# no-restricted-imports

Rule `eslint/no-restricted-imports`. Disallow specified modules when loaded by `import`

- Source: eslint
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 2.5M weekly downloads of presets that enable it
- Trend: +97.4% last quarter
- Rank: #1481 by reach, #266 by growth

## Linters

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

## Code examples

### Incorrect: the rule reports this

```js
import fs from 'fs';
```

```js
export { fs } from 'fs';
```

```js
export * from 'fs';
```

### Correct: the rule accepts this

```js
import crypto from 'crypto';
export { foo } from "bar";
```

```js
import DisallowedObject from "foo"
```

```js
/*eslint no-restricted-imports: ["error", { paths: [{
    name: "foo",
    importNames: ["DisallowedObject"],
    message: "Please import 'DisallowedObject' from '/bar/baz/' instead."
}]}]*/

import { AllowedObject as DisallowedObject } from "foo";
```

Examples from the ESLint documentation.

## Enable it

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

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

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "no-restricted-imports": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "style": {
        "noRestrictedImports": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [typescript/no-restricted-imports](https://lintradar.dev/rules/typescript/no-restricted-imports.md): Disallow specified modules when loaded by `import`
- [eslint/func-name-matching](https://lintradar.dev/rules/eslint/func-name-matching.md): Require function names to match the name of the variable or property to which they are assigned
- [eslint/no-eq-null](https://lintradar.dev/rules/eslint/no-eq-null.md): Disallow `null` comparisons without type-checking operators
- [eslint/no-warning-comments](https://lintradar.dev/rules/eslint/no-warning-comments.md): Disallow specified warning terms in comments
- [eslint/no-implicit-globals](https://lintradar.dev/rules/eslint/no-implicit-globals.md): Disallow declarations in the global scope
- [eslint/prefer-named-capture-group](https://lintradar.dev/rules/eslint/prefer-named-capture-group.md): Enforce using named capture group in regular expression

---

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