import/no-restricted-paths
eslint-plugin-import
import importPlugin from "eslint-plugin-import";
export default [
{
plugins: { import: importPlugin },
rules: {
"import/no-restricted-paths": "error",
},
},
];// client/foo.js
import bar from '../server/bar';// server/one/a.js
import a from '../two/a'// client/foo.js
import a from './sub-module/baz'// server/bar.js
import baz from '../client/baz';// server/one/a.js
import b from './b'// client/sub-module/bar.js
import b from './baz'Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
import/no-restricted-paths
eslint-plugin-import
import importPlugin from "eslint-plugin-import";
export default [
{
plugins: { import: importPlugin },
rules: {
"import/no-restricted-paths": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Forbid modules without exports, or exports without matching import in another module.
Enforce a leading comment with the webpackChunkName for dynamic imports.
Forbid imported names marked with @deprecated documentation tag.
Enforce either using, or omitting, the node: protocol when importing Node.js builtin modules.
Forbid potentially ambiguous parse goal (script vs. module).