1
- <a name =" user-content-require-param-description " ></a >
2
- <a name =" require-param-description " ></a >
3
- # <code >require-param-description </code >
1
+ <a name =" user-content-require-param-name " ></a >
2
+ <a name =" require-param-name " ></a >
3
+ # <code >require-param-name </code >
4
4
5
- * [ Options] ( #user-content-require-param-description-options )
6
- * [ ` setDefaultDestructuredRootDescription ` ] ( #user-content-require-param-description-options-setdefaultdestructuredrootdescription )
7
- * [ ` defaultDestructuredRootDescription ` ] ( #user-content-require-param-description-options-defaultdestructuredrootdescription )
8
- * [ ` contexts ` ] ( #user-content-require-param-description-options-contexts )
9
- * [ Context and settings] ( #user-content-require-param-description-context-and-settings )
10
- * [ Failing examples] ( #user-content-require-param-description-failing-examples )
11
- * [ Passing examples] ( #user-content-require-param-description-passing-examples )
5
+ * [ Options] ( #user-content-require-param-name-options )
6
+ * [ ` contexts ` ] ( #user-content-require-param-name-options-contexts )
7
+ * [ Context and settings] ( #user-content-require-param-name-context-and-settings )
8
+ * [ Failing examples] ( #user-content-require-param-name-failing-examples )
9
+ * [ Passing examples] ( #user-content-require-param-name-passing-examples )
12
10
13
11
14
- Requires that each ` @param ` tag has a ` description ` value .
12
+ Requires that all ` @param ` tags have names .
15
13
16
- Will exempt destructured roots and their children if
17
- ` settings.exemptDestructuredRootsFromChecks ` is set to ` true ` (e.g.,
18
- ` @param {object} props ` will be exempted from requiring a description given
19
- ` function someFunc ({child1, child2}) ` ).
14
+ > The ` @param ` tag requires you to specify the name of the parameter you are documenting. You can also include the parameter's type, enclosed in curly brackets, and a description of the parameter.
15
+ >
16
+ > [ JSDoc] ( https://jsdoc.app/tags-param.html#overview )
20
17
21
- <a name =" user-content-require-param-description -options " ></a >
22
- <a name =" require-param-description -options " ></a >
18
+ <a name =" user-content-require-param-name -options " ></a >
19
+ <a name =" require-param-name -options " ></a >
23
20
## Options
24
21
25
- <a name =" user-content-require-param-description-options-setdefaultdestructuredrootdescription " ></a >
26
- <a name =" require-param-description-options-setdefaultdestructuredrootdescription " ></a >
27
- ### <code >setDefaultDestructuredRootDescription</code >
28
-
29
- Whether to set a default destructured root description. For example, you may
30
- wish to avoid manually having to set the description for a ` @param `
31
- corresponding to a destructured root object as it should always be the same
32
- type of object. Uses ` defaultDestructuredRootDescription ` for the description
33
- string. Defaults to ` false ` .
34
-
35
- <a name =" user-content-require-param-description-options-defaultdestructuredrootdescription " ></a >
36
- <a name =" require-param-description-options-defaultdestructuredrootdescription " ></a >
37
- ### <code >defaultDestructuredRootDescription</code >
38
-
39
- The description string to set by default for destructured roots. Defaults to
40
- "The root object".
41
-
42
- <a name =" user-content-require-param-description-options-contexts " ></a >
43
- <a name =" require-param-description-options-contexts " ></a >
22
+ <a name =" user-content-require-param-name-options-contexts " ></a >
23
+ <a name =" require-param-name-options-contexts " ></a >
44
24
### <code >contexts</code >
45
25
46
26
Set this to an array of strings representing the AST context (or an object with
@@ -54,8 +34,8 @@ expression, i.e., `@callback` or `@function` (or its aliases `@func` or
54
34
See the [ "AST and Selectors"] ( #user-content-eslint-plugin-jsdoc-advanced-ast-and-selectors )
55
35
section of our README for more on the expected format.
56
36
57
- <a name =" user-content-require-param-description -context-and-settings " ></a >
58
- <a name =" require-param-description -context-and-settings " ></a >
37
+ <a name =" user-content-require-param-name -context-and-settings " ></a >
38
+ <a name =" require-param-name -context-and-settings " ></a >
59
39
## Context and settings
60
40
61
41
|||
@@ -64,55 +44,53 @@ section of our README for more on the expected format.
64
44
| Tags| ` param ` |
65
45
| Aliases| ` arg ` , ` argument ` |
66
46
| Recommended| true|
67
- | Options| ` setDefaultDestructuredRootDescription ` , ` defaultDestructuredRootDescription ` , ` contexts ` |
68
- | Settings| ` exemptDestructuredRootsFromChecks ` |
47
+ | Options| ` contexts ` |
69
48
70
- <a name =" user-content-require-param-description -failing-examples " ></a >
71
- <a name =" require-param-description -failing-examples " ></a >
49
+ <a name =" user-content-require-param-name -failing-examples " ></a >
50
+ <a name =" require-param-name -failing-examples " ></a >
72
51
## Failing examples
73
52
74
53
The following patterns are considered problems:
75
54
76
55
```` js
77
56
/**
78
- * @param foo
57
+ * @param
79
58
*/
80
59
function quux (foo ) {
81
60
82
61
}
83
- // Message: Missing JSDoc @param "foo" description .
62
+ // Message: There must be an identifier after @param type .
84
63
85
64
/**
86
- * @param foo
65
+ * @param {string}
87
66
*/
88
67
function quux (foo ) {
89
68
90
69
}
91
- // "jsdoc/require-param-description": ["error"|"warn", {"contexts":["any"]}]
92
- // Message: Missing JSDoc @param "foo" description.
70
+ // Message: There must be an identifier after @param tag.
93
71
94
72
/**
95
- * @function
96
- * @param foo
73
+ * @param {string}
97
74
*/
98
- // "jsdoc/require-param-description": ["error"|"warn", {"contexts":["any"]}]
99
- // Message: Missing JSDoc @param "foo" description.
75
+ function quux (foo ) {
76
+
77
+ }
78
+ // "jsdoc/require-param-name": ["error"|"warn", {"contexts":["any"]}]
79
+ // Message: There must be an identifier after @param tag.
100
80
101
81
/**
102
- * @callback
103
- * @param foo
82
+ * @function
83
+ * @param {string}
104
84
*/
105
- // "jsdoc/require-param-description ": ["error"|"warn", {"contexts":["any"]}]
106
- // Message: Missing JSDoc @param "foo" description .
85
+ // "jsdoc/require-param-name ": ["error"|"warn", {"contexts":["any"]}]
86
+ // Message: There must be an identifier after @param tag .
107
87
108
88
/**
109
- * @arg foo
89
+ * @callback
90
+ * @param {string}
110
91
*/
111
- function quux (foo ) {
112
-
113
- }
114
- // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
115
- // Message: Missing JSDoc @arg "foo" description.
92
+ // "jsdoc/require-param-name": ["error"|"warn", {"contexts":["any"]}]
93
+ // Message: There must be an identifier after @param tag.
116
94
117
95
/**
118
96
* @param foo
@@ -122,117 +100,64 @@ function quux (foo) {
122
100
}
123
101
// Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
124
102
// Message: Unexpected tag `@param`
125
-
126
- /**
127
- * @param foo
128
- */
129
- function quux (foo ) {
130
-
131
- }
132
- // "jsdoc/require-param-description": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag:not([name=props]))","context":"FunctionDeclaration"}]}]
133
- // Message: Missing JSDoc @param "foo" description.
134
-
135
- /**
136
- * @param {number} foo Foo description
137
- * @param {object} root
138
- * @param {boolean} baz Baz description
139
- */
140
- function quux (foo , {bar}, baz ) {
141
-
142
- }
143
- // "jsdoc/require-param-description": ["error"|"warn", {"setDefaultDestructuredRootDescription":true}]
144
- // Message: Missing root description for @param.
145
-
146
- /**
147
- * @param {number} foo Foo description
148
- * @param {object} root
149
- * @param {boolean} baz Baz description
150
- */
151
- function quux (foo , {bar}, baz ) {
152
-
153
- }
154
- // "jsdoc/require-param-description": ["error"|"warn", {"defaultDestructuredRootDescription":"Root description","setDefaultDestructuredRootDescription":true}]
155
- // Message: Missing root description for @param.
156
-
157
- /**
158
- * @param {number} foo Foo description
159
- * @param {object} root
160
- * @param {boolean} baz Baz description
161
- */
162
- function quux (foo , {bar}, baz ) {
163
-
164
- }
165
- // "jsdoc/require-param-description": ["error"|"warn", {"setDefaultDestructuredRootDescription":false}]
166
- // Message: Missing JSDoc @param "root" description.
167
103
````
168
104
169
105
170
106
171
- <a name =" user-content-require-param-description -passing-examples " ></a >
172
- <a name =" require-param-description -passing-examples " ></a >
107
+ <a name =" user-content-require-param-name -passing-examples " ></a >
108
+ <a name =" require-param-name -passing-examples " ></a >
173
109
## Passing examples
174
110
175
111
The following patterns are not considered problems:
176
112
177
113
```` js
178
114
/**
179
- *
115
+ * @param foo
180
116
*/
181
117
function quux (foo ) {
182
118
183
119
}
184
120
185
121
/**
186
- * @param foo Foo.
122
+ * @param foo
187
123
*/
188
124
function quux (foo ) {
189
125
190
126
}
127
+ // "jsdoc/require-param-name": ["error"|"warn", {"contexts":["any"]}]
191
128
192
129
/**
193
- * @param foo Foo.
130
+ * @param {string} foo
194
131
*/
195
132
function quux (foo ) {
196
133
197
134
}
198
- // "jsdoc/require-param-description": ["error"|"warn", {"contexts":["any"]}]
199
135
200
136
/**
201
137
* @function
202
- * @param foo
138
+ * @param
203
139
*/
204
140
205
141
/**
206
142
* @callback
207
- * @param foo
143
+ * @param
208
144
*/
209
145
210
146
/**
211
- * @param props
147
+ * @param {Function} [processor = data => data ] A function to run
212
148
*/
213
- function quux ( props ) {
214
-
149
+ function processData ( processor ) {
150
+ return processor (data)
215
151
}
216
- // "jsdoc/require-param-description": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag:not([name=props]))","context":"FunctionDeclaration"}]}]
217
-
218
- /**
219
- * @param {number} foo Foo description
220
- * @param {object} root
221
- * @param {boolean} baz Baz description
222
- */
223
- function quux (foo , {bar}, baz ) {
224
-
225
- }
226
- // Settings: {"jsdoc":{"exemptDestructuredRootsFromChecks":true}}
227
-
228
- /**
229
- * @param {number} foo Foo description
230
- * @param {object} root
231
- * @param {object} root.bar
232
- */
233
- function quux (foo , {bar: {baz}}) {
234
152
153
+ /** Example with multi-line param type.
154
+ *
155
+ * @param {function(
156
+ * number
157
+ * )} cb Callback.
158
+ */
159
+ function example (cb ) {
160
+ cb (42 );
235
161
}
236
- // Settings: {"jsdoc":{"exemptDestructuredRootsFromChecks":true}}
237
162
````
238
163
0 commit comments