Skip to content

Latest commit

 

History

History
68 lines (45 loc) · 2.31 KB

no-missing-import.md

File metadata and controls

68 lines (45 loc) · 2.31 KB

Disallow import declarations which import non-existence modules (n/no-missing-import)

💼 This rule is enabled in the following configs: ☑️ flat/recommended, 🟢 flat/recommended-module, ✅ flat/recommended-script, ☑️ recommended, 🟢 recommended-module, ✅ recommended-script.

This is similar to no-missing-require, but this rule handles import and export declarations.

📖 Rule Details

This rule checks the file paths of import and export declarations. If the file paths don't exist, this reports these.

Examples of 👎 incorrect code for this rule:

/*eslint n/no-missing-import: "error" */

import typoFile from "./typo-file";   /*ERROR: "./typo-file" is not found.*/
import typoModule from "typo-module"; /*ERROR: "typo-module" is not found.*/

Examples of 👍 correct code for this rule:

/*eslint n/no-missing-import: "error" */

import existingFile from "./existing-file";
import existingModule from "existing-module";

Options

{
    "rules": {
        "n/no-missing-import": ["error", {
            "allowModules": [],
            "resolvePaths": ["/path/to/a/modules/directory"]
        }]
    }
}

allowModules

This can be configured in the rule options or as a shared setting settings.allowModules. Please see the shared settings documentation for more information.

resolvePaths

This can be configured in the rule options or as a shared setting settings.resolvePaths. Please see the shared settings documentation for more information.

tsconfigPath

This can be configured in the rule options or as a shared setting settings.tsconfigPath. Please see the shared settings documentation for more information.

typescriptExtensionMap

This can be configured in the rule options or as a shared setting settings.typescriptExtensionMap. Please see the shared settings documentation for more information.

🔎 Implementation