# no-shadow

Rule `eslint/no-shadow`. Disallow variable declarations from shadowing variables declared in the outer scope

- Source: eslint
- Technologies: JavaScript
- Kind: suspicious
- Needs type information: no
- Autofix: no
- Reach: 12M weekly downloads of presets that enable it
- Trend: +13.8% last quarter
- Rank: #836 by reach, #1422 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `no-shadow` | no | no | package `eslint` | [docs](https://eslint.org/docs/latest/rules/no-shadow) |
| Oxlint | `no-shadow` | no | no | plugin `eslint`, category suspicious | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-shadow.html) |
| Biome | `suspicious/noShadow` | no | no | group suspicious, since 2.0.0 | [docs](https://biomejs.dev/linter/rules/no-shadow/) |

## Code examples

### Incorrect: the rule reports this

```js
const a = 3;
function b() {
    const a = 10;
}

const c = function () {
    const a = 10;
}

function d(a) {
    a = 10;
}
d(a);

if (true) {
    const a = 5;
}

const f = wrap(function f() {});

const C = wrap(class C {});
```

### Correct: the rule accepts this

```js
const a = 3;
function b(c) {
    const d = 10;
    if (c) {
        const e = 20;
    }
}

/*
 * Function and class names are allowed to shadow a variable
 * if the function/class expression is assigned to the variable
 * as its initializer or default value.
 */
const f = function f() {};
const g = foo ? (bar || function g() {}) : baz;
const { h = function h() {} } = obj;
function qux(i = function i() {}) {}
const C = class C {};
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "no-shadow": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "no-shadow": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "suspicious": {
        "noShadow": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Airbnb base](https://lintradar.dev/presets/airbnb-base.md) | ESLint | `eslint-config-airbnb-base` | 241 | 6.5M | +2.1% |
| [Airbnb](https://lintradar.dev/presets/airbnb.md) | ESLint | `eslint-config-airbnb` | 346 | 3.4M | +2.3% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |

## Related rules

- [typescript/no-shadow](https://lintradar.dev/rules/typescript/no-shadow.md): Disallow variable declarations from shadowing variables declared in the outer scope
- [eslint/no-empty-function](https://lintradar.dev/rules/eslint/no-empty-function.md): Disallow empty functions
- [eslint/no-nested-ternary](https://lintradar.dev/rules/eslint/no-nested-ternary.md): Disallow nested ternary expressions
- [eslint/max-classes-per-file](https://lintradar.dev/rules/eslint/max-classes-per-file.md): Enforce a maximum number of classes per file
- [eslint/default-param-last](https://lintradar.dev/rules/eslint/default-param-last.md): Enforce default parameters to be last
- [eslint/default-case](https://lintradar.dev/rules/eslint/default-case.md): Require `default` cases in `switch` statements

---

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