Skip to content

Commit ee005b6

Browse files
raisulchowdhuryljharb
authored andcommitted
[Docs] show bare plugin flat config usage
Add flat-config examples for enabling selected import rules without a preset, including a TypeScript parser and resolver setup. Assisted-by: OpenAI Codex Signed-off-by: raisulchowdhury <34920788+raisulchowdhury@users.noreply.github.com>
1 parent a0a9e16 commit ee005b6

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
3232
- [Docs] `no-unused-modules`: Fix docs of `ignoreUnusedTypeExports` option ([#3233], thanks [@ej612])
3333
- [actions] update `codecov/codecov-action` to v7, for reliable tokenless coverage uploads from fork PRs ([#3262], thanks [@captaindonald])
3434
- [Docs] clarify flat config file scoping ([#3283], thanks [@raisulchowdhury])
35+
- [Docs] show bare plugin flat config usage ([#3284], thanks [@raisulchowdhury])
3536

3637
## [2.32.0] - 2025-06-20
3738

@@ -1208,6 +1209,7 @@ for info on changes for earlier releases.
12081209

12091210
[`memo-parser`]: ./memo-parser/README.md
12101211

1212+
[#3284]: https://github.com/import-js/eslint-plugin-import/pull/3284
12111213
[#3283]: https://github.com/import-js/eslint-plugin-import/pull/3283
12121214
[#3262]: https://github.com/import-js/eslint-plugin-import/pull/3262
12131215
[#3250]: https://github.com/import-js/eslint-plugin-import/pull/3250

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,24 @@ export default [
161161
},
162162
},
163163
];
164+
```
165+
166+
- Configuring rules without a preset:
167+
168+
```js
169+
import importPlugin from 'eslint-plugin-import';
170+
171+
export default [
172+
{
173+
files: ['**/*.{js,mjs,cjs,jsx,mjsx}'],
174+
plugins: {
175+
import: importPlugin,
176+
},
177+
rules: {
178+
'import/no-cycle': 'warn',
179+
},
180+
},
181+
];
164182
```
165183

166184
## TypeScript
@@ -191,6 +209,34 @@ Make sure you have installed [`@typescript-eslint/parser`] and [`eslint-import-r
191209
[`@typescript-eslint/parser`]: https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser
192210
[`eslint-import-resolver-typescript`]: https://github.com/import-js/eslint-import-resolver-typescript
193211

212+
### Config - Flat
213+
214+
```js
215+
import importPlugin from 'eslint-plugin-import';
216+
import tsParser from '@typescript-eslint/parser';
217+
218+
export default [
219+
{
220+
files: ['**/*.{ts,tsx}'],
221+
languageOptions: {
222+
parser: tsParser,
223+
},
224+
plugins: {
225+
import: importPlugin,
226+
},
227+
settings: {
228+
'import/resolver': {
229+
typescript: true,
230+
node: true,
231+
},
232+
},
233+
rules: {
234+
'import/no-unresolved': 'error',
235+
},
236+
},
237+
];
238+
```
239+
194240
### Config - Flat with `config()` in `typescript-eslint`
195241

196242
If you are using the `config` method from [`typescript-eslint`](https://github.com/typescript-eslint/typescript-eslint), ensure that the `flatConfig` is included within the `extends` array.

0 commit comments

Comments
 (0)