Skip to content

Consistent Compound Words

Suggestion
small-rules/consistent-compound-words

Enforce consistent spelling of compound words in identifiers.

Rationale

A lot of words that used to be two words are one word now: callback, database, timeout, username. When half a codebase writes timeOut and the other half writes timeout, a search for one misses the other, and autocomplete offers you both. This picks the closed spelling and sticks to it.

By default it only checks the names you declare: variables, functions, classes, and parameters. Property names often come from someone else’s API, so checkProperties and checkShorthandProperties are off until you turn them on. Add your own pairs with replacements.

Diagnostic Messages

error
Prefer `{{replacement}}` over `{{name}}`.
rename
Rename to `{{replacement}}`.

Configuration

This rule accepts one options object after the severity.

allowListOptional

No description available.

checkPropertiesOptional

No description available.

checkShorthandPropertiesOptional

No description available.

checkVariablesOptional

No description available.

extendDefaultReplacementsOptional

No description available.

replacementsOptional

No description available.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/consistent-compound-words": [
"error",
{
"allowList": {},
"checkProperties": false,
"checkShorthandProperties": false,
"checkVariables": false,
"extendDefaultReplacements": false,
"replacements": {}
}
]
}
}

Examples

Split compound word
const passWord = 'secret';
Consistent compound spelling
const password = 'secret';