@@ -12,7 +12,8 @@ JSDoc linting rules for ESLint.
12
12
* [ eslint-plugin-jsdoc] ( #user-content-eslint-plugin-jsdoc )
13
13
* [ Installation] ( #user-content-eslint-plugin-jsdoc-installation )
14
14
* [ Configuration] ( #user-content-eslint-plugin-jsdoc-configuration )
15
- * [ Flat config] ( #user-content-eslint-plugin-jsdoc-configuration-flat-config )
15
+ * [ Flat config (procedural)] ( #user-content-eslint-plugin-jsdoc-configuration-flat-config-procedural )
16
+ * [ Flat config (declarative)] ( #user-content-eslint-plugin-jsdoc-configuration-flat-config-declarative )
16
17
* [ ` eslintrc ` ] ( #user-content-eslint-plugin-jsdoc-configuration-eslintrc )
17
18
* [ Options] ( #user-content-eslint-plugin-jsdoc-options )
18
19
* [ Settings] ( #user-content-eslint-plugin-jsdoc-settings )
@@ -43,9 +44,68 @@ npm install --save-dev eslint-plugin-jsdoc
43
44
<a name =" eslint-plugin-jsdoc-configuration " ></a >
44
45
## Configuration
45
46
46
- <a name =" user-content-eslint-plugin-jsdoc-configuration-flat-config " ></a >
47
- <a name =" eslint-plugin-jsdoc-configuration-flat-config " ></a >
48
- ### Flat config
47
+ <a name =" user-content-eslint-plugin-jsdoc-configuration-flat-config-procedural " ></a >
48
+ <a name =" eslint-plugin-jsdoc-configuration-flat-config-procedural " ></a >
49
+ ### Flat config (procedural)
50
+
51
+ This is the currently recommended approach.
52
+
53
+ ``` js
54
+ import jsdoc from ' eslint-plugin-jsdoc' ;
55
+
56
+ export default jsdoc ({
57
+ config: ' flat/recommended' ,
58
+ });
59
+ ```
60
+
61
+ Or with settings supplied:
62
+
63
+ ``` js
64
+ import jsdoc from ' eslint-plugin-jsdoc' ;
65
+
66
+ export default jsdoc ({
67
+ config: ' flat/recommended' ,
68
+ // Uncomment this if you wish your `settings` to overwrite the config's own settings;
69
+ // otherwise, the default behavior is to merge recursively
70
+ // mergeSettings: false,
71
+ settings: {
72
+ // Do not add a `jsdoc` child object here as you would for regular ESLint `settings`
73
+ structuredTags: {
74
+ see: {
75
+ name: ' namepath-referencing' ,
76
+ required: [
77
+ ' name' ,
78
+ ],
79
+ },
80
+ },
81
+ /*
82
+ // The above will be merged by default with the following tags (which are
83
+ // being allowed and requiring a type):
84
+ structuredTags: {
85
+ next: {
86
+ required: [
87
+ 'type',
88
+ ],
89
+ },
90
+ throws: {
91
+ required: [
92
+ 'type',
93
+ ],
94
+ },
95
+ yields: {
96
+ required: [
97
+ 'type',
98
+ ],
99
+ },
100
+ },
101
+ */
102
+ }
103
+ });
104
+ ```
105
+
106
+ <a name =" user-content-eslint-plugin-jsdoc-configuration-flat-config-declarative " ></a >
107
+ <a name =" eslint-plugin-jsdoc-configuration-flat-config-declarative " ></a >
108
+ ### Flat config (declarative)
49
109
50
110
``` js
51
111
import jsdoc from ' eslint-plugin-jsdoc' ;
@@ -56,6 +116,7 @@ const config = [
56
116
// other configuration objects...
57
117
{
58
118
files: [' **/*.js' ],
119
+ // `plugins` here is not necessary if including the above config
59
120
plugins: {
60
121
jsdoc,
61
122
},
@@ -77,8 +138,8 @@ The general starting rulesets you can extend from in flat config are:
77
138
- ` jsdoc.configs['flat/recommended-typescript-flavor'] ` : A similar recommended starting list, adjusted for projects using JavaScript syntax (source files that are still ` .js ` ) but using TypeScript flavor within JSDoc (i.e., the default "typescript" ` mode ` in ` eslint-plugin-jsdoc ` )
78
139
- ` jsdoc.configs['flat/recommended-typescript-flavor-error'] ` : The same, reporting with failing errors instead of mere warnings
79
140
80
- <a name =" user-content-eslint-plugin-jsdoc-configuration-flat-config-granular-flat-configs " ></a >
81
- <a name =" eslint-plugin-jsdoc-configuration-flat-config-granular-flat-configs " ></a >
141
+ <a name =" user-content-eslint-plugin-jsdoc-configuration-flat-config-declarative- granular-flat-configs " ></a >
142
+ <a name =" eslint-plugin-jsdoc-configuration-flat-config-declarative- granular-flat-configs " ></a >
82
143
#### Granular Flat Configs
83
144
84
145
There also exist several more granular, standalone TypeScript rulesets you can extend from.
@@ -94,7 +155,7 @@ These each only enable mostly or only rules from the recommended starting rules:
94
155
- ` jsdoc.configs['flat/logical-typescript-error'] ` : for TypeScript files, with reports set to error
95
156
- ` jsdoc.configs['flat/logical-typescript-flavor'] ` : for files using JavaScript syntax and JSDoc types, with reports set to warn
96
157
- ` jsdoc.configs['flat/logical-typescript-flavor-error'] ` : for files using JavaScript syntax and JSDoc types, with reports set to error
97
- - ** Requirements** : rules that enforce tags exist
158
+ - ** Requirements** : rules that enforce tags exist or have or don't have types
98
159
- ` jsdoc.configs['flat/requirements-typescript'] ` : for TypeScript files, with reports set to warn
99
160
- ` jsdoc.configs['flat/requirements-typescript-error'] ` : for TypeScript files, with reports set to error
100
161
- ` jsdoc.configs['flat/requirements-typescript-flavor'] ` : for files using JavaScript syntax and JSDoc types, with reports set to warn
@@ -117,8 +178,8 @@ export default [
117
178
];
118
179
```
119
180
120
- <a name =" user-content-eslint-plugin-jsdoc-configuration-flat-config-granular-flat-configs-why-certain-rules-were-excluded-from-the-granular-configs " ></a >
121
- <a name =" eslint-plugin-jsdoc-configuration-flat-config-granular-flat-configs-why-certain-rules-were-excluded-from-the-granular-configs " ></a >
181
+ <a name =" user-content-eslint-plugin-jsdoc-configuration-flat-config-declarative- granular-flat-configs-why-certain-rules-were-excluded-from-the-granular-configs " ></a >
182
+ <a name =" eslint-plugin-jsdoc-configuration-flat-config-declarative- granular-flat-configs-why-certain-rules-were-excluded-from-the-granular-configs " ></a >
122
183
##### Why certain rules were excluded from the granular configs
123
184
124
185
A few rules were left out of the granular configs. Here is why:
0 commit comments