# consistent-compound-words

Rule `unicorn/consistent-compound-words`. Enforce consistent spelling of compound words in identifiers.

- Source: unicorn
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 9.5M weekly downloads of presets that enable it
- Trend: +30.3% last quarter
- Rank: #1117 by reach, #1136 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/consistent-compound-words` | no | suggestion | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/consistent-compound-words.md) |

## Code examples

### Incorrect: the rule reports this

```js
const passWord = 'secret';
```

```js
const isInViewPort = true;
```

```js
function unSubscribe() {}
```

### Correct: the rule accepts this

```js
const password = 'secret';
```

```js
const isInViewport = true;
```

```js
function unsubscribe() {}
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import unicorn from "eslint-plugin-unicorn";

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/consistent-compound-words": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [Unicorn unopinionated](https://lintradar.dev/presets/unicorn-unopinionated.md) | ESLint | `eslint-plugin-unicorn` | 236 | 9.5M | +30.3% |

## Related rules

- [unicorn/no-invalid-argument-count](https://lintradar.dev/rules/unicorn/no-invalid-argument-count.md): Disallow calling functions and constructors with an invalid number of arguments.
- [unicorn/no-useless-template-literals](https://lintradar.dev/rules/unicorn/no-useless-template-literals.md): Disallow useless template literal expressions.
- [unicorn/require-array-sort-compare](https://lintradar.dev/rules/unicorn/require-array-sort-compare.md): Require a compare function when calling `Array#sort()` or `Array#toSorted()`.
- [unicorn/no-this-outside-of-class](https://lintradar.dev/rules/unicorn/no-this-outside-of-class.md): Disallow `this` outside of classes.
- [unicorn/no-unreadable-for-of-expression](https://lintradar.dev/rules/unicorn/no-unreadable-for-of-expression.md): Disallow unreadable iterable expressions in `for…of` and `for await…of` loop headers.
- [unicorn/no-top-level-assignment-in-function](https://lintradar.dev/rules/unicorn/no-top-level-assignment-in-function.md): Disallow assigning to top-level variables from inside functions.

---

Web page: https://lintradar.dev/rules/unicorn/consistent-compound-words. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
