Why this matters
When a module imports itself, the import statement serves no purpose and may indicate a mistake during refactoring. Removing self-imports improves code clarity and avoids confusion.
Identify cases where a module imports itself. Self-imports are usually unintentional and can cause confusion or unnecessary dependencies. Suggest removing them.
When a module imports itself, the import statement serves no purpose and may indicate a mistake during refactoring. Removing self-imports improves code clarity and avoids confusion.
Side-by-side examples engineers can pattern-match during review.
// file: foo.js
import foo from './foo'; // Noncompliant
const foo = require('./foo'); // Noncompliant
// file: index.js
import index from '.'; // Noncompliant
const index = require('.'); // Noncompliant// file: foo.js
import foo from './foo'; // Noncompliant
const foo = require('./foo'); // Noncompliant
// file: index.js
import index from '.'; // Noncompliant
const index = require('.'); // NoncompliantFrom the same buckets as this rule.
For changes that affect architecture, data models, external APIs, security posture, deployment topology, or cost (>10%), create an ADR in docs/adr/ using the standard template (Context, Decision, Consequences) and link the PR and issue IDs.