@@ -119,6 +119,11 @@ All rules are off by default. However, you may extend one of the preset configs,
119
119
" eslint:recommended" ,
120
120
" plugin:import/recommended" ,
121
121
],
122
+ " rules" : {
123
+ " import/no-dynamic-require" : " warn" ,
124
+ " import/no-nodejs-modules" : " warn" ,
125
+ // etc...
126
+ }
122
127
}
123
128
```
124
129
@@ -139,7 +144,9 @@ All rules are off by default. However, you may extend one of the preset configs,
139
144
140
145
### Config - Flat (` eslint.config.js ` )
141
146
142
- All rules are off by default. However, you may configure them manually in your ` eslint.config.(js|cjs|mjs) ` , or extend one of the preset configs:
147
+ All rules are off by default. However, you may extend one of the preset configs, or configure them manually in your ` eslint.config.(js|cjs|mjs) ` .
148
+
149
+ - Extending a preset config:
143
150
144
151
``` js
145
152
import importPlugin from ' eslint-plugin-import' ;
@@ -150,17 +157,36 @@ export default [
150
157
importPlugin .flatConfigs .recommended ,
151
158
{
152
159
files: [' **/*.{js,mjs,cjs}' ],
153
- languageOptions: {
154
- ecmaVersion: ' latest' ,
155
- sourceType: ' module' ,
156
- },
157
160
rules: {
158
- ' no-unused-vars' : ' off' ,
159
161
' import/no-dynamic-require' : ' warn' ,
160
162
' import/no-nodejs-modules' : ' warn' ,
161
163
},
162
164
},
163
165
];
166
+ ```
167
+
168
+ - Configuring manually:
169
+
170
+ ``` js
171
+ import importPlugin from ' eslint-plugin-import' ;
172
+ import js from ' @eslint/js' ;
173
+
174
+ export default [
175
+ js .configs .recommended ,
176
+ {
177
+ files: [' **/*.{js,mjs,cjs}' ],
178
+ plugins: {
179
+ import: importPlugin,
180
+ },
181
+ rules: {
182
+ ' import/no-unresolved' : [' error' , { ' commonjs' : true , ' amd' : true }],
183
+ ' import/named' : ' error' ,
184
+ ' import/namespace' : ' error' ,
185
+ ' import/default' : ' error' ,
186
+ ' import/export' : ' error' ,
187
+ },
188
+ },
189
+ ];
164
190
```
165
191
166
192
## TypeScript
0 commit comments