# class-name

Rule `sonarjs/class-name`. Class names should comply with a naming convention

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1191 by reach, #492 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/class-name` | yes | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-101/) |

## Code examples

### Incorrect: the rule reports this

```js
class my_class {...}
```

### Correct: the rule accepts this

```js
class MyClass {...}
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/class-name": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [sonarjs/chai-determinate-assertion](https://lintradar.dev/rules/sonarjs/chai-determinate-assertion.md): Chai assertions should have only one reason to succeed
- [sonarjs/code-eval](https://lintradar.dev/rules/sonarjs/code-eval.md): Dynamic code execution should not use user-controlled data
- [sonarjs/call-argument-line](https://lintradar.dev/rules/sonarjs/call-argument-line.md): Function call arguments should not start on new lines
- [sonarjs/comma-or-logical-or-case](https://lintradar.dev/rules/sonarjs/comma-or-logical-or-case.md): Comma and logical OR operators should not be used in switch cases
- [sonarjs/block-scoped-var](https://lintradar.dev/rules/sonarjs/block-scoped-var.md): Variables should be used in the blocks where they are declared
- [sonarjs/concise-regex](https://lintradar.dev/rules/sonarjs/concise-regex.md): Regular expression quantifiers and character classes should be used concisely

---

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