@@ -107,8 +107,15 @@ This plugin intends to support linting of ES2015+ (ES6+) import/export syntax, a
107
107
npm install eslint-plugin-import-x --save-dev
108
108
```
109
109
110
- All rules are off by default. However, you may configure them manually
111
- in your ` .eslintrc.(yml|json|js) ` , or extend one of the canned configs:
110
+ ## Configuration (legacy: ` .eslintrc* ` )
111
+
112
+ > [ !TIP]
113
+ > If your eslint is ` >=8.23.0 ` , you're 100% ready to use the new config system.
114
+ > See dedicated section below.
115
+
116
+ > [ !NOTE]
117
+ > All rules are off by default. However, you may configure them manually
118
+ > in your ` .eslintrc.(yml|json|js) ` , or extend one of the canned configs:
112
119
113
120
``` yaml
114
121
---
@@ -132,11 +139,12 @@ rules:
132
139
# etc...
133
140
```
134
141
135
- ## TypeScript
142
+ ### TypeScript
136
143
137
144
You may use the following snippet or assemble your own config using the granular settings described below it.
138
145
139
- Make sure you have installed [ ` @typescript-eslint/parser ` ] and [ ` eslint-import-resolver-typescript ` ] which are used in the following configuration.
146
+ > [ !WARNING]
147
+ > Make sure you have installed [ ` @typescript-eslint/parser ` ] and [ ` eslint-import-resolver-typescript ` ] which are used in the following configuration.
140
148
141
149
``` yaml
142
150
extends :
@@ -155,6 +163,73 @@ settings:
155
163
[` @typescript-eslint/parser`]: https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser
156
164
[`eslint-import-resolver-typescript`] : https://github.com/import-js/eslint-import-resolver-typescript
157
165
166
+ # # Configuration (new: `eslint.config.js`)
167
+
168
+ From [`v8.21.0`](https://github.com/eslint/eslint/releases/tag/v8.21.0), ESLint announced a new config system.
169
+ In the new system, `.eslintrc*` is no longer used. `eslint.config.js` would be the default config file name.
170
+
171
+ <details>
172
+ <summary>JS example</summary>
173
+
174
+ ` ` ` js
175
+ import js from '@eslint/js'
176
+ import eslintPluginImportX from 'eslint-plugin-import-x'
177
+
178
+ export default [
179
+ js.configs.recommended,
180
+ eslintPluginImportX.flatConfigs.recommended,
181
+ ]
182
+ ` ` `
183
+
184
+ </details>
185
+
186
+ <details>
187
+ <summary>Typescript example</summary>
188
+
189
+ You have to install `eslint-import-resolver-typescript` :
190
+
191
+ ` ` ` shell
192
+ npm install eslint-import-resolver-typescript --save-dev
193
+ ` ` `
194
+
195
+ ` ` ` js
196
+ import js from '@eslint/js'
197
+ import eslintPluginImportX from 'eslint-plugin-import-x'
198
+ import tsParser from '@typescript-eslint/parser'
199
+
200
+ export default [
201
+ js.configs.recommended,
202
+ eslintPluginImportX.flatConfigs.recommended,
203
+ eslintPluginImportX.flatConfigs.typescript,
204
+ {
205
+ files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
206
+ languageOptions: {
207
+ parser: tsParser,
208
+ ecmaVersion: 'latest',
209
+ sourceType: 'module',
210
+ },
211
+ ignores: ['eslint.config.js'],
212
+ rules: {
213
+ 'no-unused-vars': 'off',
214
+ 'import/no-dynamic-require': 'warn',
215
+ 'import/no-nodejs-modules': 'warn',
216
+ },
217
+ settings: {
218
+ 'import-x/resolver': {
219
+ typescript: true,
220
+ },
221
+ },
222
+ },
223
+ ]
224
+ ` ` `
225
+
226
+ </details>
227
+
228
+ ---
229
+
230
+ > [!NOTE]
231
+ > A complete list of available configuration can be found in [config/flat folders](src/config/flat)
232
+
158
233
# # Resolvers
159
234
160
235
With the advent of module bundlers and the current state of modules and module
0 commit comments