JSON Plugin
Rules for linting .json files containing arbitrary data in the JavaScript Object Notation (JSON) format.
This plugin comes packaged with the flint npm package.
Presets
Section titled “Presets”Flint’s JSON plugin provides the following preset:
| Preset | Recommended | Description |
|---|---|---|
logical | ✅ Always | Common rules for finding bugs and good practices in JSON files. |
Flint recommends using the logical preset:
import { function defineConfig(definition: ConfigDefinition): Config
Defines a new linter configuration for a Flint config file.
defineConfig, const json: Plugin<RuleAbout, "all", [Rule<{ readonly description: "Reports unnecessary duplicate keys that override previous values."; readonly id: "keyDuplicates"; readonly presets: ["logical", "logicalStrict"];} & { presets?: ("logical" | "logicalStrict")[]; url: string;}, object, object, "duplicateKey", { readonly allowKeys: ZodDefault<ZodArray<ZodString>>;}>, Rule<{ readonly description: "Reports object keys that are not normalized using Unicode normalization forms."; readonly id: "keyNormalization"; readonly presets: [...];} & { presets?: ("logical" | "logicalStrict")[]; url: string;}, object, object, "unnormalizedKey", { ...;}>, Rule<...>]>
json } from "flint";
export default function defineConfig(definition: ConfigDefinition): Config
Defines a new linter configuration for a Flint config file.
defineConfig({ ConfigDefinition.use: ConfigUseDefinition[]
Specifies the files to be linted alongside the rules and settings to lint with.
use: [ { ConfigUseDefinition.files: AnyLevelDeep<FilesValue>
A list of glob patterns describing which file(s) to lint.
files: const json: Plugin<RuleAbout, "all", [Rule<{ readonly description: "Reports unnecessary duplicate keys that override previous values."; readonly id: "keyDuplicates"; readonly presets: ["logical", "logicalStrict"];} & { presets?: ("logical" | "logicalStrict")[]; url: string;}, object, object, "duplicateKey", { readonly allowKeys: ZodDefault<ZodArray<ZodString>>;}>, Rule<{ readonly description: "Reports object keys that are not normalized using Unicode normalization forms."; readonly id: "keyNormalization"; readonly presets: [...];} & { presets?: ("logical" | "logicalStrict")[]; url: string;}, object, object, "unnormalizedKey", { ...;}>, Rule<...>]>
json.Plugin<RuleAbout, "all", [Rule<{ readonly description: "Reports unnecessary duplicate keys that override previous values."; readonly id: "keyDuplicates"; readonly presets: [...]; } & { ...; }, object, object, "duplicateKey", { ...; }>, Rule<...>, Rule<...>]>.files: Record<"all", FilesValue>
Selectors of files this plugin suggests applying its rules to.
files.all: FilesValue
all, ConfigUseDefinition.rules: AnyLevelDeep<ConfigRuleDefinition>
Any number of rules and/or presets of rules to enable for those files.
rules: const json: Plugin<RuleAbout, "all", [Rule<{ readonly description: "Reports unnecessary duplicate keys that override previous values."; readonly id: "keyDuplicates"; readonly presets: ["logical", "logicalStrict"];} & { presets?: ("logical" | "logicalStrict")[]; url: string;}, object, object, "duplicateKey", { readonly allowKeys: ZodDefault<ZodArray<ZodString>>;}>, Rule<{ readonly description: "Reports object keys that are not normalized using Unicode normalization forms."; readonly id: "keyNormalization"; readonly presets: [...];} & { presets?: ("logical" | "logicalStrict")[]; url: string;}, object, object, "unnormalizedKey", { ...;}>, Rule<...>]>
json.Plugin<RuleAbout, "all", [Rule<{ readonly description: "Reports unnecessary duplicate keys that override previous values."; readonly id: "keyDuplicates"; readonly presets: [...]; } & { ...; }, object, object, "duplicateKey", { ...; }>, Rule<...>, Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "logicalStrict">
Preset lists of rules to enable on files.
presets.logical: Rule<RuleAbout, object, object, string, AnyOptionalSchema | undefined>[]
logical, }, ],});logical
Section titled “logical”Rules that find bugs and enforce good JSON practices for most-to-all JSON files.
import { function defineConfig(definition: ConfigDefinition): Config
Defines a new linter configuration for a Flint config file.
defineConfig, const json: Plugin<RuleAbout, "all", [Rule<{ readonly description: "Reports unnecessary duplicate keys that override previous values."; readonly id: "keyDuplicates"; readonly presets: ["logical", "logicalStrict"];} & { presets?: ("logical" | "logicalStrict")[]; url: string;}, object, object, "duplicateKey", { readonly allowKeys: ZodDefault<ZodArray<ZodString>>;}>, Rule<{ readonly description: "Reports object keys that are not normalized using Unicode normalization forms."; readonly id: "keyNormalization"; readonly presets: [...];} & { presets?: ("logical" | "logicalStrict")[]; url: string;}, object, object, "unnormalizedKey", { ...;}>, Rule<...>]>
json } from "flint";
export default function defineConfig(definition: ConfigDefinition): Config
Defines a new linter configuration for a Flint config file.
defineConfig({ ConfigDefinition.use: ConfigUseDefinition[]
Specifies the files to be linted alongside the rules and settings to lint with.
use: [ { ConfigUseDefinition.files: AnyLevelDeep<FilesValue>
A list of glob patterns describing which file(s) to lint.
files: const json: Plugin<RuleAbout, "all", [Rule<{ readonly description: "Reports unnecessary duplicate keys that override previous values."; readonly id: "keyDuplicates"; readonly presets: ["logical", "logicalStrict"];} & { presets?: ("logical" | "logicalStrict")[]; url: string;}, object, object, "duplicateKey", { readonly allowKeys: ZodDefault<ZodArray<ZodString>>;}>, Rule<{ readonly description: "Reports object keys that are not normalized using Unicode normalization forms."; readonly id: "keyNormalization"; readonly presets: [...];} & { presets?: ("logical" | "logicalStrict")[]; url: string;}, object, object, "unnormalizedKey", { ...;}>, Rule<...>]>
json.Plugin<RuleAbout, "all", [Rule<{ readonly description: "Reports unnecessary duplicate keys that override previous values."; readonly id: "keyDuplicates"; readonly presets: [...]; } & { ...; }, object, object, "duplicateKey", { ...; }>, Rule<...>, Rule<...>]>.files: Record<"all", FilesValue>
Selectors of files this plugin suggests applying its rules to.
files.all: FilesValue
all, ConfigUseDefinition.rules: AnyLevelDeep<ConfigRuleDefinition>
Any number of rules and/or presets of rules to enable for those files.
rules: const json: Plugin<RuleAbout, "all", [Rule<{ readonly description: "Reports unnecessary duplicate keys that override previous values."; readonly id: "keyDuplicates"; readonly presets: ["logical", "logicalStrict"];} & { presets?: ("logical" | "logicalStrict")[]; url: string;}, object, object, "duplicateKey", { readonly allowKeys: ZodDefault<ZodArray<ZodString>>;}>, Rule<{ readonly description: "Reports object keys that are not normalized using Unicode normalization forms."; readonly id: "keyNormalization"; readonly presets: [...];} & { presets?: ("logical" | "logicalStrict")[]; url: string;}, object, object, "unnormalizedKey", { ...;}>, Rule<...>]>
json.Plugin<RuleAbout, "all", [Rule<{ readonly description: "Reports unnecessary duplicate keys that override previous values."; readonly id: "keyDuplicates"; readonly presets: [...]; } & { ...; }, object, object, "duplicateKey", { ...; }>, Rule<...>, Rule<...>]>.presets: PluginPresets<RuleAbout, "logical" | "logicalStrict">
Preset lists of rules to enable on files.
presets.logical: Rule<RuleAbout, object, object, string, AnyOptionalSchema | undefined>[]
logical, }, ],});| Flint Rule | Preset |
|---|---|
keyDuplicatesReports unnecessary duplicate keys that override previous values. | logical |
keyNormalizationReports object keys that are not normalized using Unicode normalization forms. | logical |
valueSafetyReports JSON values that are unsafe for data interchange. | logical |
Selectors
Section titled “Selectors”Flint’s JSON plugin provides the following files selector:
all:**/*.json