no-unresolved
UnreleasedConfiguration
Rule Details
Report imports whose module cannot be resolved. The rule checks ES imports,
re-exports, and dynamic import() calls with string literals. It ignores explicit
import type and export type declarations.
Examples of incorrect code for this rule, when the target does not exist:
Examples of correct code for this rule, when existing.js exists:
The rule does not provide automatic fixes or suggestions.
Options
The ignore option is separate from settings['import/ignore']: a module can
exist even when other import rules cannot parse its contents.
Resolution settings
The default node resolver checks runtime files, including JSON and native
modules. It tries .mjs, .js, .json, and .node extensions. For packages,
it tries the module, jsnext:main, and main fields in that order, then falls
back to index files.
It does not treat an installed @types package as a runtime module.
import/core-modules exempts exact module names, such as electron.
import/resolver accepts node, an object containing Node options, or an array
of resolvers tried in order. Node options include extensions, paths,
moduleDirectory, and preserveSymlinks. The legacy import/resolve setting
supplies Node options when import/resolver is absent.
Differences from upstream
- Supported resolvers are
nodeandtypescript, also accepted aseslint-import-resolver-nodeandeslint-import-resolver-typescript. For example,settings['import/resolver'] = 'webpack'reports a resolver error and unresolved imports. For bundler aliases, usetypescriptwith matchingpathsintsconfig.json, or exclude those imports with theignoreoption. - The
typescriptresolver follows the TypeScript project selected by rslint. Itsproject,alwaysTryTypes, and other resolver-specific options have no effect. For example,{ typescript: { project: 'tsconfig.app.json' } }does not select that config; uselanguageOptions.parserOptions.projectinstead. - If an
import/resolverobject contains several resolver names, they are tried alphabetically. Use an array, such as['typescript', 'node'], to choose the order explicitly. - Babel's experimental
export value from './module'syntax is not supported. Useexport { default as value } from './module'instead.