no-restricted-imports
eslint
No autofix
eslint.config.js
export default [
{
rules: {
"no-restricted-imports": "error",
},
},
];import fs from 'fs';export { fs } from 'fs';export * from 'fs';import crypto from 'crypto';
export { foo } from "bar";import DisallowedObject from "foo"/*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.
no-restricted-imports
eslint
export default [
{
rules: {
"no-restricted-imports": "error",
},
},
];no-restricted-imports
eslint plugin · restriction
{
"rules": {
"no-restricted-imports": "error"
}
}style/noRestrictedImports
style · since 1.6.0
{
"linter": {
"rules": {
"style": {
"noRestrictedImports": "error"
}
}
}
}Disallow specified modules when loaded by import
Require function names to match the name of the variable or property to which they are assigned
Disallow null comparisons without type-checking operators
Disallow specified warning terms in comments
Disallow declarations in the global scope
Enforce using named capture group in regular expression