Skip to content

Files

Latest commit

 

History

History
21 lines (15 loc) · 480 Bytes

no-dynamic-require.md

File metadata and controls

21 lines (15 loc) · 480 Bytes

Pattern: Dynamic module path

Issue: -

Description

Using expressions that are resolved at runtime in import statements makes it difficult to determine the module source and hinders static analysis tools. Module paths should be static strings for better code navigation and optimization.

Examples

Example of incorrect code:

require(name);
require(`../${name}`);

Example of correct code:

require("../name");
require(`../name`);