eslint-plugin-jsdoc 46.4.5 → 46.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +31 -0
  2. package/dist/alignTransform.js +5 -5
  3. package/dist/alignTransform.js.map +1 -1
  4. package/dist/index.js +21 -10
  5. package/dist/index.js.map +1 -1
  6. package/dist/iterateJsdoc.js +1 -1
  7. package/dist/iterateJsdoc.js.map +1 -1
  8. package/dist/rules/checkExamples.js +12 -6
  9. package/dist/rules/checkExamples.js.map +1 -1
  10. package/package.json +19 -15
  11. package/docs/advanced.md +0 -102
  12. package/docs/rules/check-access.md +0 -193
  13. package/docs/rules/check-alignment.md +0 -169
  14. package/docs/rules/check-examples.md +0 -784
  15. package/docs/rules/check-indentation.md +0 -296
  16. package/docs/rules/check-line-alignment.md +0 -1002
  17. package/docs/rules/check-param-names.md +0 -1035
  18. package/docs/rules/check-property-names.md +0 -244
  19. package/docs/rules/check-syntax.md +0 -80
  20. package/docs/rules/check-tag-names.md +0 -1132
  21. package/docs/rules/check-types.md +0 -1198
  22. package/docs/rules/check-values.md +0 -409
  23. package/docs/rules/empty-tags.md +0 -220
  24. package/docs/rules/implements-on-classes.md +0 -219
  25. package/docs/rules/imports-as-dependencies.md +0 -99
  26. package/docs/rules/informative-docs.md +0 -400
  27. package/docs/rules/match-description.md +0 -1008
  28. package/docs/rules/match-name.md +0 -249
  29. package/docs/rules/multiline-blocks.md +0 -398
  30. package/docs/rules/no-bad-blocks.md +0 -174
  31. package/docs/rules/no-blank-block-descriptions.md +0 -91
  32. package/docs/rules/no-blank-blocks.md +0 -98
  33. package/docs/rules/no-defaults.md +0 -207
  34. package/docs/rules/no-missing-syntax.md +0 -275
  35. package/docs/rules/no-multi-asterisks.md +0 -278
  36. package/docs/rules/no-restricted-syntax.md +0 -383
  37. package/docs/rules/no-types.md +0 -168
  38. package/docs/rules/no-undefined-types.md +0 -789
  39. package/docs/rules/require-asterisk-prefix.md +0 -297
  40. package/docs/rules/require-description-complete-sentence.md +0 -820
  41. package/docs/rules/require-description.md +0 -585
  42. package/docs/rules/require-example.md +0 -390
  43. package/docs/rules/require-file-overview.md +0 -324
  44. package/docs/rules/require-hyphen-before-param-description.md +0 -281
  45. package/docs/rules/require-jsdoc.md +0 -1857
  46. package/docs/rules/require-param-description.md +0 -238
  47. package/docs/rules/require-param-name.md +0 -163
  48. package/docs/rules/require-param-type.md +0 -227
  49. package/docs/rules/require-param.md +0 -1820
  50. package/docs/rules/require-property-description.md +0 -88
  51. package/docs/rules/require-property-name.md +0 -79
  52. package/docs/rules/require-property-type.md +0 -79
  53. package/docs/rules/require-property.md +0 -128
  54. package/docs/rules/require-returns-check.md +0 -1053
  55. package/docs/rules/require-returns-description.md +0 -181
  56. package/docs/rules/require-returns-type.md +0 -144
  57. package/docs/rules/require-returns.md +0 -1191
  58. package/docs/rules/require-throws.md +0 -326
  59. package/docs/rules/require-yields-check.md +0 -544
  60. package/docs/rules/require-yields.md +0 -823
  61. package/docs/rules/sort-tags.md +0 -635
  62. package/docs/rules/tag-lines.md +0 -551
  63. package/docs/rules/text-escaping.md +0 -177
  64. package/docs/rules/valid-types.md +0 -881
  65. package/docs/settings.md +0 -362
  66. package/tsconfig.json +0 -22
@@ -1,383 +0,0 @@
1
- <a name="user-content-no-restricted-syntax"></a>
2
- <a name="no-restricted-syntax"></a>
3
- # <code>no-restricted-syntax</code>
4
-
5
- * [Options](#user-content-no-restricted-syntax-options)
6
- * [`contexts`](#user-content-no-restricted-syntax-options-contexts)
7
- * [Context and settings](#user-content-no-restricted-syntax-context-and-settings)
8
- * [Failing examples](#user-content-no-restricted-syntax-failing-examples)
9
- * [Passing examples](#user-content-no-restricted-syntax-passing-examples)
10
-
11
-
12
- Reports when certain comment structures are present.
13
-
14
- Note that this rule differs from ESLint's [no-restricted-syntax](https://eslint.org/docs/rules/no-restricted-syntax)
15
- rule in expecting values within a single options object's
16
- `contexts` property, and with the property `context` being used in place of
17
- `selector` (as well as allowing for `comment`). The format also differs from
18
- the format expected by [`eslint-plugin-query`](https://github.com/brettz9/eslint-plugin-query).
19
-
20
- Unlike those rules, this is specific to finding comments attached to
21
- structures, (whether or not you add a specific `comment` condition).
22
-
23
- Note that if your parser supports comment AST (as [jsdoc-eslint-parser](https://github.com/brettz9/jsdoc-eslint-parser)
24
- is designed to do), you can just use ESLint's rule.
25
-
26
- <a name="user-content-no-restricted-syntax-options"></a>
27
- <a name="no-restricted-syntax-options"></a>
28
- ## Options
29
-
30
- <a name="user-content-no-restricted-syntax-options-contexts"></a>
31
- <a name="no-restricted-syntax-options-contexts"></a>
32
- ### <code>contexts</code>
33
-
34
- Set this to an array of strings representing the AST context (or an object with
35
- `context` and `comment` properties) where you wish the rule to be applied.
36
-
37
- Use the `message` property to indicate the specific error to be shown when an
38
- error is reported for that context being found.
39
-
40
- Set to `"any"` if you want the rule to apply to any jsdoc block throughout
41
- your files (as is necessary for finding function blocks not attached to a
42
- function declaration or expression, i.e., `@callback` or `@function` (or its
43
- aliases `@func` or `@method`) (including those associated with an `@interface`).
44
-
45
- See the ["AST and Selectors"](#user-content-eslint-plugin-jsdoc-advanced-ast-and-selectors)
46
- section of our README for more on the expected format.
47
-
48
- <a name="user-content-no-restricted-syntax-context-and-settings"></a>
49
- <a name="no-restricted-syntax-context-and-settings"></a>
50
- ## Context and settings
51
-
52
- |||
53
- |---|---|
54
- |Context|None except those indicated by `contexts`|
55
- |Tags|Any if indicated by AST|
56
- |Recommended|false|
57
- |Options|`contexts`|
58
-
59
- <a name="user-content-no-restricted-syntax-failing-examples"></a>
60
- <a name="no-restricted-syntax-failing-examples"></a>
61
- ## Failing examples
62
-
63
- The following patterns are considered problems:
64
-
65
- ````js
66
- /**
67
- *
68
- */
69
- function quux () {
70
-
71
- }
72
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":["FunctionDeclaration"]}]
73
- // Message: Syntax is restricted: FunctionDeclaration
74
-
75
- /**
76
- *
77
- */
78
- function quux () {
79
-
80
- }
81
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"context":"FunctionDeclaration","message":"Oops: `{{context}}`."}]}]
82
- // Message: Oops: `FunctionDeclaration`.
83
-
84
- /**
85
- * @implements {Bar|Foo}
86
- */
87
- function quux () {
88
-
89
- }
90
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Bar\"]:nth-child(1))","context":"FunctionDeclaration"}]}]
91
- // Message: Syntax is restricted: FunctionDeclaration with JsdocBlock[postDelimiter=""]:has(JsdocTypeUnion > JsdocTypeName[value="Bar"]:nth-child(1))
92
-
93
- /**
94
- * @implements {Bar|Foo}
95
- */
96
- function quux () {
97
-
98
- }
99
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Foo\"]:nth-child(1))","context":"FunctionDeclaration","message":"The foo one: {{context}}."},{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Bar\"]:nth-child(1))","context":"FunctionDeclaration","message":"The bar one: {{context}}."}]}]
100
- // Message: The bar one: FunctionDeclaration.
101
-
102
- /**
103
- * @implements {Bar|Foo}
104
- */
105
- function quux () {
106
-
107
- }
108
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Bar\"]:nth-child(1))","context":"FunctionDeclaration","message":"The bar one: {{context}}."},{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Foo\"]:nth-child(1))","context":"FunctionDeclaration","message":"The foo one: {{context}}."}]}]
109
- // Message: The bar one: FunctionDeclaration.
110
-
111
- /**
112
- * @implements {Bar|Foo}
113
- */
114
- function quux () {
115
-
116
- }
117
- // Message: Rule `no-restricted-syntax` is missing a `contexts` option.
118
-
119
- /**
120
- * @implements {Bar|Foo}
121
- */
122
- function quux () {
123
-
124
- }
125
- // Settings: {"jsdoc":{"contexts":["FunctionDeclaration"]}}
126
- // Message: Rule `no-restricted-syntax` is missing a `contexts` option.
127
-
128
- /**
129
- * @param opt_a
130
- * @param opt_b
131
- */
132
- function a () {}
133
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","context":"FunctionDeclaration","message":"Only allowing names not matching `/^opt_/i`."}]}]
134
- // Message: Only allowing names not matching `/^opt_/i`.
135
-
136
- /**
137
- * @param opt_a
138
- * @param opt_b
139
- */
140
- function a () {}
141
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","context":"any","message":"Only allowing names not matching `/^opt_/i`."}]}]
142
- // Message: Only allowing names not matching `/^opt_/i`.
143
-
144
- /**
145
- * @param opt_a
146
- * @param opt_b
147
- */
148
- function a () {}
149
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","message":"Only allowing names not matching `/^opt_/i`."}]}]
150
- // Message: Only allowing names not matching `/^opt_/i`.
151
-
152
- /**
153
- * @param opt_a
154
- * @param opt_b
155
- */
156
- function a () {}
157
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/not-this/])","context":"any","message":"Only allowing names not matching `/^not-this/i`."},{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","context":"any","message":"Only allowing names not matching `/^opt_/i`."}]}]
158
- // Message: Only allowing names not matching `/^opt_/i`.
159
-
160
- /**
161
- * @param opt_a
162
- * @param opt_b
163
- */
164
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","context":"any","message":"Only allowing names not matching `/^opt_/i`."}]}]
165
- // Message: Only allowing names not matching `/^opt_/i`.
166
-
167
- /**
168
- * @enum {String}
169
- * Object holding values of some custom enum
170
- */
171
- const MY_ENUM = Object.freeze({
172
- VAL_A: "myvala"
173
- } as const);
174
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTag ~ JsdocTag[tag=/private|protected/])","context":"any","message":"Access modifier tags must come first"},{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTag[tag=\"enum\"])","context":":declaration","message":"@enum not allowed on declarations"}]}]
175
- // Message: @enum not allowed on declarations
176
-
177
- /** @type {React.FunctionComponent<{ children: React.ReactNode }>}*/
178
- const MyComponent = ({ children }) => {
179
- return children;
180
- }
181
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[tag=\"type\"]:has([value=/FunctionComponent/]))","context":"any","message":"The `FunctionComponent` type is not allowed. Please use `FC` instead."}]}]
182
- // Message: The `FunctionComponent` type is not allowed. Please use `FC` instead.
183
-
184
- /** Some text and more */
185
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[descriptionStartLine=0][descriptionEndLine=0]","context":"any","message":"Requiring descriptive text on 0th line only"}]}]
186
- // Message: Requiring descriptive text on 0th line only
187
-
188
- /** Some text and
189
- * more
190
- */
191
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[descriptionStartLine=0][hasPreterminalDescription=0]","context":"any","message":"Requiring descriptive text on 0th line and no preterminal description"}]}]
192
- // Message: Requiring descriptive text on 0th line and no preterminal description
193
-
194
- /** Some text
195
- * @param sth Param text followed by no newline */
196
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[descriptionStartLine=0][hasPreterminalTagDescription=1]","context":"any","message":"Requiring descriptive text on 0th line but no preterminal description"}]}]
197
- // Message: Requiring descriptive text on 0th line but no preterminal description
198
-
199
- /**
200
- *
201
- */
202
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(*:has(JsdocTag[tag=see]))","context":"any","message":"@see required on each block"}]}]
203
- // Message: @see required on each block
204
-
205
- /**
206
- * @type {{a: string}}
207
- */
208
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[tag=type][parsedType.type!=JsdocTypeStringValue][parsedType.type!=JsdocTypeNumber][parsedType.type!=JsdocTypeName])","context":"any","message":"@type should be limited to numeric or string literals and names"},{"comment":"JsdocBlock:has(JsdocTag[tag=type][parsedType.type=JsdocTypeName]:not(*[parsedType.value=/^(true|false|null|undefined|boolean|number|string)$/]))","context":"any","message":"@type names should only be recognized primitive types or literals"}]}]
209
- // Message: @type should be limited to numeric or string literals and names
210
-
211
- /**
212
- * @type {abc}
213
- */
214
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[tag=type][parsedType.type!=JsdocTypeStringValue][parsedType.type!=JsdocTypeNumber][parsedType.type!=JsdocTypeName])","context":"any","message":"@type should be limited to numeric or string literals and names"},{"comment":"JsdocBlock:has(JsdocTag[tag=type][parsedType.type=JsdocTypeName]:not(*[parsedType.value=/^(true|false|null|undefined|boolean|number|string)$/]))","context":"any","message":"@type names should only be recognized primitive types or literals"}]}]
215
- // Message: @type names should only be recognized primitive types or literals
216
-
217
- /**
218
- *
219
- */
220
- function test(): string { }
221
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(*:has(JsdocTag[tag=/returns/]))","context":"FunctionDeclaration[returnType.typeAnnotation.type!=/TSVoidKeyword|TSUndefinedKeyword/]","message":"Functions with non-void return types must have a @returns tag"}]}]
222
- // Message: Functions with non-void return types must have a @returns tag
223
-
224
- /**
225
- *
226
- */
227
- let test = (): string => { };
228
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(*:has(JsdocTag[tag=/returns/]))","context":"ArrowFunctionExpression[returnType.typeAnnotation.type!=/TSVoidKeyword|TSUndefinedKeyword/]","message":"Functions with non-void return types must have a @returns tag"}]}]
229
- // Message: Functions with non-void return types must have a @returns tag
230
-
231
- /**
232
- * @returns
233
- */
234
- let test: () => string;
235
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(*:has(JsdocTag[tag=/returns/]:has(JsdocDescriptionLine)))","context":"VariableDeclaration:has(*[typeAnnotation.typeAnnotation.type=/TSFunctionType/][typeAnnotation.typeAnnotation.returnType.typeAnnotation.type!=/TSVoidKeyword|TSUndefinedKeyword/])","message":"FunctionType's with non-void return types must have a @returns tag with a description"}]}]
236
- // Message: FunctionType's with non-void return types must have a @returns tag with a description
237
-
238
- /**
239
- *
240
- */
241
- class Test {
242
- abstract Test(): string;
243
- }
244
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(*:has(JsdocTag[tag=/returns/]))","context":"TSEmptyBodyFunctionExpression[returnType.typeAnnotation.type!=/TSVoidKeyword|TSUndefinedKeyword/]","message":"methods with non-void return types must have a @returns tag"}]}]
245
- // Message: methods with non-void return types must have a @returns tag
246
-
247
- /**
248
- * This has an inline {@link http://example.com}
249
- */
250
- function quux () {
251
-
252
- }
253
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocInlineTag)","context":"FunctionDeclaration"}]}]
254
- // Message: Syntax is restricted: FunctionDeclaration with JsdocBlock:has(JsdocInlineTag)
255
-
256
- /**
257
- * @see This has an inline {@link http://example.com}
258
- */
259
- function quux () {
260
-
261
- }
262
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag:has(JsdocInlineTag[format=\"plain\"]))","context":"FunctionDeclaration"}]}]
263
- // Message: Syntax is restricted: FunctionDeclaration with JsdocBlock:has(JsdocTag:has(JsdocInlineTag[format="plain"]))
264
- ````
265
-
266
-
267
-
268
- <a name="user-content-no-restricted-syntax-passing-examples"></a>
269
- <a name="no-restricted-syntax-passing-examples"></a>
270
- ## Passing examples
271
-
272
- The following patterns are not considered problems:
273
-
274
- ````js
275
- /**
276
- *
277
- */
278
- function quux () {
279
-
280
- }
281
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":["FunctionExpression"]}]
282
-
283
- /**
284
- * @implements {Bar|Foo}
285
- */
286
- function quux () {
287
-
288
- }
289
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTypeUnion > JsdocTypeName[value=\"Foo\"]:nth-child(1))","context":"FunctionDeclaration"}]}]
290
-
291
- /**
292
- * @param ab
293
- * @param cd
294
- */
295
- function a () {}
296
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","context":"any","message":"Only allowing names not matching `/^opt_/i`."}]}]
297
-
298
- /**
299
- * @param ab
300
- * @param cd
301
- */
302
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","context":"any","message":"Only allowing names not matching `/^opt_/i`."}]}]
303
-
304
- /**
305
- * @param ab
306
- * @param cd
307
- */
308
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[name=/opt_/])","message":"Only allowing names not matching `/^opt_/i`."}]}]
309
-
310
- /**
311
- * @enum {String}
312
- * Object holding values of some custom enum
313
- */
314
- const MY_ENUM = Object.freeze({
315
- VAL_A: "myvala"
316
- } as const);
317
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTag ~ JsdocTag[tag=/private|protected/])","context":"any","message":"Access modifier tags must come first"},{"comment":"JsdocBlock[postDelimiter=\"\"]:has(JsdocTag[tag=\"enum\"])","context":":declaration:not(TSEnumDeclaration):not(:has(ObjectExpression)), :function","message":"@enum is only allowed on potential enum types"}]}]
318
-
319
- /**
320
- * @param {(...args: any[]) => any} fn
321
- * @returns {(...args: any[]) => any}
322
- */
323
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[tag=\"type\"]:has([value=/FunctionComponent/]))","context":"any","message":"The `FunctionComponent` type is not allowed. Please use `FC` instead."}]}]
324
-
325
- /** Does something very important. */
326
- function foo(): string;
327
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[endLine=0][description!=/^\\S[\\s\\S]*\\S\\s$/]"}]}]
328
-
329
- /** Some text and more */
330
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[descriptionStartLine=0][descriptionEndLine=1]","context":"any","message":"Requiring descriptive text on 0th line and no final newline"}]}]
331
-
332
- /** Some text and
333
- * more */
334
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[descriptionStartLine=0][hasPreterminalDescription=0]","context":"any","message":"Requiring descriptive text on 0th line and no preterminal description"}]}]
335
-
336
- /** Some text
337
- * @param sth Param text followed by newline
338
- */
339
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock[descriptionStartLine=0][hasPreterminalTagDescription=1]","context":"any","message":"Requiring descriptive text on 0th line but no preterminal description"}]}]
340
-
341
- /**
342
- * @type {123}
343
- */
344
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[tag=type][parsedType.type!=JsdocTypeStringValue][parsedType.type!=JsdocTypeNumber][parsedType.type!=JsdocTypeName])","context":"any","message":"@type should be limited to numeric or string literals and names"},{"comment":"JsdocBlock:has(JsdocTag[tag=type][parsedType.type=JsdocTypeName]:not(*[parsedType.value=/^(true|false|null|undefined|boolean|number|string)$/]))","context":"any","message":"@type names should only be recognized primitive types or literals"}]}]
345
-
346
- /**
347
- * @type {boolean}
348
- */
349
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[tag=type][parsedType.type!=JsdocTypeStringValue][parsedType.type!=JsdocTypeNumber][parsedType.type!=JsdocTypeName])","context":"any","message":"@type should be limited to numeric or string literals and names"},{"comment":"JsdocBlock:has(JsdocTag[tag=type][parsedType.type=JsdocTypeName]:not(*[parsedType.value=/^(true|false|null|undefined|boolean|number|string)$/]))","context":"any","message":"@type names should only be recognized primitive types or literals"}]}]
350
-
351
- /**
352
- *
353
- */
354
- function test(): void { }
355
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(*:has(JsdocTag[tag=/returns/]))","context":"FunctionDeclaration[returnType.typeAnnotation.type!=/TSVoidKeyword|TSUndefinedKeyword/]","message":"Functions with return types must have a @returns tag"}]}]
356
-
357
- /**
358
- *
359
- */
360
- let test = (): undefined => { };
361
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(*:has(JsdocTag[tag=/returns/]))","context":"ArrowFunctionExpression[returnType.typeAnnotation.type!=/TSVoidKeyword|TSUndefinedKeyword/]","message":"Functions with non-void return types must have a @returns tag"}]}]
362
-
363
- /**
364
- * @returns A description
365
- */
366
- let test: () => string;
367
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(*:has(JsdocTag[tag=/returns/]:has(JsdocDescriptionLine)))","context":"VariableDeclaration:has(*[typeAnnotation.typeAnnotation.type=/TSFunctionType/])","message":"FunctionType's with non-void return types must have a @returns tag"}]}]
368
-
369
- /**
370
- *
371
- */
372
- class Test {
373
- abstract Test(): void;
374
- }
375
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(*:has(JsdocTag[tag=/returns/]))","context":"TSEmptyBodyFunctionExpression[returnType.typeAnnotation.type!=/TSVoidKeyword|TSUndefinedKeyword/]","message":"methods with non-void return types must have a @returns tag"}]}]
376
-
377
- /**
378
- * @private
379
- */
380
- function quux () {}
381
- // "jsdoc/no-restricted-syntax": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:not(JsdocBlock:has(JsdocTag[tag=/private|protected|public/]))","context":"any","message":"Access modifier tags must be present"}]}]
382
- ````
383
-
@@ -1,168 +0,0 @@
1
- <a name="user-content-no-types"></a>
2
- <a name="no-types"></a>
3
- # <code>no-types</code>
4
-
5
- * [Fixer](#user-content-no-types-fixer)
6
- * [Options](#user-content-no-types-options)
7
- * [`contexts`](#user-content-no-types-options-contexts)
8
- * [Context and settings](#user-content-no-types-context-and-settings)
9
- * [Failing examples](#user-content-no-types-failing-examples)
10
- * [Passing examples](#user-content-no-types-passing-examples)
11
-
12
-
13
- This rule reports types being used on `@param` or `@returns`.
14
-
15
- The rule is intended to prevent the indication of types on tags where
16
- the type information would be redundant with TypeScript.
17
-
18
- <a name="user-content-no-types-fixer"></a>
19
- <a name="no-types-fixer"></a>
20
- ## Fixer
21
-
22
- (TODO)
23
-
24
- <a name="user-content-no-types-options"></a>
25
- <a name="no-types-options"></a>
26
- ## Options
27
-
28
- <a name="user-content-no-types-options-contexts"></a>
29
- <a name="no-types-options-contexts"></a>
30
- ### <code>contexts</code>
31
-
32
- Set this to an array of strings representing the AST context (or an object with
33
- `context` and `comment` properties) where you wish the rule to be applied.
34
- Overrides the default contexts (see below). Set to `"any"` if you want
35
- the rule to apply to any jsdoc block throughout your files (as is necessary
36
- for finding function blocks not attached to a function declaration or
37
- expression, i.e., `@callback` or `@function` (or its aliases `@func` or
38
- `@method`) (including those associated with an `@interface`).
39
-
40
- See the ["AST and Selectors"](#user-content-eslint-plugin-jsdoc-advanced-ast-and-selectors)
41
- section of our README for more on the expected format.
42
-
43
- <a name="user-content-no-types-context-and-settings"></a>
44
- <a name="no-types-context-and-settings"></a>
45
- ## Context and settings
46
-
47
- |||
48
- |---|---|
49
- |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
50
- |Tags|`param`, `returns`|
51
- |Aliases|`arg`, `argument`, `return`|
52
- |Recommended|false|
53
- |Options|`contexts`|
54
-
55
- <a name="user-content-no-types-failing-examples"></a>
56
- <a name="no-types-failing-examples"></a>
57
- ## Failing examples
58
-
59
- The following patterns are considered problems:
60
-
61
- ````js
62
- /**
63
- * @param {number} foo
64
- */
65
- function quux (foo) {
66
-
67
- }
68
- // Message: Types are not permitted on @param.
69
-
70
- class quux {
71
- /**
72
- * @param {number} foo
73
- */
74
- bar (foo) {
75
-
76
- }
77
- }
78
- // Message: Types are not permitted on @param.
79
-
80
- /**
81
- * @param {number} foo
82
- */
83
- function quux (foo) {
84
-
85
- }
86
- // "jsdoc/no-types": ["error"|"warn", {"contexts":["any"]}]
87
- // Message: Types are not permitted on @param.
88
-
89
- class quux {
90
- /**
91
- * @param {number} foo
92
- */
93
- quux (foo) {
94
-
95
- }
96
- }
97
- // "jsdoc/no-types": ["error"|"warn", {"contexts":["any"]}]
98
- // Message: Types are not permitted on @param.
99
-
100
- /**
101
- * @function
102
- * @param {number} foo
103
- */
104
- // "jsdoc/no-types": ["error"|"warn", {"contexts":["any"]}]
105
- // Message: Types are not permitted on @param.
106
-
107
- /**
108
- * @callback
109
- * @param {number} foo
110
- */
111
- // "jsdoc/no-types": ["error"|"warn", {"contexts":["any"]}]
112
- // Message: Types are not permitted on @param.
113
-
114
- /**
115
- * @returns {number}
116
- */
117
- function quux () {
118
-
119
- }
120
- // Message: Types are not permitted on @returns.
121
-
122
- /**
123
- * Beep
124
- * Boop
125
- *
126
- * @returns {number}
127
- */
128
- function quux () {
129
-
130
- }
131
- // Message: Types are not permitted on @returns.
132
- ````
133
-
134
-
135
-
136
- <a name="user-content-no-types-passing-examples"></a>
137
- <a name="no-types-passing-examples"></a>
138
- ## Passing examples
139
-
140
- The following patterns are not considered problems:
141
-
142
- ````js
143
- /**
144
- * @param foo
145
- */
146
- function quux (foo) {
147
-
148
- }
149
-
150
- /**
151
- * @param foo
152
- */
153
- // "jsdoc/no-types": ["error"|"warn", {"contexts":["any"]}]
154
-
155
- /**
156
- * @function
157
- * @param {number} foo
158
- */
159
-
160
- /**
161
- * @callback
162
- * @param {number} foo
163
- */
164
-
165
- /*** Oops that's too many asterisks by accident **/
166
- function a () {}
167
- ````
168
-