Skip to content

no-restricted-library-load

Apply configured library restrictions to literal runtime loads and CommonJS resolution references.

Why

Dynamic imports, CommonJS loads, and package resolution checks can bypass library restrictions enforced for static imports.

Fix

Use the configured replacement for the runtime dependency reference; resolution checks do not themselves load a module.

Examples

Before — flagged Do not load a restricted library at runtime
src/client.ts
const client = require("axios");
After — preferred Static imports remain the static-import rule's responsibility
src/client.ts
import axios from "axios";

Options

{
"additionalProperties": false,
"properties": {
"libraries": {
"items": {
"additionalProperties": false,
"properties": {
"id": { "minLength": 1, "type": "string" },
"module": { "minLength": 1, "type": "string" },
"note": { "minLength": 1, "type": "string" },
"replacement": { "minLength": 1, "type": "string" }
},
"required": ["id", "module", "replacement"],
"type": "object"
},
"type": "array"
}
},
"required": ["libraries"],
"type": "object"
}