Skip to content

Commit c7cf4b0

Browse files
committed
Update readme docs
1 parent 6cc837a commit c7cf4b0

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

README.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ All rules are off by default. However, you may extend one of the preset configs,
119119
"eslint:recommended",
120120
"plugin:import/recommended",
121121
],
122+
"rules": {
123+
"import/no-dynamic-require": "warn",
124+
"import/no-nodejs-modules": "warn",
125+
// etc...
126+
}
122127
}
123128
```
124129

@@ -139,7 +144,9 @@ All rules are off by default. However, you may extend one of the preset configs,
139144

140145
### Config - Flat (`eslint.config.js`)
141146

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:
143150

144151
```js
145152
import importPlugin from 'eslint-plugin-import';
@@ -150,17 +157,36 @@ export default [
150157
importPlugin.flatConfigs.recommended,
151158
{
152159
files: ['**/*.{js,mjs,cjs}'],
153-
languageOptions: {
154-
ecmaVersion: 'latest',
155-
sourceType: 'module',
156-
},
157160
rules: {
158-
'no-unused-vars': 'off',
159161
'import/no-dynamic-require': 'warn',
160162
'import/no-nodejs-modules': 'warn',
161163
},
162164
},
163165
];
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+
];
164190
```
165191

166192
## TypeScript

0 commit comments

Comments
 (0)