Skip to main content

Disallow specified modules when loaded by import (no-restricted-imports)

Rule Details

This rule extends the base eslint/no-restricted-imports rule.

How to Use

// note you must disable the base rule as it can report incorrect errors
"no-restricted-imports": "off",
"@typescript-eslint/no-restricted-imports": "off"


See eslint/no-restricted-imports options. This rule adds the following options:


(default: false)

You can specify this option for a specific path or pattern as follows:

"@typescript-eslint/no-restricted-imports": ["error", {
"paths": [{
"name": "import-foo",
"message": "Please use import-bar instead.",
"allowTypeImports": true
}, {
"name": "import-baz",
"message": "Please use import-quux instead.",
"allowTypeImports": true

When set to true, the rule will allow Type-Only Imports.

Examples of code with the above config:

import foo from 'import-foo';
export { Foo } from 'import-foo';

import baz from 'import-baz';
export { Baz } from 'import-baz';


  • โœ… Recommended
  • ๐Ÿ”ง Fixable
  • ๐Ÿ’ญ Requires type information