import/no-unused-modules
eslint-plugin-import
import importPlugin from "eslint-plugin-import";
export default [
{
plugins: { import: importPlugin },
rules: {
"import/no-unused-modules": "error",
},
},
];Forbid modules without exports, or exports without matching import in another module.
const class MyClass { /*...*/ }
function makeClass() { return new MyClass(...arguments) }export default function () { /*...*/ }export const foo = function () { /*...*/ }export { foo, bar }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-unused-modules
eslint-plugin-import
import importPlugin from "eslint-plugin-import";
export default [
{
plugins: { import: importPlugin },
rules: {
"import/no-unused-modules": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Enforce which files can be imported in a given folder.
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).