noDuplicateJsonKeys (since v1.0.0)
Diagnostic Category: lint/nursery/noDuplicateJsonKeys
Disallow two keys with the same name inside a JSON object.
Examples
Section titled ExamplesInvalid
Section titled Invalid{ "title": "New title", "title": "Second title"}
nursery/noDuplicateJsonKeys.js:2:3 lint/nursery/noDuplicateJsonKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ The key title was already declared.
1 │ {
> 2 │ "title": "New title",
│ ^^^^^^^
3 │ "title": "Second title"
4 │ }
ℹ This where a duplicated key was declared again.
1 │ {
2 │ "title": "New title",
> 3 │ "title": "Second title"
│ ^^^^^^^
4 │ }
5 │
ℹ If a key is defined multiple times, only the last definition takes effect. Previous definitions are ignored.
Valid
Section titled Valid{ "title": "New title", "secondTitle": "Second title"}