This resolver adds `TypeScript` support to `eslint-plugin-import(-x)`
827
stars
347
commits
TypeScript
primary language
Jun 2, 2026
updated
This is a resolver for eslint-plugin-import(-x) plugin, not an ESLint plugin itself, it adds TypeScript support to eslint-plugin-import. (Or maybe you want to try eslint-plugin-import-x for faster speed)
This means you can:
import/require files with extension .cts/.mts/.ts/.tsx/.d.cts/.d.mts/.d.tspaths defined in tsconfig.json@types/* definitions over plain .js/.jsximports/exports fields support in package.jsonunrs-resolver
After version 2.0.0, .d.ts will take higher priority than normal .js/.jsx files on resolving node_modules packages in favor of @types/* definitions or its own definition.
If you're facing some problems with rules import/default or import/named from eslint-plugin-import, do not post any issue here, because they are working exactly as expected on our side. Take import-js/eslint-plugin-import#1525 as reference or post a new issue on eslint-plugin-import instead.
eslint-plugin-import-x# npm
npm i -D eslint-plugin-import-x eslint-import-resolver-typescript
# pnpm
pnpm i -D eslint-plugin-import-x eslint-import-resolver-typescript
# yarn
yarn add -D eslint-plugin-import-x eslint-import-resolver-typescript
# bun
bun add -d eslint-plugin-import-x eslint-import-resolver-typescript
eslint-plugin-import# npm
npm i -D eslint-plugin-import eslint-import-resolver-typescript
# pnpm
pnpm i -D eslint-plugin-import eslint-import-resolver-typescript
# yarn
yarn add -D eslint-plugin-import eslint-import-resolver-typescript
# bun
bun add -d eslint-plugin-import eslint-import-resolver-typescript
eslint.config.jsIf you are using eslint-plugin-import-x@>=4.5.0, you can use import/require to reference eslint-import-resolver-typescript directly in your ESLint flat config:
// eslint.config.js (CommonJS is also supported)
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'
export default [
{
settings: {
'import-x/resolver-next': [
createTypeScriptImportResolver({
alwaysTryTypes: true, // Always try to resolve types under `<root>@types` directory even if it doesn't contain any source code, like `@types/unist`
bun: true, // Resolve Bun modules (https://github.com/import-js/eslint-import-resolver-typescript#bun)
// Choose from one of the "project" configs below or omit to use <root>/tsconfig.json or <root>/jsconfig.json by default
// Use <root>/path/to/folder/tsconfig.json or <root>/path/to/folder/jsconfig.json
project: 'path/to/folder',
// Multiple tsconfigs/jsconfigs (Useful for monorepos, but discouraged in favor of `references` supported)
// Use a glob pattern
project: 'packages/*/{ts,js}config.json',
// Use an array
project: [
'packages/module-a/tsconfig.json',
'packages/module-b/jsconfig.json',
],
// Use an array of glob patterns
project: [
'packages/*/tsconfig.json',
'other-packages/*/jsconfig.json',
],
}),
],
},
},
]
But if you are using eslint-plugin-import or the older version of eslint-plugin-import-x, you can't use require/import:
// eslint.config.js (CommonJS is also supported)
export default [
{
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true, // Always try to resolve types under `<root>@types` directory even if it doesn't contain any source code, like `@types/unist`
bun: true, // Resolve Bun modules (https://github.com/import-js/eslint-import-resolver-typescript#bun)
// Choose from one of the "project" configs below or omit to use <root>/tsconfig.json or <root>/jsconfig.json by default
// Use <root>/path/to/folder/tsconfig.json or <root>/path/to/folder/jsconfig.json
project: 'path/to/folder',
// Multiple tsconfigs/jsconfigs (Useful for monorepos, but discouraged in favor of `references` supported)
// Use a glob pattern
project: 'packages/*/{ts,js}config.json',
// Use an array
project: [
'packages/module-a/tsconfig.json',
'packages/module-b/jsconfig.json',
],
// Use an array of glob patterns
project: [
'packages/*/tsconfig.json',
'other-packages/*/jsconfig.json',
],
},
},
},
},
]
.eslintrcAdd the following to your .eslintrc config:
{
"plugins": ["import"],
"rules": {
// Turn on errors for missing imports
"import/no-unresolved": "error",
},
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true, // Always try to resolve types under `<root>@types` directory even if it doesn't contain any source code, like `@types/unist`
"bun": true, // Resolve Bun modules (https://github.com/import-js/eslint-import-resolver-typescript#bun)
// Choose from one of the "project" configs below or omit to use <root>/tsconfig.json or <root>/jsconfig.json by default
// Use <root>/path/to/folder/tsconfig.json or <root>/path/to/folder/jsconfig.json
"project": "path/to/folder",
// Multiple tsconfigs (Useful for monorepos, but discouraged in favor of `references` supported)
// Use a glob pattern
"project": "packages/*/{ts,js}config.json",
// Use an array
"project": [
"packages/module-a/tsconfig.json",
"packages/module-b/jsconfig.json",
],
// Use an array of glob patterns
"project": [
"packages/*/tsconfig.json",
"other-packages/*/jsconfig.json",
],
},
},
},
}
Bun provides built-in modules such as bun:test, which are not resolved by default.
Enable Bun built-in module resolution by choosing 1 out of these 3 options:
bun: true option, as shown in Configuration above.bun --bun eslint.run.bun in bunfig.toml.unrs-resolverconditionNamesDefault:
[
"types",
"import",
// APF: https://angular.io/guide/angular-package-format
"esm2020",
"es2020",
"es2015",
"require",
"node",
"node-addons",
"browser",
"default",
]
extensionsDefault:
[
// `.mts`, `.cts`, `.d.mts`, `.d.cts`, `.mjs`, `.cjs` are not included because `.cjs` and `.mjs` must be used explicitly
".ts",
".tsx",
".d.ts",
".js",
".jsx",
".json",
".node",
]
extensionAliasDefault:
{
".js": [
".ts",
// `.tsx` can also be compiled as `.js`
".tsx",
".d.ts",
".js",
],
".ts": [".ts", ".d.ts", ".js"],
".jsx": [".tsx", ".d.ts", ".jsx"],
".tsx": [
".tsx",
".d.ts",
".jsx",
// `.tsx` can also be compiled as `.js`
".js",
],
".cjs": [".cts", ".d.cts", ".cjs"],
".cts": [".cts", ".d.cts", ".cjs"],
".mjs": [".mts", ".d.mts", ".mjs"],
".mts": [".mts", ".d.mts", ".mjs"],
}
mainFieldsDefault:
[
"types",
"typings",
// APF: https://angular.io/guide/angular-package-format
"fesm2020",
"fesm2015",
"esm2020",
"es2020",
"module",
"jsnext:main",
"main",
]
You can pass through other options of unrs-resolver directly.
You can reuse defaultConditionNames, defaultExtensions, defaultExtensionAlias, and defaultMainFields by directly using require/import.
yarn test passes without a failure.yarn lint passes without conflicts.yarn type-coverage.We have GitHub Actions, which will run the above commands on your PRs.
If either fails, we won't be able to merge your PR until it's fixed.
Detailed changes for each release are documented in CHANGELOG.md.
(top 30 of 44)
TypeScript
73.5%
JavaScript
26.5%
This resolver adds `TypeScript` support to `eslint-plugin-import(-x)`
827
stars
347
commits
TypeScript
primary language
Jun 2, 2026
updated
This is a resolver for eslint-plugin-import(-x) plugin, not an ESLint plugin itself, it adds TypeScript support to eslint-plugin-import. (Or maybe you want to try eslint-plugin-import-x for faster speed)
This means you can:
import/require files with extension .cts/.mts/.ts/.tsx/.d.cts/.d.mts/.d.tspaths defined in tsconfig.json@types/* definitions over plain .js/.jsximports/exports fields support in package.jsonunrs-resolver
After version 2.0.0, .d.ts will take higher priority than normal .js/.jsx files on resolving node_modules packages in favor of @types/* definitions or its own definition.
If you're facing some problems with rules import/default or import/named from eslint-plugin-import, do not post any issue here, because they are working exactly as expected on our side. Take import-js/eslint-plugin-import#1525 as reference or post a new issue on eslint-plugin-import instead.
eslint-plugin-import-x# npm
npm i -D eslint-plugin-import-x eslint-import-resolver-typescript
# pnpm
pnpm i -D eslint-plugin-import-x eslint-import-resolver-typescript
# yarn
yarn add -D eslint-plugin-import-x eslint-import-resolver-typescript
# bun
bun add -d eslint-plugin-import-x eslint-import-resolver-typescript
eslint-plugin-import# npm
npm i -D eslint-plugin-import eslint-import-resolver-typescript
# pnpm
pnpm i -D eslint-plugin-import eslint-import-resolver-typescript
# yarn
yarn add -D eslint-plugin-import eslint-import-resolver-typescript
# bun
bun add -d eslint-plugin-import eslint-import-resolver-typescript
eslint.config.jsIf you are using eslint-plugin-import-x@>=4.5.0, you can use import/require to reference eslint-import-resolver-typescript directly in your ESLint flat config:
// eslint.config.js (CommonJS is also supported)
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'
export default [
{
settings: {
'import-x/resolver-next': [
createTypeScriptImportResolver({
alwaysTryTypes: true, // Always try to resolve types under `<root>@types` directory even if it doesn't contain any source code, like `@types/unist`
bun: true, // Resolve Bun modules (https://github.com/import-js/eslint-import-resolver-typescript#bun)
// Choose from one of the "project" configs below or omit to use <root>/tsconfig.json or <root>/jsconfig.json by default
// Use <root>/path/to/folder/tsconfig.json or <root>/path/to/folder/jsconfig.json
project: 'path/to/folder',
// Multiple tsconfigs/jsconfigs (Useful for monorepos, but discouraged in favor of `references` supported)
// Use a glob pattern
project: 'packages/*/{ts,js}config.json',
// Use an array
project: [
'packages/module-a/tsconfig.json',
'packages/module-b/jsconfig.json',
],
// Use an array of glob patterns
project: [
'packages/*/tsconfig.json',
'other-packages/*/jsconfig.json',
],
}),
],
},
},
]
But if you are using eslint-plugin-import or the older version of eslint-plugin-import-x, you can't use require/import:
// eslint.config.js (CommonJS is also supported)
export default [
{
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true, // Always try to resolve types under `<root>@types` directory even if it doesn't contain any source code, like `@types/unist`
bun: true, // Resolve Bun modules (https://github.com/import-js/eslint-import-resolver-typescript#bun)
// Choose from one of the "project" configs below or omit to use <root>/tsconfig.json or <root>/jsconfig.json by default
// Use <root>/path/to/folder/tsconfig.json or <root>/path/to/folder/jsconfig.json
project: 'path/to/folder',
// Multiple tsconfigs/jsconfigs (Useful for monorepos, but discouraged in favor of `references` supported)
// Use a glob pattern
project: 'packages/*/{ts,js}config.json',
// Use an array
project: [
'packages/module-a/tsconfig.json',
'packages/module-b/jsconfig.json',
],
// Use an array of glob patterns
project: [
'packages/*/tsconfig.json',
'other-packages/*/jsconfig.json',
],
},
},
},
},
]
.eslintrcAdd the following to your .eslintrc config:
{
"plugins": ["import"],
"rules": {
// Turn on errors for missing imports
"import/no-unresolved": "error",
},
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true, // Always try to resolve types under `<root>@types` directory even if it doesn't contain any source code, like `@types/unist`
"bun": true, // Resolve Bun modules (https://github.com/import-js/eslint-import-resolver-typescript#bun)
// Choose from one of the "project" configs below or omit to use <root>/tsconfig.json or <root>/jsconfig.json by default
// Use <root>/path/to/folder/tsconfig.json or <root>/path/to/folder/jsconfig.json
"project": "path/to/folder",
// Multiple tsconfigs (Useful for monorepos, but discouraged in favor of `references` supported)
// Use a glob pattern
"project": "packages/*/{ts,js}config.json",
// Use an array
"project": [
"packages/module-a/tsconfig.json",
"packages/module-b/jsconfig.json",
],
// Use an array of glob patterns
"project": [
"packages/*/tsconfig.json",
"other-packages/*/jsconfig.json",
],
},
},
},
}
Bun provides built-in modules such as bun:test, which are not resolved by default.
Enable Bun built-in module resolution by choosing 1 out of these 3 options:
bun: true option, as shown in Configuration above.bun --bun eslint.run.bun in bunfig.toml.unrs-resolverconditionNamesDefault:
[
"types",
"import",
// APF: https://angular.io/guide/angular-package-format
"esm2020",
"es2020",
"es2015",
"require",
"node",
"node-addons",
"browser",
"default",
]
extensionsDefault:
[
// `.mts`, `.cts`, `.d.mts`, `.d.cts`, `.mjs`, `.cjs` are not included because `.cjs` and `.mjs` must be used explicitly
".ts",
".tsx",
".d.ts",
".js",
".jsx",
".json",
".node",
]
extensionAliasDefault:
{
".js": [
".ts",
// `.tsx` can also be compiled as `.js`
".tsx",
".d.ts",
".js",
],
".ts": [".ts", ".d.ts", ".js"],
".jsx": [".tsx", ".d.ts", ".jsx"],
".tsx": [
".tsx",
".d.ts",
".jsx",
// `.tsx` can also be compiled as `.js`
".js",
],
".cjs": [".cts", ".d.cts", ".cjs"],
".cts": [".cts", ".d.cts", ".cjs"],
".mjs": [".mts", ".d.mts", ".mjs"],
".mts": [".mts", ".d.mts", ".mjs"],
}
mainFieldsDefault:
[
"types",
"typings",
// APF: https://angular.io/guide/angular-package-format
"fesm2020",
"fesm2015",
"esm2020",
"es2020",
"module",
"jsnext:main",
"main",
]
You can pass through other options of unrs-resolver directly.
You can reuse defaultConditionNames, defaultExtensions, defaultExtensionAlias, and defaultMainFields by directly using require/import.
yarn test passes without a failure.yarn lint passes without conflicts.yarn type-coverage.We have GitHub Actions, which will run the above commands on your PRs.
If either fails, we won't be able to merge your PR until it's fixed.
Detailed changes for each release are documented in CHANGELOG.md.
(top 30 of 44)
TypeScript
73.5%
JavaScript
26.5%