eslint-plugin-jsdoc 46.4.6 → 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 (187) hide show
  1. package/README.md +31 -0
  2. package/dist/index.js +21 -10
  3. package/dist/index.js.map +1 -1
  4. package/package.json +14 -12
  5. package/dist/WarnSettings.d.ts +0 -17
  6. package/dist/WarnSettings.d.ts.map +0 -1
  7. package/dist/alignTransform.d.ts +0 -32
  8. package/dist/alignTransform.d.ts.map +0 -1
  9. package/dist/defaultTagOrder.d.ts +0 -5
  10. package/dist/defaultTagOrder.d.ts.map +0 -1
  11. package/dist/exportParser.d.ts +0 -41
  12. package/dist/exportParser.d.ts.map +0 -1
  13. package/dist/getDefaultTagStructureForMode.d.ts +0 -11
  14. package/dist/getDefaultTagStructureForMode.d.ts.map +0 -1
  15. package/dist/index.d.ts +0 -10
  16. package/dist/index.d.ts.map +0 -1
  17. package/dist/iterateJsdoc.d.ts +0 -460
  18. package/dist/iterateJsdoc.d.ts.map +0 -1
  19. package/dist/jsdocUtils.d.ts +0 -421
  20. package/dist/jsdocUtils.d.ts.map +0 -1
  21. package/dist/rules/checkAccess.d.ts +0 -3
  22. package/dist/rules/checkAccess.d.ts.map +0 -1
  23. package/dist/rules/checkAlignment.d.ts +0 -3
  24. package/dist/rules/checkAlignment.d.ts.map +0 -1
  25. package/dist/rules/checkExamples.d.ts +0 -4
  26. package/dist/rules/checkExamples.d.ts.map +0 -1
  27. package/dist/rules/checkIndentation.d.ts +0 -3
  28. package/dist/rules/checkIndentation.d.ts.map +0 -1
  29. package/dist/rules/checkLineAlignment.d.ts +0 -10
  30. package/dist/rules/checkLineAlignment.d.ts.map +0 -1
  31. package/dist/rules/checkParamNames.d.ts +0 -3
  32. package/dist/rules/checkParamNames.d.ts.map +0 -1
  33. package/dist/rules/checkPropertyNames.d.ts +0 -3
  34. package/dist/rules/checkPropertyNames.d.ts.map +0 -1
  35. package/dist/rules/checkSyntax.d.ts +0 -3
  36. package/dist/rules/checkSyntax.d.ts.map +0 -1
  37. package/dist/rules/checkTagNames.d.ts +0 -3
  38. package/dist/rules/checkTagNames.d.ts.map +0 -1
  39. package/dist/rules/checkTypes.d.ts +0 -3
  40. package/dist/rules/checkTypes.d.ts.map +0 -1
  41. package/dist/rules/checkValues.d.ts +0 -3
  42. package/dist/rules/checkValues.d.ts.map +0 -1
  43. package/dist/rules/emptyTags.d.ts +0 -3
  44. package/dist/rules/emptyTags.d.ts.map +0 -1
  45. package/dist/rules/implementsOnClasses.d.ts +0 -3
  46. package/dist/rules/implementsOnClasses.d.ts.map +0 -1
  47. package/dist/rules/importsAsDependencies.d.ts +0 -3
  48. package/dist/rules/importsAsDependencies.d.ts.map +0 -1
  49. package/dist/rules/informativeDocs.d.ts +0 -3
  50. package/dist/rules/informativeDocs.d.ts.map +0 -1
  51. package/dist/rules/matchDescription.d.ts +0 -3
  52. package/dist/rules/matchDescription.d.ts.map +0 -1
  53. package/dist/rules/matchName.d.ts +0 -3
  54. package/dist/rules/matchName.d.ts.map +0 -1
  55. package/dist/rules/multilineBlocks.d.ts +0 -3
  56. package/dist/rules/multilineBlocks.d.ts.map +0 -1
  57. package/dist/rules/noBadBlocks.d.ts +0 -3
  58. package/dist/rules/noBadBlocks.d.ts.map +0 -1
  59. package/dist/rules/noBlankBlockDescriptions.d.ts +0 -3
  60. package/dist/rules/noBlankBlockDescriptions.d.ts.map +0 -1
  61. package/dist/rules/noBlankBlocks.d.ts +0 -3
  62. package/dist/rules/noBlankBlocks.d.ts.map +0 -1
  63. package/dist/rules/noDefaults.d.ts +0 -3
  64. package/dist/rules/noDefaults.d.ts.map +0 -1
  65. package/dist/rules/noMissingSyntax.d.ts +0 -10
  66. package/dist/rules/noMissingSyntax.d.ts.map +0 -1
  67. package/dist/rules/noMultiAsterisks.d.ts +0 -3
  68. package/dist/rules/noMultiAsterisks.d.ts.map +0 -1
  69. package/dist/rules/noRestrictedSyntax.d.ts +0 -3
  70. package/dist/rules/noRestrictedSyntax.d.ts.map +0 -1
  71. package/dist/rules/noTypes.d.ts +0 -3
  72. package/dist/rules/noTypes.d.ts.map +0 -1
  73. package/dist/rules/noUndefinedTypes.d.ts +0 -3
  74. package/dist/rules/noUndefinedTypes.d.ts.map +0 -1
  75. package/dist/rules/requireAsteriskPrefix.d.ts +0 -3
  76. package/dist/rules/requireAsteriskPrefix.d.ts.map +0 -1
  77. package/dist/rules/requireDescription.d.ts +0 -3
  78. package/dist/rules/requireDescription.d.ts.map +0 -1
  79. package/dist/rules/requireDescriptionCompleteSentence.d.ts +0 -3
  80. package/dist/rules/requireDescriptionCompleteSentence.d.ts.map +0 -1
  81. package/dist/rules/requireExample.d.ts +0 -3
  82. package/dist/rules/requireExample.d.ts.map +0 -1
  83. package/dist/rules/requireFileOverview.d.ts +0 -3
  84. package/dist/rules/requireFileOverview.d.ts.map +0 -1
  85. package/dist/rules/requireHyphenBeforeParamDescription.d.ts +0 -3
  86. package/dist/rules/requireHyphenBeforeParamDescription.d.ts.map +0 -1
  87. package/dist/rules/requireJsdoc.d.ts +0 -9
  88. package/dist/rules/requireJsdoc.d.ts.map +0 -1
  89. package/dist/rules/requireParam.d.ts +0 -4
  90. package/dist/rules/requireParam.d.ts.map +0 -1
  91. package/dist/rules/requireParamDescription.d.ts +0 -3
  92. package/dist/rules/requireParamDescription.d.ts.map +0 -1
  93. package/dist/rules/requireParamName.d.ts +0 -3
  94. package/dist/rules/requireParamName.d.ts.map +0 -1
  95. package/dist/rules/requireParamType.d.ts +0 -3
  96. package/dist/rules/requireParamType.d.ts.map +0 -1
  97. package/dist/rules/requireProperty.d.ts +0 -3
  98. package/dist/rules/requireProperty.d.ts.map +0 -1
  99. package/dist/rules/requirePropertyDescription.d.ts +0 -3
  100. package/dist/rules/requirePropertyDescription.d.ts.map +0 -1
  101. package/dist/rules/requirePropertyName.d.ts +0 -3
  102. package/dist/rules/requirePropertyName.d.ts.map +0 -1
  103. package/dist/rules/requirePropertyType.d.ts +0 -3
  104. package/dist/rules/requirePropertyType.d.ts.map +0 -1
  105. package/dist/rules/requireReturns.d.ts +0 -3
  106. package/dist/rules/requireReturns.d.ts.map +0 -1
  107. package/dist/rules/requireReturnsCheck.d.ts +0 -3
  108. package/dist/rules/requireReturnsCheck.d.ts.map +0 -1
  109. package/dist/rules/requireReturnsDescription.d.ts +0 -3
  110. package/dist/rules/requireReturnsDescription.d.ts.map +0 -1
  111. package/dist/rules/requireReturnsType.d.ts +0 -3
  112. package/dist/rules/requireReturnsType.d.ts.map +0 -1
  113. package/dist/rules/requireThrows.d.ts +0 -3
  114. package/dist/rules/requireThrows.d.ts.map +0 -1
  115. package/dist/rules/requireYields.d.ts +0 -3
  116. package/dist/rules/requireYields.d.ts.map +0 -1
  117. package/dist/rules/requireYieldsCheck.d.ts +0 -3
  118. package/dist/rules/requireYieldsCheck.d.ts.map +0 -1
  119. package/dist/rules/sortTags.d.ts +0 -3
  120. package/dist/rules/sortTags.d.ts.map +0 -1
  121. package/dist/rules/tagLines.d.ts +0 -3
  122. package/dist/rules/tagLines.d.ts.map +0 -1
  123. package/dist/rules/textEscaping.d.ts +0 -3
  124. package/dist/rules/textEscaping.d.ts.map +0 -1
  125. package/dist/rules/validTypes.d.ts +0 -3
  126. package/dist/rules/validTypes.d.ts.map +0 -1
  127. package/dist/tagNames.d.ts +0 -16
  128. package/dist/tagNames.d.ts.map +0 -1
  129. package/dist/utils/hasReturnValue.d.ts +0 -20
  130. package/dist/utils/hasReturnValue.d.ts.map +0 -1
  131. package/docs/advanced.md +0 -102
  132. package/docs/rules/check-access.md +0 -193
  133. package/docs/rules/check-alignment.md +0 -169
  134. package/docs/rules/check-examples.md +0 -784
  135. package/docs/rules/check-indentation.md +0 -296
  136. package/docs/rules/check-line-alignment.md +0 -1002
  137. package/docs/rules/check-param-names.md +0 -1035
  138. package/docs/rules/check-property-names.md +0 -244
  139. package/docs/rules/check-syntax.md +0 -80
  140. package/docs/rules/check-tag-names.md +0 -1132
  141. package/docs/rules/check-types.md +0 -1198
  142. package/docs/rules/check-values.md +0 -409
  143. package/docs/rules/empty-tags.md +0 -220
  144. package/docs/rules/implements-on-classes.md +0 -219
  145. package/docs/rules/imports-as-dependencies.md +0 -99
  146. package/docs/rules/informative-docs.md +0 -400
  147. package/docs/rules/match-description.md +0 -1008
  148. package/docs/rules/match-name.md +0 -249
  149. package/docs/rules/multiline-blocks.md +0 -398
  150. package/docs/rules/no-bad-blocks.md +0 -174
  151. package/docs/rules/no-blank-block-descriptions.md +0 -91
  152. package/docs/rules/no-blank-blocks.md +0 -98
  153. package/docs/rules/no-defaults.md +0 -207
  154. package/docs/rules/no-missing-syntax.md +0 -275
  155. package/docs/rules/no-multi-asterisks.md +0 -278
  156. package/docs/rules/no-restricted-syntax.md +0 -383
  157. package/docs/rules/no-types.md +0 -168
  158. package/docs/rules/no-undefined-types.md +0 -789
  159. package/docs/rules/require-asterisk-prefix.md +0 -297
  160. package/docs/rules/require-description-complete-sentence.md +0 -820
  161. package/docs/rules/require-description.md +0 -585
  162. package/docs/rules/require-example.md +0 -390
  163. package/docs/rules/require-file-overview.md +0 -324
  164. package/docs/rules/require-hyphen-before-param-description.md +0 -281
  165. package/docs/rules/require-jsdoc.md +0 -1857
  166. package/docs/rules/require-param-description.md +0 -238
  167. package/docs/rules/require-param-name.md +0 -163
  168. package/docs/rules/require-param-type.md +0 -227
  169. package/docs/rules/require-param.md +0 -1820
  170. package/docs/rules/require-property-description.md +0 -88
  171. package/docs/rules/require-property-name.md +0 -79
  172. package/docs/rules/require-property-type.md +0 -79
  173. package/docs/rules/require-property.md +0 -128
  174. package/docs/rules/require-returns-check.md +0 -1053
  175. package/docs/rules/require-returns-description.md +0 -181
  176. package/docs/rules/require-returns-type.md +0 -144
  177. package/docs/rules/require-returns.md +0 -1191
  178. package/docs/rules/require-throws.md +0 -326
  179. package/docs/rules/require-yields-check.md +0 -544
  180. package/docs/rules/require-yields.md +0 -823
  181. package/docs/rules/sort-tags.md +0 -635
  182. package/docs/rules/tag-lines.md +0 -551
  183. package/docs/rules/text-escaping.md +0 -177
  184. package/docs/rules/valid-types.md +0 -881
  185. package/docs/settings.md +0 -362
  186. package/tsconfig-prod.json +0 -20
  187. package/tsconfig.json +0 -21
@@ -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
-