---
url: /docs/guide/usage/linter/rules/eslint/no-underscore-dangle.md
---

### What it does

Disallows dangling underscores in identifiers.

### Why is this bad?

There is a long history of using `_` as a prefix or suffix for private members in JavaScript.
It is however recommended to use the formal private class feature introduced in ES2022.
See <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_elements> for more information.

### Examples

Examples of **incorrect** code for this rule:

```js
let foo_;
const __proto__ = {};
foo._bar();
```

Examples of **correct** code for this rule:

```js
const _ = require("underscore");
const obj = _.contains(items, item);
obj.__proto__ = {};
const file = __filename;
function foo(_bar) {}
const bar = { onClick(_bar) {} };
const baz = (_bar) => {};
```

## Configuration

### allow

type: `string[]`

default: `[]`

An array of variable names that are allowed to have dangling underscores.

### allowAfterSuper

type: `boolean`

default: `false`

Whether to allow dangling underscores in members of the `super` object.

### allowAfterThis

type: `boolean`

default: `false`

Whether to allow dangling underscores in members of the `this` object.

### allowAfterThisConstructor

type: `boolean`

default: `false`

Whether to allow dangling underscores in members of the `this.constructor` object.

### allowFunctionParams

type: `boolean`

default: `true`

Whether to allow dangling underscores in function parameter names.

### allowInArrayDestructuring

type: `boolean`

default: `true`

Whether to allow dangling underscores in variable names assigned by array destructuring.

### allowInObjectDestructuring

type: `boolean`

default: `true`

Whether to allow dangling underscores in variable names assigned by object destructuring.

### allowInUsingDeclarations

type: `boolean`

default: `false`

Whether to allow dangling underscores in `using` and `await using` declarations.

### enforceInClassFields

type: `boolean`

default: `false`

Whether to enforce dangling underscores in class field names.

### enforceInMethodNames

type: `boolean`

default: `false`

Whether to enforce dangling underscores in method names.

## How to use

## Version

This rule was added in v1.62.0.

## References
