Skip to content

Files

Latest commit

 

History

History
22 lines (16 loc) · 470 Bytes

no-self-import.md

File metadata and controls

22 lines (16 loc) · 470 Bytes

Pattern: Self import

Issue: -

Description

A module importing itself creates a circular dependency that can cause runtime issues, including infinite loops, unresolved imports, or undefined values. This often happens accidentally during refactoring.

Examples

Example of incorrect code:

// foo.js
import foo from "./foo.js";
const bar = require("./foo");

Example of correct code:

// foo.js
import bar from "./bar.js";