Skip to main content

Unresolved imports

unresolvedImportsDetection Detects and reports import statements that rev-dep cannot resole to a physical file or module.

What this check does

The check scans the codebase for import statements and attempts to resolve each import request to a physical file or module. If an import cannot be successfully resolved (e.g., due to a missing file, incorrect path, or misconfigured alias), it is flagged as an unresolved import.

Why this is important

Unresolved imports are critical errors that directly impact the stability and usability of your application:

  • Broken Applications: Unresolved imports often result in runtime errors or build failures, as the required code is simply not available.
  • Dependency Integrity: They can signal issues with your package.json configuration, tsconfig.json aliases, or package.json imports/exports maps.
  • Bug in rev-dep itself: If you believe an import should be resolvable but is reported as unresolved, it may indicate a bug in rev-dep's parsing or resolution logic. Please report such cases to help improve the tool.

Configuration

Below is an example of how unresolvedImportsDetection fits within the rules array, demonstrating how to use various ignore options:

{
"configVersion": "1.0",
"rules": [
{
"path": ".",
"unresolvedImportsDetection": {
"enabled": true,
"ignoreFiles": ["**/*.test.ts"],
"ignoreImports": ["some-external-pkg/*"],
"ignore": {
"src/some/path/to/file.ts": ["import-specifier-to-ignore", "another-import-to-ignore"],
}
}
}
]
}

Options

  • enabled (boolean): Whether to enable unresolved imports detection.
  • ignoreFiles (array of strings): Glob patterns for files whose unresolved imports should be ignored.
  • ignoreImports (array of strings): Import requests (or globs) to ignore globally in unresolved imports results.
  • ignore (object): A map where the key is a file path glob (relative to the rule path) and the value is an import request glob (or string) to ignore for that specific file. Use this when an exception depends on both the file location and the import itself.

Also referred as

Unresolved or Broken Imports is also known as:

  • Broken imports
  • Unresolvable imports
  • Missing imports