{"id":13683707,"url":"https://github.com/import-js/eslint-import-resolver-typescript","last_synced_at":"2025-05-13T15:11:03.821Z","repository":{"id":25774884,"uuid":"104607703","full_name":"import-js/eslint-import-resolver-typescript","owner":"import-js","description":"This resolver adds `TypeScript` support to `eslint-plugin-import(-x)`","archived":false,"fork":false,"pushed_at":"2025-04-27T03:48:52.000Z","size":7419,"stargazers_count":783,"open_issues_count":10,"forks_count":69,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-08T22:55:01.103Z","etag":null,"topics":["eslint","eslint-import-plugin","eslint-import-resolver","eslint-plugin-import","typescript"],"latest_commit_sha":null,"homepage":"https://npm.im/eslint-import-resolver-typescript","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/import-js.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["import-js","ljharb"],"patreon":null,"open_collective":"eslint-plugin-import","ko_fi":null,"tidelift":"npm/eslint-plugin-import","community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2017-09-24T00:27:16.000Z","updated_at":"2025-05-08T07:56:29.000Z","dependencies_parsed_at":"2023-09-23T06:15:23.485Z","dependency_job_id":"8e76e6b0-d583-4c83-b522-ddfbae24309d","html_url":"https://github.com/import-js/eslint-import-resolver-typescript","commit_stats":{"total_commits":232,"total_committers":40,"mean_commits":5.8,"dds":0.5818965517241379,"last_synced_commit":"42e7cc3eb413dda56683c1b2b2483e4756e0bd62"},"previous_names":[],"tags_count":72,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/import-js%2Feslint-import-resolver-typescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/import-js%2Feslint-import-resolver-typescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/import-js%2Feslint-import-resolver-typescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/import-js%2Feslint-import-resolver-typescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/import-js","download_url":"https://codeload.github.com/import-js/eslint-import-resolver-typescript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253187130,"owners_count":21868067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eslint","eslint-import-plugin","eslint-import-resolver","eslint-plugin-import","typescript"],"created_at":"2024-08-02T13:02:25.171Z","updated_at":"2025-05-13T15:10:58.805Z","avatar_url":"https://github.com/import-js.png","language":"TypeScript","funding_links":["https://github.com/sponsors/import-js","https://github.com/sponsors/ljharb","https://opencollective.com/eslint-plugin-import","https://tidelift.com/funding/github/npm/eslint-plugin-import","https://github.com/sponsors/JounQin","https://opencollective.com/1stG","https://opencollective.com/rxts","https://opencollective.com/unts"],"categories":["TypeScript"],"sub_categories":[],"readme":"# eslint-import-resolver-typescript\n\n[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/import-js/eslint-import-resolver-typescript/ci.yml?branch=master)](https://github.com/import-js/eslint-import-resolver-typescript/actions/workflows/ci.yml?query=branch%3Amaster)\n[![type-coverage](https://img.shields.io/badge/dynamic/json.svg?label=type-coverage\u0026prefix=%E2%89%A5\u0026suffix=%\u0026query=$.typeCoverage.atLeast\u0026uri=https%3A%2F%2Fraw.githubusercontent.com%2Fimport-js%2Feslint-import-resolver-typescript%2Fmaster%2Fpackage.json)](https://github.com/plantain-00/type-coverage)\n[![npm](https://img.shields.io/npm/v/eslint-import-resolver-typescript.svg)](https://www.npmjs.com/package/eslint-import-resolver-typescript)\n[![GitHub Release](https://img.shields.io/github/release/import-js/eslint-import-resolver-typescript)](https://github.com/import-js/eslint-import-resolver-typescript/releases)\n\n[![Conventional Commits](https://img.shields.io/badge/conventional%20commits-1.0.0-yellow.svg)](https://conventionalcommits.org)\n[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![Code Style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![changesets](https://img.shields.io/badge/maintained%20with-changesets-176de3.svg)](https://github.com/changesets/changesets)\n\nThis 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)\n\nThis means you can:\n\n- `import`/`require` files with extension `.cts`/`.mts`/`.ts`/`.tsx`/`.d.cts`/`.d.mts`/`.d.ts`\n- Use [`paths`](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping) defined in `tsconfig.json`\n- Prefer resolving `@types/*` definitions over plain `.js`/`.jsx`\n- Multiple tsconfigs support just like normal\n- `imports/exports` fields support in `package.json`\n\n## TOC \u003c!-- omit in toc --\u003e\n\n- [Notice](#notice)\n- [Installation](#installation)\n  - [`eslint-plugin-import-x`](#eslint-plugin-import-x)\n  - [`eslint-plugin-import`](#eslint-plugin-import)\n- [Configuration](#configuration)\n  - [`eslint.config.js`](#eslintconfigjs)\n  - [`.eslintrc`](#eslintrc)\n  - [Other environments](#other-environments)\n    - [Bun](#bun)\n- [Options from `unrs-resolver`](#options-from-unrs-resolver)\n  - [`conditionNames`](#conditionnames)\n  - [`extensions`](#extensions)\n  - [`extensionAlias`](#extensionalias)\n  - [`mainFields`](#mainfields)\n  - [Other options](#other-options)\n  - [Default options](#default-options)\n- [Contributing](#contributing)\n- [Sponsors](#sponsors)\n- [Backers](#backers)\n- [Changelog](#changelog)\n- [License](#license)\n\n## Notice\n\nAfter version 2.0.0, `.d.ts` will take higher priority then normal `.js`/`.jsx` files on resolving `node_modules` packages in favor of `@types/*` definitions or its own definition.\n\nIf you're facing some problems on rules `import/default` or `import/named` from [`eslint-plugin-import`][], do not post any issue here, because they are just working exactly as [expected](https://github.com/import-js/eslint-import-resolver-typescript/issues/31#issuecomment-539751607) on our sides, take [import-js/eslint-plugin-import#1525](https://github.com/import-js/eslint-plugin-import/issues/1525) as reference or post a new issue to [`eslint-plugin-import`][] instead.\n\n## Installation\n\n### `eslint-plugin-import-x`\n\n```sh\n# npm\nnpm i -D eslint-plugin-import-x eslint-import-resolver-typescript\n\n# pnpm\npnpm i -D eslint-plugin-import-x eslint-import-resolver-typescript\n\n# yarn\nyarn add -D eslint-plugin-import-x eslint-import-resolver-typescript\n```\n\n### `eslint-plugin-import`\n\n```sh\n# npm\nnpm i -D eslint-plugin-import eslint-import-resolver-typescript\n\n# pnpm\npnpm i -D eslint-plugin-import eslint-import-resolver-typescript\n\n# yarn\nyarn add -D eslint-plugin-import eslint-import-resolver-typescript\n```\n\n## Configuration\n\n### `eslint.config.js`\n\nIf you are using `eslint-plugin-import-x@\u003e=4.5.0`, you can use import/require to reference `eslint-import-resolver-typescript` directly in your ESLint flat config:\n\n```js\n// eslint.config.js, CommonJS is also supported\nimport { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'\n\nexport default [\n  {\n    settings: {\n      'import-x/resolver-next': [\n        createTypeScriptImportResolver({\n          alwaysTryTypes: true, // always try to resolve types under `\u003croot\u003e@types` directory even it doesn't contain any source code, like `@types/unist`\n\n          bun: true, // resolve Bun modules https://github.com/import-js/eslint-import-resolver-typescript#bun\n\n          // Choose from one of the \"project\" configs below or omit to use \u003croot\u003e/tsconfig.json or \u003croot\u003e/jsconfig.json by default\n\n          // use \u003croot\u003e/path/to/folder/tsconfig.json or \u003croot\u003e/path/to/folder/jsconfig.json\n          project: 'path/to/folder',\n\n          // Multiple tsconfigs/jsconfigs (Useful for monorepos, but discouraged in favor of `references` supported)\n\n          // use a glob pattern\n          project: 'packages/*/{ts,js}config.json',\n\n          // use an array\n          project: [\n            'packages/module-a/tsconfig.json',\n            'packages/module-b/jsconfig.json',\n          ],\n\n          // use an array of glob patterns\n          project: [\n            'packages/*/tsconfig.json',\n            'other-packages/*/jsconfig.json',\n          ],\n        }),\n      ],\n    },\n  },\n]\n```\n\nBut if you are using `eslint-plugin-import` or the older version of `eslint-plugin-import-x`, you can't use require/import:\n\n```js\n// eslint.config.js, CommonJS is also supported\nexport default [\n  {\n    settings: {\n      'import/resolver': {\n        typescript: {\n          alwaysTryTypes: true, // always try to resolve types under `\u003croot\u003e@types` directory even it doesn't contain any source code, like `@types/unist`\n\n          bun: true, // resolve Bun modules https://github.com/import-js/eslint-import-resolver-typescript#bun\n\n          // Choose from one of the \"project\" configs below or omit to use \u003croot\u003e/tsconfig.json or \u003croot\u003e/jsconfig.json by default\n\n          // use \u003croot\u003e/path/to/folder/tsconfig.json or \u003croot\u003e/path/to/folder/jsconfig.json\n          project: 'path/to/folder',\n\n          // Multiple tsconfigs/jsconfigs (Useful for monorepos, but discouraged in favor of `references` supported)\n\n          // use a glob pattern\n          project: 'packages/*/{ts,js}config.json',\n\n          // use an array\n          project: [\n            'packages/module-a/tsconfig.json',\n            'packages/module-b/jsconfig.json',\n          ],\n\n          // use an array of glob patterns\n          project: [\n            'packages/*/tsconfig.json',\n            'other-packages/*/jsconfig.json',\n          ],\n        },\n      },\n    },\n  },\n]\n```\n\n### `.eslintrc`\n\nAdd the following to your `.eslintrc` config:\n\n```jsonc\n{\n  \"plugins\": [\"import\"],\n  \"rules\": {\n    // turn on errors for missing imports\n    \"import/no-unresolved\": \"error\",\n  },\n  \"settings\": {\n    \"import/parsers\": {\n      \"@typescript-eslint/parser\": [\".ts\", \".tsx\"],\n    },\n    \"import/resolver\": {\n      \"typescript\": {\n        \"alwaysTryTypes\": true, // always try to resolve types under `\u003croot\u003e@types` directory even it doesn't contain any source code, like `@types/unist`\n\n        \"bun\": true, // resolve Bun modules https://github.com/import-js/eslint-import-resolver-typescript#bun\n\n        // Choose from one of the \"project\" configs below or omit to use \u003croot\u003e/tsconfig.json or \u003croot\u003e/jsconfig.json by default\n\n        // use \u003croot\u003e/path/to/folder/tsconfig.json or \u003croot\u003e/path/to/folder/jsconfig.json\n        \"project\": \"path/to/folder\",\n\n        // Multiple tsconfigs (Useful for monorepos, but discouraged in favor of `references` supported)\n\n        // use a glob pattern\n        \"project\": \"packages/*/{ts,js}config.json\",\n\n        // use an array\n        \"project\": [\n          \"packages/module-a/tsconfig.json\",\n          \"packages/module-b/jsconfig.json\",\n        ],\n\n        // use an array of glob patterns\n        \"project\": [\n          \"packages/*/tsconfig.json\",\n          \"other-packages/*/jsconfig.json\",\n        ],\n      },\n    },\n  },\n}\n```\n\n### Other environments\n\n#### Bun\n\n[Bun](https://bun.sh/) provides built-in modules such as `bun:test`, which are not resolved by default.\n\nEnable Bun built-in module resolution by choosing 1 out of these 3 options:\n\n- Set the `bun: true` option, as shown in [Configuration](#configuration) above\n- Run ESLint with `bun --bun eslint`\n- [Configure `run.bun` in `bunfig.toml`](https://bun.sh/docs/runtime/bunfig#run-bun-auto-alias-node-to-bun)\n\n## Options from [`unrs-resolver`][]\n\n### `conditionNames`\n\nDefault:\n\n```jsonc\n[\n  \"types\",\n  \"import\",\n\n  // APF: https://angular.io/guide/angular-package-format\n  \"esm2020\",\n  \"es2020\",\n  \"es2015\",\n\n  \"require\",\n  \"node\",\n  \"node-addons\",\n  \"browser\",\n  \"default\",\n]\n```\n\n### `extensions`\n\nDefault:\n\n```jsonc\n[\n  // `.mts`, `.cts`, `.d.mts`, `.d.cts`, `.mjs`, `.cjs` are not included because `.cjs` and `.mjs` must be used explicitly\n  \".ts\",\n  \".tsx\",\n  \".d.ts\",\n  \".js\",\n  \".jsx\",\n  \".json\",\n  \".node\",\n]\n```\n\n### `extensionAlias`\n\nDefault:\n\n```jsonc\n{\n  \".js\": [\n    \".ts\",\n    // `.tsx` can also be compiled as `.js`\n    \".tsx\",\n    \".d.ts\",\n    \".js\",\n  ],\n  \".jsx\": [\".tsx\", \".d.ts\", \".jsx\"],\n  \".cjs\": [\".cts\", \".d.cts\", \".cjs\"],\n  \".mjs\": [\".mts\", \".d.mts\", \".mjs\"],\n}\n```\n\n### `mainFields`\n\nDefault:\n\n```jsonc\n[\n  \"types\",\n  \"typings\",\n\n  // APF: https://angular.io/guide/angular-package-format\n  \"fesm2020\",\n  \"fesm2015\",\n  \"esm2020\",\n  \"es2020\",\n\n  \"module\",\n  \"jsnext:main\",\n\n  \"main\",\n]\n```\n\n### Other options\n\nYou can pass through other options of [`unrs-resolver`][] directly\n\n### Default options\n\nYou can reuse `defaultConditionNames`, `defaultExtensions`, `defaultExtensionAlias` and `defaultMainFields` by `require/import` them directly\n\n## Contributing\n\n- Make sure your change is covered by a test import.\n- Make sure that `yarn test` passes without a failure.\n- Make sure that `yarn lint` passes without conflicts.\n- Make sure your code changes match our [type-coverage](https://github.com/plantain-00/type-coverage) settings: `yarn type-coverage`.\n\nWe have [GitHub Actions](https://github.com/import-js/eslint-import-resolver-typescript/actions) which will run the above commands on your PRs.\n\nIf either fails, we won't be able to merge your PR until it's fixed.\n\n[![Sponsors](https://raw.githubusercontent.com/1stG/static/master/sponsors.svg)](https://github.com/sponsors/JounQin)\n\n## Sponsors\n\n| 1stG                                                                                                                   | RxTS                                                                                                                   | UnTS                                                                                                                   |\n| ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |\n| [![1stG Open Collective sponsors](https://opencollective.com/1stG/organizations.svg)](https://opencollective.com/1stG) | [![RxTS Open Collective sponsors](https://opencollective.com/rxts/organizations.svg)](https://opencollective.com/rxts) | [![UnTS Open Collective sponsors](https://opencollective.com/unts/organizations.svg)](https://opencollective.com/unts) |\n\n## Backers\n\n| 1stG                                                                                                                | RxTS                                                                                                                | UnTS                                                                                                                |\n| ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |\n| [![1stG Open Collective backers](https://opencollective.com/1stG/individuals.svg)](https://opencollective.com/1stG) | [![RxTS Open Collective backers](https://opencollective.com/rxts/individuals.svg)](https://opencollective.com/rxts) | [![UnTS Open Collective backers](https://opencollective.com/unts/individuals.svg)](https://opencollective.com/unts) |\n\n## Changelog\n\nDetailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.md).\n\n## License\n\n[ISC][]\n\n[`eslint-plugin-import`]: https://github.com/import-js/eslint-plugin-import\n[`eslint-plugin-import-x`]: https://github.com/un-ts/eslint-plugin-import-x\n[`unrs-resolver`]: https://github.com/unrs/unrs-resolver\n[`typescript`]: https://www.typescriptlang.org\n[isc]: https://opensource.org/licenses/ISC\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimport-js%2Feslint-import-resolver-typescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimport-js%2Feslint-import-resolver-typescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimport-js%2Feslint-import-resolver-typescript/lists"}