no-duplicate-keys
What it does
Section titled “What it does”Reports a key that a mapping has twice, after decoding escapes and quotes ({"a": 1, "\u0061": 2} has a twice). It reads the mappings of the language’s grammar: JSON and JSONC objects, YAML and TOML mappings, JavaScript object literals, and similar entries of other languages. A YAML merge key (<<) may repeat, and the option merge_keys: forbid reports a second one too. The second key is reported, the first is shown as related.
Why it matters
Section titled “Why it matters”Parsers disagree on what a duplicate means: many keep the last value, some the first, some reject the file. The value that is lost is silent, so a file can mean something different in two tools, and the second entry is often a copy that was meant to have another name.
To fix, remove one of the keys, or give it its own name.
Example
Section titled “Example”{"a": 1, "\u0061": 2, "b\/": 3, "b/": 4}Configuration
Section titled “Configuration”lint: rules: no-duplicate-keys: level: error # off, warn, error (default) options: merge_keys: "allow"| Option | Type | Default | Description |
|---|---|---|---|
merge_keys |
string | "allow" |
Languages with a merge key (YAML <<) only. allow skips merge keys, which may repeat; forbid reports a second one like any other duplicate key.Values: allow, forbid |
Enabled by the presets: json/eslint-plugin-jsonc-recommended, html/html-validate-standard, html/htmlhint, html/html-eslint-recommended, html/eslint-plugin-vue-recommended, graphql/graphql-eslint-recommended, hcl/tflint-recommended, js/eslint-recommended, js/biome-recommended, js/oxlint, python/ruff.
Suppress one line with sudsy-disable-next-line no-duplicate-keys in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| actionlint | syntax-check/duplicate-key |
partial | partial |
| Biome | suspicious/noDuplicateObjectKeys |
full | |
| eslint | no-dupe-keys |
full | |
| eslint-plugin-jsonc | jsonc/no-dupe-keys |
full | |
| eslint-plugin-vue | no-duplicate-attributes |
partial | repeated v-on handlers and slots are allowed, and class next to :class is not a repeat |
| graphql-eslint | no-duplicate-fields |
full | |
| graphql-eslint | unique-enum-value-names |
full | |
| html-eslint | no-duplicate-attrs |
full | |
| html-validate | no-dup-attr |
full | |
| htmlhint | attr-no-duplication |
full | |
| ruff | F601 |
full | |
| ruff | F602 |
full | |
| tflint | terraform_map_duplicate_keys |
full | |
| yamllint | key-duplicates |
full | |
| yamllint | key-duplicates.forbid-duplicated-merge-keys |
full |