12
12
[ ![ Code Style: Prettier] ( https://img.shields.io/badge/code_style-prettier-ff69b4.svg )] ( https://github.com/prettier/prettier )
13
13
[ ![ changesets] ( https://img.shields.io/badge/maintained%20with-changesets-176de3.svg )] ( https://github.com/changesets/changesets )
14
14
15
- 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. )
15
+ 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)
16
16
17
17
This means you can:
18
18
@@ -59,32 +59,32 @@ If you're facing some problems with rules `import/default` or `import/named` fro
59
59
### ` eslint-plugin-import-x `
60
60
61
61
``` sh
62
- # NPM
62
+ # npm
63
63
npm i -D eslint-plugin-import-x eslint-import-resolver-typescript
64
64
65
- # PNPM
65
+ # pnpm
66
66
pnpm i -D eslint-plugin-import-x eslint-import-resolver-typescript
67
67
68
- # Yarn
68
+ # yarn
69
69
yarn add -D eslint-plugin-import-x eslint-import-resolver-typescript
70
70
71
- # Bun
71
+ # bun
72
72
bun add -d eslint-plugin-import-x eslint-import-resolver-typescript
73
73
```
74
74
75
75
### ` eslint-plugin-import `
76
76
77
77
``` sh
78
- # NPM
78
+ # npm
79
79
npm i -D eslint-plugin-import eslint-import-resolver-typescript
80
80
81
- # PNPM
81
+ # pnpm
82
82
pnpm i -D eslint-plugin-import eslint-import-resolver-typescript
83
83
84
- # Yarn
84
+ # yarn
85
85
yarn add -D eslint-plugin-import eslint-import-resolver-typescript
86
86
87
- # Bun
87
+ # bun
88
88
bun add -d eslint-plugin-import eslint-import-resolver-typescript
89
89
```
90
90
@@ -95,35 +95,35 @@ bun add -d eslint-plugin-import eslint-import-resolver-typescript
95
95
If 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:
96
96
97
97
``` js
98
- // eslint.config.js (CommonJS is also supported. )
98
+ // eslint.config.js (CommonJS is also supported)
99
99
import { createTypeScriptImportResolver } from ' eslint-import-resolver-typescript'
100
100
101
101
export default [
102
102
{
103
103
settings: {
104
104
' import-x/resolver-next' : [
105
105
createTypeScriptImportResolver ({
106
- alwaysTryTypes: true , // Always try to resolve types under `<root>@types` directory even if it doesn't contain any source code, like `@types/unist`.
106
+ alwaysTryTypes: true , // Always try to resolve types under `<root>@types` directory even if it doesn't contain any source code, like `@types/unist`
107
107
108
- bun: true , // Resolve Bun modules (https://github.com/import-js/eslint-import-resolver-typescript#bun).
108
+ bun: true , // Resolve Bun modules (https://github.com/import-js/eslint-import-resolver-typescript#bun)
109
109
110
- // Choose from one of the "project" configs below or omit to use <root>/tsconfig.json or <root>/jsconfig.json by default.
110
+ // Choose from one of the "project" configs below or omit to use <root>/tsconfig.json or <root>/jsconfig.json by default
111
111
112
- // Use <root>/path/to/folder/tsconfig.json or <root>/path/to/folder/jsconfig.json,
112
+ // Use <root>/path/to/folder/tsconfig.json or <root>/path/to/folder/jsconfig.json
113
113
project: ' path/to/folder' ,
114
114
115
115
// Multiple tsconfigs/jsconfigs (Useful for monorepos, but discouraged in favor of `references` supported)
116
116
117
- // Use a glob pattern.
117
+ // Use a glob pattern
118
118
project: ' packages/*/{ts,js}config.json' ,
119
119
120
- // Use an array.
120
+ // Use an array
121
121
project: [
122
122
' packages/module-a/tsconfig.json' ,
123
123
' packages/module-b/jsconfig.json' ,
124
124
],
125
125
126
- // Use an array of glob patterns.
126
+ // Use an array of glob patterns
127
127
project: [
128
128
' packages/*/tsconfig.json' ,
129
129
' other-packages/*/jsconfig.json' ,
@@ -138,33 +138,33 @@ export default [
138
138
But if you are using ` eslint-plugin-import ` or the older version of ` eslint-plugin-import-x ` , you can't use ` require ` /` import ` :
139
139
140
140
``` js
141
- // eslint.config.js (CommonJS is also supported. )
141
+ // eslint.config.js (CommonJS is also supported)
142
142
export default [
143
143
{
144
144
settings: {
145
145
' import/resolver' : {
146
146
typescript: {
147
- alwaysTryTypes: true , // Always try to resolve types under `<root>@types` directory even if it doesn't contain any source code, like `@types/unist`.
147
+ alwaysTryTypes: true , // Always try to resolve types under `<root>@types` directory even if it doesn't contain any source code, like `@types/unist`
148
148
149
- bun: true , // Resolve Bun modules (https://github.com/import-js/eslint-import-resolver-typescript#bun).
149
+ bun: true , // Resolve Bun modules (https://github.com/import-js/eslint-import-resolver-typescript#bun)
150
150
151
- // Choose from one of the "project" configs below or omit to use <root>/tsconfig.json or <root>/jsconfig.json by default.
151
+ // Choose from one of the "project" configs below or omit to use <root>/tsconfig.json or <root>/jsconfig.json by default
152
152
153
- // Use <root>/path/to/folder/tsconfig.json or <root>/path/to/folder/jsconfig.json,
153
+ // Use <root>/path/to/folder/tsconfig.json or <root>/path/to/folder/jsconfig.json
154
154
project: ' path/to/folder' ,
155
155
156
156
// Multiple tsconfigs/jsconfigs (Useful for monorepos, but discouraged in favor of `references` supported)
157
157
158
- // Use a glob pattern,
158
+ // Use a glob pattern
159
159
project: ' packages/*/{ts,js}config.json' ,
160
160
161
- // Use an array,
161
+ // Use an array
162
162
project: [
163
163
' packages/module-a/tsconfig.json' ,
164
164
' packages/module-b/jsconfig.json' ,
165
165
],
166
166
167
- // Use an array of glob patterns,
167
+ // Use an array of glob patterns
168
168
project: [
169
169
' packages/*/tsconfig.json' ,
170
170
' other-packages/*/jsconfig.json' ,
@@ -184,7 +184,7 @@ Add the following to your `.eslintrc` config:
184
184
{
185
185
" plugins" : [" import" ],
186
186
" rules" : {
187
- // Turn on errors for missing imports.
187
+ // Turn on errors for missing imports
188
188
" import/no-unresolved" : " error" ,
189
189
},
190
190
" settings" : {
@@ -193,21 +193,21 @@ Add the following to your `.eslintrc` config:
193
193
},
194
194
" import/resolver" : {
195
195
" typescript" : {
196
- " alwaysTryTypes" : true , // Always try to resolve types under `<root>@types` directory even if it doesn't contain any source code, like `@types/unist`.
196
+ " alwaysTryTypes" : true , // Always try to resolve types under `<root>@types` directory even if it doesn't contain any source code, like `@types/unist`
197
197
198
- " bun" : true , // Resolve Bun modules (https://github.com/import-js/eslint-import-resolver-typescript#bun).
198
+ " bun" : true , // Resolve Bun modules (https://github.com/import-js/eslint-import-resolver-typescript#bun)
199
199
200
- // Choose from one of the "project" configs below or omit to use <root>/tsconfig.json or <root>/jsconfig.json by default.
200
+ // Choose from one of the "project" configs below or omit to use <root>/tsconfig.json or <root>/jsconfig.json by default
201
201
202
- // Use <root>/path/to/folder/tsconfig.json or <root>/path/to/folder/jsconfig.json.
202
+ // Use <root>/path/to/folder/tsconfig.json or <root>/path/to/folder/jsconfig.json
203
203
" project" : " path/to/folder" ,
204
204
205
205
// Multiple tsconfigs (Useful for monorepos, but discouraged in favor of `references` supported)
206
206
207
- // Use a glob pattern.
207
+ // Use a glob pattern
208
208
" project" : " packages/*/{ts,js}config.json" ,
209
209
210
- // Use an array.
210
+ // Use an array
211
211
" project" : [
212
212
" packages/module-a/tsconfig.json" ,
213
213
" packages/module-b/jsconfig.json" ,
@@ -266,7 +266,7 @@ Default:
266
266
267
267
``` jsonc
268
268
[
269
- // `.mts`, `.cts`, `.d.mts`, `.d.cts`, `.mjs`, `.cjs` are not included because `.cjs` and `.mjs` must be used explicitly.
269
+ // `.mts`, `.cts`, `.d.mts`, `.d.cts`, `.mjs`, `.cjs` are not included because `.cjs` and `.mjs` must be used explicitly
270
270
" .ts" ,
271
271
" .tsx" ,
272
272
" .d.ts" ,
@@ -285,7 +285,7 @@ Default:
285
285
{
286
286
" .js" : [
287
287
" .ts" ,
288
- // `.tsx` can also be compiled as `.js`.
288
+ // `.tsx` can also be compiled as `.js`
289
289
" .tsx" ,
290
290
" .d.ts" ,
291
291
" .js" ,
@@ -296,7 +296,7 @@ Default:
296
296
" .tsx" ,
297
297
" .d.ts" ,
298
298
" .jsx" ,
299
- // `.tsx` can also be compiled as `.js`.
299
+ // `.tsx` can also be compiled as `.js`
300
300
" .js" ,
301
301
],
302
302
" .cjs" : [" .cts" , " .d.cts" , " .cjs" ],
0 commit comments