JSON, JSONC, and JSON5 ​
This page documents 32 rules from the current dependency versions and repository configuration. Each entry includes effective severity, scope, upstream description, common messages, and incorrect/correct examples.
Explicit repository rules (3 rules) ​
jsonc/no-comments ​
UniApp pages.json and manifest.json use JSONC, which permits comments.
- Effective severity and scope: error: JSON, package.json
- Disabled in: tsconfig.json
- Autofix: Unsupported or not declared upstream
- Rule source: Official documentation
- Common messages:
Unexpected comment. - Example type: Direct code example for an explicit repository rule
Incorrect:
{ // name
"name": "Fast"
}Correct:
{ "name": "Fast" }jsonc/sort-array-values ​
Sorts npm files entries alphabetically. This does not change the package file set, though the initial diff can be large.
- Effective severity and scope: error: package.json
- Autofix: Supported; review semantics and the diff before applying
- Rule source: Official documentation
- Common messages:
Expected array values to be in {{orderText}} order. '{{thisValue}}' should be before '{{targetValue}}'.;Expected array values to be in {{orderText}} order. '{{thisValue}}' should be after '{{targetValue}}'. - Example type: Direct code example for an explicit repository rule
Incorrect:
{ "files": ["dist/z.js", "dist/a.js"] }Correct:
{ "files": ["dist/a.js", "dist/z.js"] }jsonc/sort-keys ​
Only reorders top-level and compilerOptions keys; leaves option values and arrays unchanged.
- Effective severity and scope: error: package.json, tsconfig.json
- Autofix: Supported; review semantics and the diff before applying
- Rule source: Official documentation
- Common messages:
Expected object keys to be in {{orderText}} order. '{{thisName}}' should be before '{{targetName}}'.;Expected object keys to be in {{orderText}} order. '{{thisName}}' should be after '{{targetName}}'. - Example type: Direct code example for an explicit repository rule
Incorrect:
{ "version": "1.0.0", "name": "demo" }Correct:
{ "name": "demo", "version": "1.0.0" }Rules from third-party presets (29 rules) ​
jsonc/comma-dangle ​
Checks the corresponding code constraint. Upstream description: require or disallow trailing commas
- Effective severity and scope: error: JSON, package.json, tsconfig.json
- Autofix: Supported; review semantics and the diff before applying
- Rule source: Official documentation
- Common messages:
Unexpected trailing comma.;Missing trailing comma. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "name": "Fast", }Correct:
{ "name": "Fast" }jsonc/no-bigint-literals ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow BigInt literals
- Effective severity and scope: error: JSON, JSONC, JSON5, package.json, tsconfig.json
- Autofix: Unsupported or not declared upstream
- Rule source: Official documentation
- Common messages:
BigInt literals are not allowed. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "id": 1n }Correct:
{ "id": "1" }jsonc/no-binary-expression ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow binary expression
- Effective severity and scope: error: JSON, JSONC, JSON5, package.json, tsconfig.json
- Autofix: Supported; review semantics and the diff before applying
- Rule source: Official documentation
- Common messages:
The binary expressions are not allowed. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "timeout": 1000 + 500 }Correct:
{ "timeout": 1500 }jsonc/no-binary-numeric-literals ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow binary numeric literals
- Effective severity and scope: error: JSON, JSONC, JSON5, package.json, tsconfig.json
- Autofix: Supported; review semantics and the diff before applying
- Rule source: Official documentation
- Common messages:
Binary numeric literals should not be used. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "mask": 0b1010 }Correct:
{ "mask": 10 }jsonc/no-dupe-keys ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow duplicate keys in object literals
- Effective severity and scope: error: JSON, JSONC, JSON5, package.json, tsconfig.json
- Autofix: Unsupported or not declared upstream
- Rule source: Official documentation
- Common messages:
Duplicate key '{{name}}'. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "name": "Fast", "name": "Admin" }Correct:
{ "name": "Fast", "title": "Admin" }jsonc/no-escape-sequence-in-identifier ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow escape sequences in identifiers.
- Effective severity and scope: error: JSON, JSONC, JSON5, package.json, tsconfig.json
- Autofix: Supported; review semantics and the diff before applying
- Rule source: Official documentation
- Common messages:
Escape sequence in identifiers should not be used. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ \u0061: "Fast" }Correct:
{ a: "Fast" }jsonc/no-floating-decimal ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow leading or trailing decimal points in numeric literals
- Effective severity and scope: error: JSON, JSONC, package.json, tsconfig.json
- Autofix: Supported; review semantics and the diff before applying
- Rule source: Official documentation
- Common messages:
A leading decimal point can be confused with a dot.;A trailing decimal point can be confused with a dot. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "ratio": .5 }Correct:
{ "ratio": 0.5 }jsonc/no-hexadecimal-numeric-literals ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow hexadecimal numeric literals
- Effective severity and scope: error: JSON, JSONC, package.json, tsconfig.json
- Autofix: Supported; review semantics and the diff before applying
- Rule source: Official documentation
- Common messages:
Hexadecimal numeric literals should not be used. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "color": 0xff }Correct:
{ "color": 255 }jsonc/no-infinity ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow Infinity
- Effective severity and scope: error: JSON, JSONC, package.json, tsconfig.json
- Autofix: Unsupported or not declared upstream
- Rule source: Official documentation
- Common messages:
Infinity should not be used. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "limit": Infinity }Correct:
{ "limit": null }jsonc/no-irregular-whitespace ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow irregular whitespace
- Effective severity and scope: error: JSON, JSONC, JSON5, package.json, tsconfig.json
- Autofix: Unsupported or not declared upstream
- Rule source: Official documentation
- Common messages:
Irregular whitespace not allowed. - Example type: Direct code example for a third-party preset rule
Incorrect:
{
"name": "Fast"
}Correct:
{
"name": "Fast"
}jsonc/no-multi-str ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow multiline strings
- Effective severity and scope: error: JSON, JSONC, package.json, tsconfig.json
- Autofix: Unsupported or not declared upstream
- Rule source: Official documentation
- Common messages:
Multiline support is limited to JSON5 only. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "text": "first\
second" }Correct:
{ "text": "first\nsecond" }jsonc/no-nan ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow NaN
- Effective severity and scope: error: JSON, JSONC, package.json, tsconfig.json
- Autofix: Unsupported or not declared upstream
- Rule source: Official documentation
- Common messages:
NaN should not be used. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "value": NaN }Correct:
{ "value": null }jsonc/no-number-props ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow number property keys
- Effective severity and scope: error: JSON, JSONC, JSON5, package.json, tsconfig.json
- Autofix: Supported; review semantics and the diff before applying
- Rule source: Official documentation
- Common messages:
The number property keys are not allowed. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ 1: "one" }Correct:
{ "1": "one" }jsonc/no-numeric-separators ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow numeric separators
- Effective severity and scope: error: JSON, JSONC, JSON5, package.json, tsconfig.json
- Autofix: Supported; review semantics and the diff before applying
- Rule source: Official documentation
- Common messages:
Numeric separators are not allowed. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "size": 1_000 }Correct:
{ "size": 1000 }jsonc/no-octal ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow legacy octal literals
- Effective severity and scope: error: JSON, JSONC, JSON5, package.json, tsconfig.json
- Autofix: Unsupported or not declared upstream
- Rule source: Official documentation
- Common messages:
Octal literals should not be used. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "mode": 071 }Correct:
{ "mode": 57 }jsonc/no-octal-numeric-literals ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow octal numeric literals
- Effective severity and scope: error: JSON, JSONC, JSON5, package.json, tsconfig.json
- Autofix: Supported; review semantics and the diff before applying
- Rule source: Official documentation
- Common messages:
Octal numeric literals should not be used. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "mode": 0o71 }Correct:
{ "mode": 57 }jsonc/no-parenthesized ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow parentheses around the expression
- Effective severity and scope: error: JSON, JSONC, JSON5, package.json, tsconfig.json
- Autofix: Supported; review semantics and the diff before applying
- Rule source: Official documentation
- Common messages:
Parentheses around expression should not be used. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "timeout": (1000) }Correct:
{ "timeout": 1000 }jsonc/no-plus-sign ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow plus sign
- Effective severity and scope: error: JSON, JSONC, package.json, tsconfig.json
- Autofix: Supported; review semantics and the diff before applying
- Rule source: Official documentation
- Common messages:
Plus sign should not be used. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "offset": +1 }Correct:
{ "offset": 1 }jsonc/no-regexp-literals ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow RegExp literals
- Effective severity and scope: error: JSON, JSONC, JSON5, package.json, tsconfig.json
- Autofix: Unsupported or not declared upstream
- Rule source: Official documentation
- Common messages:
RegExp literals are not allowed. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "pattern": /fast/i }Correct:
{ "pattern": "fast" }jsonc/no-sparse-arrays ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow sparse arrays
- Effective severity and scope: error: JSON, JSONC, JSON5, package.json, tsconfig.json
- Autofix: Unsupported or not declared upstream
- Rule source: Official documentation
- Common messages:
Unexpected comma in middle of array. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "items": [1, , 3] }Correct:
{ "items": [1, null, 3] }jsonc/no-template-literals ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow template literals
- Effective severity and scope: error: JSON, JSONC, JSON5, package.json, tsconfig.json
- Autofix: Supported; review semantics and the diff before applying
- Rule source: Official documentation
- Common messages:
The template literals are not allowed. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "name": `Fast` }Correct:
{ "name": "Fast" }jsonc/no-undefined-value ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow undefined
- Effective severity and scope: error: JSON, JSONC, JSON5, package.json, tsconfig.json
- Autofix: Unsupported or not declared upstream
- Rule source: Official documentation
- Common messages:
'undefined' is not allowed. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "value": undefined }Correct:
{ "value": null }jsonc/no-unicode-codepoint-escapes ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow Unicode code point escape sequences.
- Effective severity and scope: error: JSON, JSONC, JSON5, package.json, tsconfig.json
- Autofix: Supported; review semantics and the diff before applying
- Rule source: Official documentation
- Common messages:
Unicode code point escape sequence should not be used. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "emoji": "\u{1F600}" }Correct:
{ "emoji": "😀" }jsonc/no-useless-escape ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow unnecessary escape usage
- Effective severity and scope: error: JSON, JSONC, JSON5, package.json, tsconfig.json
- Autofix: Unsupported or not declared upstream
- Rule source: Official documentation
- Common messages:
Unnecessary escape character: \{{character}}.;Remove the '\'. This maintains the current functionality.;Remove the '\' if it was inserted by mistake. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "name": "Fast\!" }Correct:
{ "name": "Fast!" }jsonc/quote-props ​
Checks the corresponding code constraint. Upstream description: require quotes around object literal property names
- Effective severity and scope: error: JSON, JSONC, package.json, tsconfig.json
- Autofix: Supported; review semantics and the diff before applying
- Rule source: Official documentation
- Common messages:
Properties should be quoted as '{{property}}' is a reserved word.;Inconsistently quoted property '{{key}}' found.;Unnecessarily quoted property '{{property}}' found. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ name: "Fast" }Correct:
{ "name": "Fast" }jsonc/quotes ​
Checks the corresponding code constraint. Upstream description: enforce use of double or single quotes
- Effective severity and scope: error: JSON, JSONC, package.json, tsconfig.json
- Autofix: Supported; review semantics and the diff before applying
- Rule source: Official documentation
- Common messages:
Strings must use {{description}}. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ 'name': 'Fast' }Correct:
{ "name": "Fast" }jsonc/space-unary-ops ​
Checks the corresponding code constraint. Upstream description: disallow spaces after unary operators
- Effective severity and scope: error: JSON, JSONC, JSON5, package.json, tsconfig.json
- Autofix: Supported; review semantics and the diff before applying
- Rule source: Official documentation
- Common messages:
Unexpected space before unary operator '{{operator}}'.;Unexpected space after unary operator '{{operator}}'.;Unary operator '{{operator}}' must be followed by whitespace. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "offset": - 1 }Correct:
{ "offset": -1 }jsonc/valid-json-number ​
Validates the relevant syntax, properties, or arguments. Upstream description: disallow invalid number for JSON
- Effective severity and scope: error: JSON, JSONC, package.json, tsconfig.json
- Autofix: Supported; review semantics and the diff before applying
- Rule source: Official documentation
- Common messages:
Invalid number for JSON.;Spaces after minus sign are not allowed in JSON.;Plus signs are not allowed in JSON. - Example type: Direct code example for a third-party preset rule
Incorrect:
{ "value": 01 }Correct:
{ "value": 1 }jsonc/vue-custom-block/no-parsing-error ​
Disallows unsafe, invalid, or misleading constructs. Upstream description: disallow parsing errors in Vue custom blocks
- Effective severity and scope: error: JSON, JSONC, JSON5, package.json, tsconfig.json
- Autofix: Unsupported or not declared upstream
- Rule source: Official documentation
- Example type: Direct code example for a third-party preset rule
Incorrect:
<i18n>{ "hello": }</i18n>Correct:
<i18n>{ "hello": "Hello" }</i18n>