@@ -25,11 +25,11 @@ It started as a fork of [`eslint-plugin-import`] using [`get-tsconfig`] to repla
25
25
- [ Why] ( #why )
26
26
- [ Differences] ( #differences )
27
27
- [ Installation] ( #installation )
28
- - [ Configuration (legacy: ` .eslintrc* ` )] ( #configuration-legacy-eslintrc )
29
- - [ TypeScript] ( #typescript )
30
- - [ Configuration (new: ` eslint.config.js ` )] ( #configuration-new-eslintconfigjs )
28
+ - [ Configuration (new: ` eslint.config.* ` )] ( #configuration-new-eslintconfig )
31
29
- [ JS example] ( #js-example )
32
30
- [ Typescript example] ( #typescript-example )
31
+ - [ Configuration (legacy: ` .eslintrc* ` )] ( #configuration-legacy-eslintrc )
32
+ - [ TypeScript] ( #typescript )
33
33
- [ Rules] ( #rules )
34
34
- [ Helpful warnings] ( #helpful-warnings )
35
35
- [ Module systems] ( #module-systems )
@@ -90,18 +90,66 @@ The list could be longer in the future, but we don't want to make it too long he
90
90
npm install eslint-plugin-import-x --save-dev
91
91
```
92
92
93
+ ## Configuration (new: ` eslint.config.* ` )
94
+
95
+ From [ ` v8.21.0 ` ] ( https://github.com/eslint/eslint/releases/tag/v8.21.0 ) , ESLint announced a new config system.
96
+ In the new system, ` .eslintrc* ` is no longer used. ` eslint.config.* ` would be the default config file name.
97
+
98
+ ### JS example
99
+
100
+ ``` js
101
+ import js from ' @eslint/js'
102
+ import * as importX from ' eslint-plugin-import-x'
103
+
104
+ export default [js .configs .recommended , importX .flatConfigs .recommended ]
105
+ ```
106
+
107
+ ### Typescript example
108
+
109
+ You have to install ` eslint-import-resolver-typescript ` :
110
+
111
+ ``` sh
112
+ npm install eslint-import-resolver-typescript --save-dev
113
+ ```
114
+
115
+ ``` js
116
+ import js from ' @eslint/js'
117
+ import * as importX from ' eslint-plugin-import-x'
118
+ import tsParser from ' @typescript-eslint/parser'
119
+
120
+ export default [
121
+ js .configs .recommended ,
122
+ importX .flatConfigs .recommended ,
123
+ importX .flatConfigs .typescript ,
124
+ {
125
+ files: [' **/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}' ],
126
+ languageOptions: {
127
+ parser: tsParser,
128
+ ecmaVersion: ' latest' ,
129
+ sourceType: ' module' ,
130
+ },
131
+ rules: {
132
+ ' import-x/no-dynamic-require' : ' warn' ,
133
+ ' import-x/no-nodejs-modules' : ' warn' ,
134
+ },
135
+ },
136
+ ]
137
+ ```
138
+
139
+ > [ !NOTE]
140
+ > A complete list of available configuration can be found in [ config/flat folders] ( src/config/flat )
141
+
93
142
## Configuration (legacy: ` .eslintrc* ` )
94
143
95
144
> [ !TIP]
96
145
> If your eslint is ` >=8.23.0 ` , you're 100% ready to use the new config system.
97
- > See dedicated section below .
146
+ > See dedicated section above .
98
147
99
148
> [ !NOTE]
100
149
> All rules are off by default. However, you may configure them manually
101
150
> in your ` .eslintrc.(yml|json|js) ` , or extend one of the canned configs:
102
151
103
152
``` yaml
104
- ---
105
153
extends :
106
154
- eslint:recommended
107
155
- plugin:import-x/recommended
@@ -140,60 +188,8 @@ settings:
140
188
# You will also need to install and configure the TypeScript resolver
141
189
# See also https://github.com/import-js/eslint-import-resolver-typescript#configuration
142
190
typescript : true
143
- node : true
144
- ` ` `
145
-
146
- ## Configuration (new: ` eslint.config.js`)
147
-
148
- From [`v8.21.0`](https://github.com/eslint/eslint/releases/tag/v8.21.0), ESLint announced a new config system.
149
- In the new system, `.eslintrc*` is no longer used. `eslint.config.js` would be the default config file name.
150
-
151
- # ## JS example
152
-
153
- ` ` ` js
154
- import js from '@eslint/js'
155
- import * as pluginImportX from 'eslint-plugin-import-x'
156
-
157
- export default [js.configs.recommended, pluginImportX.flatConfigs.recommended]
158
191
` ` `
159
192
160
- # ## Typescript example
161
-
162
- You have to install `eslint-import-resolver-typescript` :
163
-
164
- ` ` ` shell
165
- npm install eslint-import-resolver-typescript --save-dev
166
- ` ` `
167
-
168
- ` ` ` js
169
- import js from '@eslint/js'
170
- import * as pluginImportX from 'eslint-plugin-import-x'
171
- import tsParser from '@typescript-eslint/parser'
172
-
173
- export default [
174
- js.configs.recommended,
175
- pluginImportX.flatConfigs.recommended,
176
- pluginImportX.flatConfigs.typescript,
177
- {
178
- files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
179
- ignores: ['eslint.config.js'],
180
- languageOptions: {
181
- parser: tsParser,
182
- ecmaVersion: 'latest',
183
- sourceType: 'module',
184
- },
185
- rules: {
186
- 'no-unused-vars': 'off',
187
- 'import-x/no-dynamic-require': 'warn',
188
- 'import-x/no-nodejs-modules': 'warn',
189
- },
190
- },
191
- ]
192
- ` ` `
193
-
194
- > [!NOTE]
195
- > A complete list of available configuration can be found in [config/flat folders](src/config/flat)
196
-
197
193
## Rules
198
194
199
195
<!-- begin auto-generated rules list -->
0 commit comments