Skip to content

import/no-dynamic-require Restriction

What it does

Forbid imports which use an expression for the module argument.

Why is this bad?

Import statements which use an expression resolved at runtime makes it to find where the import comes from and some static code analysis tools might not be able to resolve them.

Examples

Examples of incorrect code for this rule:

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

Examples of correct code for this rule:

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

References

Released under the MIT License.