### Install eslint-import-resolver-typescript with eslint-plugin-import Source: https://github.com/import-js/eslint-import-resolver-typescript/blob/master/README.md Installs the necessary packages for using eslint-import-resolver-typescript with eslint-plugin-import across different package managers (npm, pnpm, yarn, bun). ```bash # 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 ``` -------------------------------- ### Install eslint-import-resolver-typescript with eslint-plugin-import-x Source: https://github.com/import-js/eslint-import-resolver-typescript/blob/master/README.md Installs the necessary packages for using eslint-import-resolver-typescript with eslint-plugin-import-x across different package managers (npm, pnpm, yarn, bun). ```bash # 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 .eslintrc Configuration Source: https://github.com/import-js/eslint-import-resolver-typescript/blob/master/README.md Configuration for the traditional `.eslintrc` file format. This setup involves specifying the plugin, enabling the `import/no-unresolved` rule, and configuring the `import/resolver` to use the `typescript` resolver with various options. ```jsonc { "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 `@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 /tsconfig.json or /jsconfig.json by default // Use /path/to/folder/tsconfig.json or /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", ], }, }, }, } ``` -------------------------------- ### ESLint Flat Config with import-x Source: https://github.com/import-js/eslint-import-resolver-typescript/blob/master/README.md Configuration for ESLint's flat config system using `eslint-plugin-import-x@>=4.5.0`. This allows direct import of the resolver and provides options like `alwaysTryTypes` and `bun` support, along with various ways to specify TypeScript/JavaScript project configurations. ```javascript // 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 `@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 /tsconfig.json or /jsconfig.json by default // Use /path/to/folder/tsconfig.json or /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', ], }), ], }, }, ] ``` -------------------------------- ### Default mainFields Source: https://github.com/import-js/eslint-import-resolver-typescript/blob/master/README.md Specifies the default package.json fields to check for the main entry point of a module. Includes fields like 'types', 'typings', 'fesm2020', 'module', and 'main'. ```json [ "types", "typings", "fesm2020", "fesm2015", "esm2020", "es2020", "module", "jsnext:main", "main", ] ``` -------------------------------- ### Default extensions Source: https://github.com/import-js/eslint-import-resolver-typescript/blob/master/README.md Defines the default file extensions that the resolver will look for when resolving module requests. Excludes extensions like '.mjs' and '.cjs' that require explicit usage. ```json [ ".ts", ".tsx", ".d.ts", ".js", ".jsx", ".json", ".node", ] ``` -------------------------------- ### Default extensionAlias Source: https://github.com/import-js/eslint-import-resolver-typescript/blob/master/README.md Provides default aliases for file extensions, mapping one extension to a list of other extensions to try. This helps in resolving modules with different extension types. ```json { ".js": [ ".ts", ".tsx", ".d.ts", ".js", ], ".ts": [".ts", ".d.ts", ".js"], ".jsx": [".tsx", ".d.ts", ".jsx"], ".tsx": [ ".tsx", ".d.ts", ".jsx", ".js", ], ".cjs": [".cts", ".d.cts", ".cjs"], ".cts": [".cts", ".d.cts", ".cjs"], ".mjs": [".mts", ".d.mts", ".mjs"], ".mts": [".mts", ".d.mts", ".mjs"], } ``` -------------------------------- ### ESLint Flat Config with import Source: https://github.com/import-js/eslint-import-resolver-typescript/blob/master/README.md Configuration for ESLint's flat config system when using `eslint-plugin-import` or older versions of `eslint-plugin-import-x`. This method uses a nested object structure for the resolver and supports the same options as the direct import method. ```javascript // eslint.config.js (CommonJS is also supported) export default [ { settings: { 'import/resolver': { typescript: { alwaysTryTypes: true, // Always try to resolve types under `@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 /tsconfig.json or /jsconfig.json by default // Use /path/to/folder/tsconfig.json or /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', ], }, }, }, }, ] ``` -------------------------------- ### Default conditionNames Source: https://github.com/import-js/eslint-import-resolver-typescript/blob/master/README.md Specifies the default condition names used for resolving module requests. Includes conditions like 'types', 'import', 'esm2020', 'es2015', 'require', 'node', and 'browser'. ```json [ "types", "import", "esm2020", "es2020", "es2015", "require", "node", "node-addons", "browser", "default", ] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.