Skip to content

Commit e62e746

Browse files
authored
docs: explain usage with defineConfig(); fixes #1729 (#1731)
1 parent 3663803 commit e62e746

4 files changed

Lines changed: 55 additions & 7 deletions

File tree

‎.README/README.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,27 @@ const config = [
130130
export default config;
131131
```
132132

133+
If you are using `defineConfig`, you can build as follows:
134+
135+
```js
136+
import jsdoc from 'eslint-plugin-jsdoc';
137+
import {defineConfig} from 'eslint/config';
138+
139+
export default defineConfig([
140+
{
141+
name: 'jsdoc-js', // Useful with `eslint --inspect-config`
142+
files: ['**/*.{js,mjs,cjs}'],
143+
plugins: {
144+
jsdoc
145+
},
146+
rules: {
147+
...jsdoc.configs['flat/recommended'].rules
148+
}
149+
}
150+
]);
151+
```
152+
153+
133154
The general starting rulesets you can extend from in flat config are:
134155

135156
- `jsdoc.configs['flat/recommended']`: Recommended starting rules for enforcing proper tag values, that common tags exist, and that tags are formatted and styled consistently

‎README.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,27 @@ const config = [
151151
export default config;
152152
```
153153

154+
If you are using `defineConfig`, you can build as follows:
155+
156+
```js
157+
import jsdoc from 'eslint-plugin-jsdoc';
158+
import {defineConfig} from 'eslint/config';
159+
160+
export default defineConfig([
161+
{
162+
name: 'jsdoc-js', // Useful with `eslint --inspect-config`
163+
files: ['**/*.{js,mjs,cjs}'],
164+
plugins: {
165+
jsdoc
166+
},
167+
rules: {
168+
...jsdoc.configs['flat/recommended'].rules
169+
}
170+
}
171+
]);
172+
```
173+
174+
154175
The general starting rulesets you can extend from in flat config are:
155176

156177
- `jsdoc.configs['flat/recommended']`: Recommended starting rules for enforcing proper tag values, that common tags exist, and that tags are formatted and styled consistently

‎eslint.config.js‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,32 @@ export default [
2121
ignores: [
2222
'coverage',
2323
'dist',
24+
'.ignore/**',
25+
'**/*.d.ts',
2426
],
27+
name: 'ignores',
2528
},
26-
...canonical,
29+
...canonical.map((cfg) => {
30+
return {
31+
name: 'canonical',
32+
...cfg,
33+
};
34+
}),
2735
// ...canonicalJsdoc,
2836
jsdoc({
2937
config: 'flat/recommended',
3038
}),
3139
...jsdoc({
3240
config: 'examples-and-default-expressions',
3341
}),
34-
{
35-
// Must be by itself
36-
ignores: [
37-
'dist/**', '.ignore/**', '**/*.d.ts',
38-
],
39-
},
4042
{
4143
...common,
4244
languageOptions: {
4345
ecmaVersion: 'latest',
4446
globals: globals.node,
4547
sourceType: 'module',
4648
},
49+
name: 'overrides',
4750
rules: {
4851
'@stylistic/array-element-newline': 0,
4952
'@stylistic/no-extra-parens': 0,
@@ -92,6 +95,7 @@ export default [
9295
},
9396
sourceType: 'script',
9497
},
98+
name: 'npm-check-updates',
9599
rules: {
96100
'canonical/filename-match-regex': 0,
97101
'import/no-commonjs': 0,
@@ -111,6 +115,7 @@ export default [
111115
globals: globals.mocha,
112116
sourceType: 'module',
113117
},
118+
name: 'jsdoc/testing',
114119
rules: {
115120
'no-restricted-syntax': 0,
116121
'unicorn/prevent-abbreviations': 0,

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@
171171
"create-rule": "node ./src/bin/generateRule.js",
172172
"create-options": "node ./src/bin/generateOptions.js",
173173
"install-offline": "CI=1 pnpm install --prefer-offline --no-frozen-lockfile",
174+
"inspect-config": "eslint --inspect-config",
174175
"lint": "eslint",
175176
"lint-fix": "eslint --fix",
176177
"prepare": "husky",

0 commit comments

Comments
 (0)