key-name-casing
What it does
Section titled “What it does”Reports a key that does not follow one of the allowed naming conventions of the option allowed (default camelCase; also PascalCase, snake_case, kebab-case, SCREAMING_SNAKE_CASE). A key with punctuation or white space never matches; camelCase also rejects _ and -, and snake_case and kebab-case reject capitals. Keys that match one of the ignored_keys regexes, and a YAML merge key (<<), are not checked. There is no fix, because renaming a key changes the data.
Why it matters
Section titled “Why it matters”Configuration and data files are read by programs and people, and one casing for all keys lets both guess a key’s name without looking it up. A key in another casing is often a typo or a copy from another file with other conventions.
To fix, rename the key and every place that reads it.
Example
Section titled “Example”With this configuration:
key-name-casing: level: warn options: allowed: [snake_case, kebab-case] ignored_keys: ["^P"]{"camelCase": 1, "snake_case": 2, "kebab-case": 3, "PascalCase": 4, "SCREAMING_SNAKE": 5, "a b": 6}Configuration
Section titled “Configuration”lint: rules: key-name-casing: level: warn # off (default), warn, error options: allowed: ["camelCase"] ignored_keys: []| Option | Type | Default | Description |
|---|---|---|---|
allowed |
list | ["camelCase"] |
Accepted conventions: camelCase, PascalCase, snake_case, kebab-case, SCREAMING_SNAKE_CASE. A key is fine when it matches one.Values: camelCase, PascalCase, snake_case, kebab-case, SCREAMING_SNAKE_CASE |
ignored_keys |
list | [] |
Regular expressions; matching keys stay where they are and are not compared. |
Suppress one line with sudsy-disable-next-line key-name-casing in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| eslint-plugin-jsonc | jsonc/key-name-casing |
full |