Skip to content

Files

Latest commit

 

History

History
23 lines (17 loc) · 588 Bytes

File metadata and controls

23 lines (17 loc) · 588 Bytes

Pattern: Misplaced import

Issue: -

Description

Import statements should be grouped together at the top of the file. Since imports are hoisted, imported modules are evaluated before any interspersed statements, which can lead to unexpected behavior when imports are scattered throughout the file.

Examples

Example of incorrect code:

import { x } from "./foo";
export { x };
import { y } from "./bar"; // Import after non-import statement

Example of correct code:

import { x } from "./foo";
import { y } from "./bar";
export { x, y };