eslint-import-context
raw JSON → 0.2.0 verified Sat Apr 25 auth: no javascript
A utility library providing context information for eslint-plugin-import-x, eliminating the need for extra arguments. Version 0.2.0 is the current stable release, actively maintained with frequent patches. It ships TypeScript types and relies on oxc-resolver as a peer dependency. Key differentiator: simplifies usage of eslint-plugin-import-x by wrapping resolver context.
Common errors
error Cannot find module 'oxc-resolver' ↓
cause Missing peer dependency after upgrading to v0.2.0.
fix
npm install oxc-resolver --save-dev
error TypeError: getTsconfigWithContext is not a function ↓
cause Incorrect import; likely using default import or wrong named export.
fix
import { getTsconfigWithContext } from 'eslint-import-context'
error Module not found: Can't resolve 'stable-hash' ↓
cause Using old peer dependency stable-hash with v0.1.8+.
fix
Update to stable-hash-x or downgrade to v0.1.7.
error Type error: Property 'NodeResolverOptions' does not exist on type... ↓
cause Using Typescript definitions older than v0.1.6.
fix
Update eslint-import-context to v0.1.6 or later.
Warnings
breaking v0.2.0 migrated from unrs-resolver to oxc-resolver. Ensure you have oxc-resolver as a peer dependency. ↓
fix npm install oxc-resolver or add to peerDependencies.
deprecated v0.1.8 replaced stable-hash with stable-hash-x. Update imports if manually using stable-hash. ↓
fix Use stable-hash-x instead.
gotcha v0.1.5 removed tslib dependency. If you depend on tslib for other reasons, ensure it's still installed. ↓
fix Install tslib separately if needed.
breaking v0.1.3 changed to CommonJS single entry type. May affect bundlers expecting ESM. ↓
fix Check bundler configuration for CommonJS compatibility.
gotcha Version 0.1.4 fixed missing peer dependencies; earlier versions required manual installation. ↓
fix Update to >=0.1.4 or manually add missing peer deps.
gotcha The package ships TypeScript types but may have incomplete types in early versions (e.g., v0.1.6 fixed NodeResolverOptions). ↓
fix Update to v0.1.6 or later for correct types.
Install
npm install eslint-import-context yarn add eslint-import-context pnpm add eslint-import-context Imports
- useRuleContext wrong
const { useRuleContext } = require('eslint-import-context')correctimport { useRuleContext } from 'eslint-import-context' - getTsconfigWithContext wrong
const getTsconfigWithContext = require('eslint-import-context').getTsconfigWithContextcorrectimport { getTsconfigWithContext } from 'eslint-import-context' - default wrong
import * as eslintImportContext from 'eslint-import-context'correctimport eslintImportContext from 'eslint-import-context'
Quickstart
import { useRuleContext, getTsconfigWithContext } from 'eslint-import-context';
// In an ESLint rule
const rule = {
create(context) {
const ruleContext = useRuleContext(context);
const tsconfig = getTsconfigWithContext(ruleContext);
return {};
}
};
export default rule;