noSelfImport (JavaScript)
Language JavaScript (and super languages)
Summary
Section titled “Summary”- Diagnostic Category:
lint/nursery/noSelfImport - This rule doesn’t have a fix.
- The default severity of this rule is error.
- This rule belongs to the following domains:
- Sources:
- Same as
import/no-self-import
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noSelfImport": "error" } } }}Description
Section titled “Description”Forbid a module from importing itself.
A module that imports itself is almost always the result of a mistake
made while refactoring. It creates a circular dependency on the module
itself, which can leave the imported value undefined during evaluation
and cause some bundlers to emit a warning or fail.
This rule reports both static import statements and dynamic imports
such as import() and require() calls that resolve to the file they
appear in.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”import foo from "./foo.js";/foo.js:1:17 lint/nursery/noSelfImport ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ This module imports itself.
> 1 │ import foo from "./foo.js";
│ ^^^^^^^^^^
2 │
ℹ A module that imports itself is a circular dependency, which can leave the imported value undefined during evaluation and cause some bundlers to warn or fail.
ℹ Remove this import, or update it to point to the intended module.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
const bar = require("./bar.js");/bar.js:1:13 lint/nursery/noSelfImport ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ This module imports itself.
> 1 │ const bar = require("./bar.js");
│ ^^^^^^^^^^^^^^^^^^^
2 │
ℹ A module that imports itself is a circular dependency, which can leave the imported value undefined during evaluation and cause some bundlers to warn or fail.
ℹ Remove this import, or update it to point to the intended module.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
import bar from "./bar.js";Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.