💼 This rule is enabled in the following configs: 🟢 recommended-module
, ✅ recommended-script
.
This is similar to no-missing-require, but this rule handles import
and export
declarations.
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";
{
"rules": {
"n/no-missing-import": ["error", {
"allowModules": [],
"resolvePaths": ["/path/to/a/modules/directory"]
}]
}
}
This can be configured in the rule options or as a shared setting settings.allowModules
.
Please see the shared settings documentation for more information.
This can be configured in the rule options or as a shared setting settings.resolvePaths
.
Please see the shared settings documentation for more information.
This can be configured in the rule options or as a shared setting settings.tsconfigPath
.
Please see the shared settings documentation for more information.
This can be configured in the rule options or as a shared setting settings.typescriptExtensionMap
.
Please see the shared settings documentation for more information.
If using typescript, you may want to ignore type imports.
{
"rules": {
"n/no-missing-import": ["error", {
"ignoreTypeImport": true
}]
}
}
In this way, the following code will not be reported:
import type { TypeOnly } from "@types/only-types";