@@ -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,72 @@ 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 [
57
+ ... jsdoc ({
58
+ config: ' flat/recommended' ,
59
+ })
60
+ ];
61
+ ```
62
+
63
+ Or with settings supplied:
64
+
65
+ ``` js
66
+ import jsdoc from ' eslint-plugin-jsdoc' ;
67
+
68
+ export default [
69
+ ... jsdoc ({
70
+ config: ' flat/recommended' ,
71
+ // Uncomment this if you wish your `settings` to overwrite the config's own settings;
72
+ // otherwise, the default behavior is to merge recursively
73
+ // mergeSettings: false,
74
+ settings: {
75
+ // Do not add a `jsdoc` child object here as you would for regular ESLint `settings`
76
+ structuredTags: {
77
+ see: {
78
+ name: ' namepath-referencing' ,
79
+ required: [
80
+ ' name' ,
81
+ ],
82
+ },
83
+ },
84
+ /*
85
+ // The above will be merged by default with the following tags (which are
86
+ // being allowed and requiring a type):
87
+ structuredTags: {
88
+ next: {
89
+ required: [
90
+ 'type',
91
+ ],
92
+ },
93
+ throws: {
94
+ required: [
95
+ 'type',
96
+ ],
97
+ },
98
+ yields: {
99
+ required: [
100
+ 'type',
101
+ ],
102
+ },
103
+ },
104
+ */
105
+ }
106
+ })
107
+ ];
108
+ ```
109
+
110
+ <a name =" user-content-eslint-plugin-jsdoc-configuration-flat-config-declarative " ></a >
111
+ <a name =" eslint-plugin-jsdoc-configuration-flat-config-declarative " ></a >
112
+ ### Flat config (declarative)
49
113
50
114
``` js
51
115
import jsdoc from ' eslint-plugin-jsdoc' ;
@@ -56,6 +120,7 @@ const config = [
56
120
// other configuration objects...
57
121
{
58
122
files: [' **/*.js' ],
123
+ // `plugins` here is not necessary if including the above config
59
124
plugins: {
60
125
jsdoc,
61
126
},
@@ -77,8 +142,8 @@ The general starting rulesets you can extend from in flat config are:
77
142
- ` 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
143
- ` jsdoc.configs['flat/recommended-typescript-flavor-error'] ` : The same, reporting with failing errors instead of mere warnings
79
144
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 >
145
+ <a name =" user-content-eslint-plugin-jsdoc-configuration-flat-config-declarative- granular-flat-configs " ></a >
146
+ <a name =" eslint-plugin-jsdoc-configuration-flat-config-declarative- granular-flat-configs " ></a >
82
147
#### Granular Flat Configs
83
148
84
149
There also exist several more granular, standalone TypeScript rulesets you can extend from.
@@ -94,7 +159,7 @@ These each only enable mostly or only rules from the recommended starting rules:
94
159
- ` jsdoc.configs['flat/logical-typescript-error'] ` : for TypeScript files, with reports set to error
95
160
- ` jsdoc.configs['flat/logical-typescript-flavor'] ` : for files using JavaScript syntax and JSDoc types, with reports set to warn
96
161
- ` 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
162
+ - ** Requirements** : rules that enforce tags exist or have or don't have types
98
163
- ` jsdoc.configs['flat/requirements-typescript'] ` : for TypeScript files, with reports set to warn
99
164
- ` jsdoc.configs['flat/requirements-typescript-error'] ` : for TypeScript files, with reports set to error
100
165
- ` jsdoc.configs['flat/requirements-typescript-flavor'] ` : for files using JavaScript syntax and JSDoc types, with reports set to warn
@@ -117,8 +182,8 @@ export default [
117
182
];
118
183
```
119
184
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 >
185
+ <a name =" user-content-eslint-plugin-jsdoc-configuration-flat-config-declarative- granular-flat-configs-why-certain-rules-were-excluded-from-the-granular-configs " ></a >
186
+ <a name =" eslint-plugin-jsdoc-configuration-flat-config-declarative- granular-flat-configs-why-certain-rules-were-excluded-from-the-granular-configs " ></a >
122
187
##### Why certain rules were excluded from the granular configs
123
188
124
189
A few rules were left out of the granular configs. Here is why:
0 commit comments