# variable-name

Rule `sonarjs/variable-name`. Variable, property and parameter names should comply with a naming convention

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #2181 by reach

## Linters

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

## Code examples

### Incorrect: the rule reports this

```js
const foo_bar = 1;
const baz_ = 2;
```

### Correct: the rule accepts this

```js
const fooBar = 1;
const _baz = 2;
```

Examples from the ESLint documentation.

## Enable it

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

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

## Related rules

- [sonarjs/values-not-convertible-to-numbers](https://lintradar.dev/rules/sonarjs/values-not-convertible-to-numbers.md): Values not convertible to numbers should not be used in numeric comparisons
- [sonarjs/unicode-aware-regex](https://lintradar.dev/rules/sonarjs/unicode-aware-regex.md): Regular expressions using Unicode character classes or property escapes should enable the unicode flag
- [sonarjs/too-many-break-or-continue-in-loop](https://lintradar.dev/rules/sonarjs/too-many-break-or-continue-in-loop.md): Loops should not contain more than a single "break" or "continue" statement
- [sonarjs/strings-comparison](https://lintradar.dev/rules/sonarjs/strings-comparison.md): Comparison operators should not be used with strings
- [sonarjs/shorthand-property-grouping](https://lintradar.dev/rules/sonarjs/shorthand-property-grouping.md): Shorthand object properties should be grouped at the beginning or end of an object declaration
- [sonarjs/prefer-object-literal](https://lintradar.dev/rules/sonarjs/prefer-object-literal.md): Object literal syntax should be used

---

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