You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This version has implemented the `eslint-plugin-import-x`'s v3 resolver interface. This allows you to use import/require to reference `eslint-import-resolver-typescript` directly in your ESLint flat config:
Note that this only works with `eslint-plugin-import-x@>=4.5.0`. You can't use `createTypeScriptImportResolver` with the older versions of `eslint-plugin-import-x` or any existing versions of `eslint-plugin-import`.
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:
68
+
69
+
```js
70
+
// eslint.config.js
71
+
const {
72
+
createTypeScriptImportResolver,
73
+
} =require('eslint-import-resolver-typescript')
74
+
75
+
module.exports= [{
76
+
settings: {
77
+
"import/resolver-next": [
78
+
createTypeScriptImportResolver({
79
+
alwaysTryTypes:true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
80
+
81
+
// Choose from one of the "project" configs below or omit to use <root>/tsconfig.json by default
82
+
83
+
// use <root>/path/to/folder/tsconfig.json
84
+
project:"path/to/folder",
85
+
86
+
// Multiple tsconfigs (Useful for monorepos)
87
+
88
+
// use a glob pattern
89
+
project:"packages/*/tsconfig.json",
90
+
91
+
// use an array
92
+
project: [
93
+
"packages/module-a/tsconfig.json",
94
+
"packages/module-b/tsconfig.json"
95
+
],
96
+
97
+
// use an array of glob patterns
98
+
project: [
99
+
"packages/*/tsconfig.json",
100
+
"other-packages/*/tsconfig.json"
101
+
]
102
+
}),
103
+
];
104
+
}
105
+
}]
106
+
```
107
+
108
+
But if you are using `eslint-plugin-import` or the older version of `eslint-plugin-import-x`, you can't use require/import:
109
+
110
+
```js
111
+
// eslint.config.js
112
+
module.exports= [
113
+
{
114
+
settings: {
115
+
'import/resolvers': {
116
+
typescript: {
117
+
alwaysTryTypes:true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
118
+
119
+
// Choose from one of the "project" configs below or omit to use <root>/tsconfig.json by default
0 commit comments