eslint-plugin-jsdoc 50.6.17 → 50.7.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 (155) hide show
  1. package/dist/alignTransform.cjs +10 -10
  2. package/dist/alignTransform.cjs.map +1 -1
  3. package/dist/exportParser.cjs +141 -135
  4. package/dist/exportParser.cjs.map +1 -1
  5. package/dist/generateRule.cjs +10 -12
  6. package/dist/generateRule.cjs.map +1 -1
  7. package/dist/getDefaultTagStructureForMode.cjs +73 -73
  8. package/dist/getDefaultTagStructureForMode.cjs.map +1 -1
  9. package/dist/getJsdocProcessorPlugin.cjs +121 -110
  10. package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
  11. package/dist/index.cjs +17 -12
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.ts +4 -3
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/iterateJsdoc.cjs +87 -66
  16. package/dist/iterateJsdoc.cjs.map +1 -1
  17. package/dist/jsdocUtils.cjs +144 -142
  18. package/dist/jsdocUtils.cjs.map +1 -1
  19. package/dist/rules/checkAlignment.cjs +2 -2
  20. package/dist/rules/checkAlignment.cjs.map +1 -1
  21. package/dist/rules/checkExamples.cjs +22 -28
  22. package/dist/rules/checkExamples.cjs.map +1 -1
  23. package/dist/rules/checkIndentation.cjs +2 -2
  24. package/dist/rules/checkIndentation.cjs.map +1 -1
  25. package/dist/rules/checkLineAlignment.cjs +14 -14
  26. package/dist/rules/checkLineAlignment.cjs.map +1 -1
  27. package/dist/rules/checkParamNames.cjs +21 -15
  28. package/dist/rules/checkParamNames.cjs.map +1 -1
  29. package/dist/rules/checkPropertyNames.cjs +2 -2
  30. package/dist/rules/checkPropertyNames.cjs.map +1 -1
  31. package/dist/rules/checkTagNames.cjs +11 -11
  32. package/dist/rules/checkTagNames.cjs.map +1 -1
  33. package/dist/rules/checkTemplateNames.cjs +21 -22
  34. package/dist/rules/checkTemplateNames.cjs.map +1 -1
  35. package/dist/rules/checkTypes.cjs +10 -10
  36. package/dist/rules/checkTypes.cjs.map +1 -1
  37. package/dist/rules/checkValues.cjs +11 -14
  38. package/dist/rules/checkValues.cjs.map +1 -1
  39. package/dist/rules/convertToJsdocComments.cjs +26 -27
  40. package/dist/rules/convertToJsdocComments.cjs.map +1 -1
  41. package/dist/rules/emptyTags.cjs +6 -6
  42. package/dist/rules/emptyTags.cjs.map +1 -1
  43. package/dist/rules/importsAsDependencies.cjs.map +1 -1
  44. package/dist/rules/informativeDocs.cjs +12 -12
  45. package/dist/rules/informativeDocs.cjs.map +1 -1
  46. package/dist/rules/linesBeforeBlock.cjs +12 -12
  47. package/dist/rules/linesBeforeBlock.cjs.map +1 -1
  48. package/dist/rules/matchDescription.cjs +1 -1
  49. package/dist/rules/matchDescription.cjs.map +1 -1
  50. package/dist/rules/matchName.cjs +4 -4
  51. package/dist/rules/matchName.cjs.map +1 -1
  52. package/dist/rules/multilineBlocks.cjs +10 -10
  53. package/dist/rules/multilineBlocks.cjs.map +1 -1
  54. package/dist/rules/noBadBlocks.cjs +3 -3
  55. package/dist/rules/noBadBlocks.cjs.map +1 -1
  56. package/dist/rules/noMultiAsterisks.cjs +6 -6
  57. package/dist/rules/noMultiAsterisks.cjs.map +1 -1
  58. package/dist/rules/noRestrictedSyntax.cjs +2 -2
  59. package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
  60. package/dist/rules/noTypes.cjs.map +1 -1
  61. package/dist/rules/noUndefinedTypes.cjs +17 -20
  62. package/dist/rules/noUndefinedTypes.cjs.map +1 -1
  63. package/dist/rules/requireAsteriskPrefix.cjs +4 -4
  64. package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
  65. package/dist/rules/requireDescription.cjs +2 -2
  66. package/dist/rules/requireDescription.cjs.map +1 -1
  67. package/dist/rules/requireDescriptionCompleteSentence.cjs +8 -8
  68. package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
  69. package/dist/rules/requireFileOverview.cjs +6 -6
  70. package/dist/rules/requireFileOverview.cjs.map +1 -1
  71. package/dist/rules/requireHyphenBeforeParamDescription.cjs +1 -4
  72. package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
  73. package/dist/rules/requireJsdoc.cjs +19 -19
  74. package/dist/rules/requireJsdoc.cjs.map +1 -1
  75. package/dist/rules/requireParam.cjs +12 -12
  76. package/dist/rules/requireParam.cjs.map +1 -1
  77. package/dist/rules/requireProperty.cjs +1 -1
  78. package/dist/rules/requireProperty.cjs.map +1 -1
  79. package/dist/rules/requireReturns.cjs +3 -3
  80. package/dist/rules/requireReturns.cjs.map +1 -1
  81. package/dist/rules/requireReturnsCheck.cjs +1 -1
  82. package/dist/rules/requireReturnsCheck.cjs.map +1 -1
  83. package/dist/rules/requireReturnsDescription.cjs +1 -1
  84. package/dist/rules/requireReturnsDescription.cjs.map +1 -1
  85. package/dist/rules/requireTemplate.cjs +16 -15
  86. package/dist/rules/requireTemplate.cjs.map +1 -1
  87. package/dist/rules/requireYields.cjs +4 -4
  88. package/dist/rules/requireYields.cjs.map +1 -1
  89. package/dist/rules/requireYieldsCheck.cjs +6 -6
  90. package/dist/rules/requireYieldsCheck.cjs.map +1 -1
  91. package/dist/rules/sortTags.cjs +13 -13
  92. package/dist/rules/sortTags.cjs.map +1 -1
  93. package/dist/rules/tagLines.cjs +11 -11
  94. package/dist/rules/tagLines.cjs.map +1 -1
  95. package/dist/rules/textEscaping.cjs +2 -2
  96. package/dist/rules/textEscaping.cjs.map +1 -1
  97. package/dist/rules/validTypes.cjs +15 -15
  98. package/dist/rules/validTypes.cjs.map +1 -1
  99. package/dist/tagNames.cjs +1 -1
  100. package/dist/tagNames.cjs.map +1 -1
  101. package/dist/utils/hasReturnValue.cjs +176 -176
  102. package/dist/utils/hasReturnValue.cjs.map +1 -1
  103. package/eslint.config.js +36 -32
  104. package/package.json +30 -30
  105. package/pnpm-workspace.yaml +1 -0
  106. package/src/alignTransform.js +15 -15
  107. package/src/exportParser.js +386 -373
  108. package/src/getDefaultTagStructureForMode.js +45 -45
  109. package/src/getJsdocProcessorPlugin.js +175 -128
  110. package/src/index.js +66 -37
  111. package/src/iterateJsdoc.js +61 -28
  112. package/src/jsdocUtils.js +354 -338
  113. package/src/rules/checkAlignment.js +2 -2
  114. package/src/rules/checkExamples.js +16 -20
  115. package/src/rules/checkIndentation.js +2 -2
  116. package/src/rules/checkLineAlignment.js +10 -10
  117. package/src/rules/checkParamNames.js +22 -14
  118. package/src/rules/checkPropertyNames.js +1 -1
  119. package/src/rules/checkTagNames.js +7 -7
  120. package/src/rules/checkTemplateNames.js +52 -38
  121. package/src/rules/checkTypes.js +7 -7
  122. package/src/rules/checkValues.js +16 -17
  123. package/src/rules/convertToJsdocComments.js +47 -37
  124. package/src/rules/emptyTags.js +14 -7
  125. package/src/rules/importsAsDependencies.js +3 -1
  126. package/src/rules/informativeDocs.js +58 -58
  127. package/src/rules/linesBeforeBlock.js +25 -17
  128. package/src/rules/matchDescription.js +1 -1
  129. package/src/rules/matchName.js +2 -2
  130. package/src/rules/multilineBlocks.js +10 -10
  131. package/src/rules/noBadBlocks.js +3 -3
  132. package/src/rules/noMultiAsterisks.js +4 -4
  133. package/src/rules/noRestrictedSyntax.js +1 -1
  134. package/src/rules/noTypes.js +1 -1
  135. package/src/rules/noUndefinedTypes.js +29 -23
  136. package/src/rules/requireAsteriskPrefix.js +3 -3
  137. package/src/rules/requireDescription.js +1 -1
  138. package/src/rules/requireDescriptionCompleteSentence.js +6 -6
  139. package/src/rules/requireFileOverview.js +3 -3
  140. package/src/rules/requireHyphenBeforeParamDescription.js +2 -5
  141. package/src/rules/requireJsdoc.js +14 -14
  142. package/src/rules/requireParam.js +9 -9
  143. package/src/rules/requireProperty.js +1 -1
  144. package/src/rules/requireReturns.js +1 -1
  145. package/src/rules/requireReturnsCheck.js +1 -1
  146. package/src/rules/requireReturnsDescription.js +1 -1
  147. package/src/rules/requireTemplate.js +59 -38
  148. package/src/rules/requireYields.js +3 -3
  149. package/src/rules/requireYieldsCheck.js +1 -1
  150. package/src/rules/sortTags.js +7 -7
  151. package/src/rules/tagLines.js +8 -8
  152. package/src/rules/textEscaping.js +2 -0
  153. package/src/rules/validTypes.js +29 -29
  154. package/src/tagNames.js +2 -2
  155. package/src/utils/hasReturnValue.js +298 -283
@@ -48,7 +48,8 @@ const getSymbolValue = function (symbol) {
48
48
  if (symbol.type === 'literal') {
49
49
  return /** @type {ValueObject} */ (symbol.value).value;
50
50
  }
51
- /* c8 ignore next */
51
+ /* c8 ignore next 2 */
52
+ // eslint-disable-next-line @stylistic/padding-line-between-statements -- c8
52
53
  return null;
53
54
  };
54
55
 
@@ -123,172 +124,180 @@ const getSymbol = function (node, globals, scope, opt) {
123
124
  const opts = opt || {};
124
125
  /* c8 ignore next */
125
126
  switch (node.type) {
126
- case 'Identifier': {
127
- return getIdentifier(node, globals, scope, opts);
128
- }
127
+ /* c8 ignore next 4 -- No longer needed? */
128
+ case 'ArrowFunctionExpression':
129
129
 
130
- case 'MemberExpression': {
131
- const obj = getSymbol(
132
- /** @type {import('eslint').Rule.Node} */
133
- (node.object),
134
- globals,
135
- scope,
136
- opts,
137
- );
138
- const propertySymbol = getSymbol(
139
- /** @type {import('eslint').Rule.Node} */
140
- (node.property),
141
- globals,
142
- scope,
143
- {
144
- simpleIdentifier: !node.computed,
145
- },
146
- );
147
- const propertyValue = getSymbolValue(propertySymbol);
130
+ // Fallthrough
131
+ case 'ClassDeclaration':
148
132
 
149
- /* c8 ignore else */
150
- if (obj && propertyValue && obj.props[propertyValue]) {
151
- const block = obj.props[propertyValue];
133
+ case 'FunctionDeclaration':
152
134
 
153
- return block;
154
- }
155
- /* c8 ignore next 10 */
156
- /*
157
- if (opts.createMissingProps && propertyValue) {
158
- obj.props[propertyValue] = createNode();
135
+ case 'FunctionExpression':
136
+ case 'TSEnumDeclaration':
137
+ case 'TSInterfaceDeclaration':
138
+ case 'TSTypeAliasDeclaration': {
139
+ const val = createNode();
140
+ val.props.prototype = createNode();
141
+ val.props.prototype.type = 'object';
142
+ val.type = 'object';
143
+ val.value = node;
159
144
 
160
- return obj.props[propertyValue];
145
+ return val;
161
146
  }
162
- */
163
- debug(`MemberExpression: Missing property ${
164
- /** @type {import('estree').PrivateIdentifier} */ (node.property).name
165
- }`);
166
- /* c8 ignore next 2 */
167
- return null;
168
- }
169
147
 
170
- case 'ClassExpression': {
171
- return getSymbol(
148
+ case 'AssignmentExpression': {
149
+ return createSymbol(
172
150
  /** @type {import('eslint').Rule.Node} */
173
- (node.body),
174
- globals,
175
- scope,
176
- opts,
177
- );
178
- }
179
-
180
- /* c8 ignore next 4 -- No longer needed? */
181
- case 'TSTypeAliasDeclaration':
182
- // Fallthrough
183
- case 'TSEnumDeclaration':
184
- case 'TSInterfaceDeclaration':
185
- case 'ClassDeclaration':
186
- case 'FunctionExpression': case 'FunctionDeclaration':
187
- case 'ArrowFunctionExpression': {
188
- const val = createNode();
189
- val.props.prototype = createNode();
190
- val.props.prototype.type = 'object';
191
- val.type = 'object';
192
- val.value = node;
193
-
194
- return val;
195
- }
151
+ (node.left),
152
+ globals,
153
+ /** @type {import('eslint').Rule.Node} */
154
+ (node.right),
155
+ scope,
156
+ opts,
157
+ );
158
+ }
196
159
 
197
- case 'AssignmentExpression': {
198
- return createSymbol(
199
- /** @type {import('eslint').Rule.Node} */
200
- (node.left),
201
- globals,
202
- /** @type {import('eslint').Rule.Node} */
203
- (node.right),
204
- scope,
205
- opts,
206
- );
207
- }
160
+ case 'ClassBody': {
161
+ const val = createNode();
162
+ for (const method of node.body) {
163
+ // StaticBlock
164
+ if (!('key' in method)) {
165
+ continue;
166
+ }
208
167
 
209
- case 'ClassBody': {
210
- const val = createNode();
211
- for (const method of node.body) {
212
- if (!('key' in method)) { // StaticBlock
213
- continue;
214
- }
215
- val.props[
168
+ val.props[
216
169
  /** @type {import('estree').Identifier} */ (
217
170
  /** @type {import('estree').MethodDefinition} */ (
218
- method
219
- ).key
220
- ).name
221
- ] = createNode();
222
- /** @type {{[key: string]: CreatedNode}} */ (val.props)[
171
+ method
172
+ ).key
173
+ ).name
174
+ ] = createNode();
175
+ /** @type {{[key: string]: CreatedNode}} */ (val.props)[
223
176
  /** @type {import('estree').Identifier} */ (
224
177
  /** @type {import('estree').MethodDefinition} */ (
225
- method
226
- ).key
227
- ).name
228
- ].type = 'object';
229
- /** @type {{[key: string]: CreatedNode}} */ (val.props)[
178
+ method
179
+ ).key
180
+ ).name
181
+ ].type = 'object';
182
+ /** @type {{[key: string]: CreatedNode}} */ (val.props)[
230
183
  /** @type {import('estree').Identifier} */ (
231
184
  /** @type {import('estree').MethodDefinition} */ (
232
- method
233
- ).key
234
- ).name
235
- ].value = /** @type {import('eslint').Rule.Node} */ (
185
+ method
186
+ ).key
187
+ ).name
188
+ ].value = /** @type {import('eslint').Rule.Node} */ (
236
189
  /** @type {import('estree').MethodDefinition} */ (method).value
237
- );
190
+ );
191
+ }
192
+
193
+ val.type = 'object';
194
+ val.value = node.parent;
195
+
196
+ return val;
238
197
  }
239
198
 
240
- val.type = 'object';
241
- val.value = node.parent;
199
+ case 'ClassExpression': {
200
+ return getSymbol(
201
+ /** @type {import('eslint').Rule.Node} */
202
+ (node.body),
203
+ globals,
204
+ scope,
205
+ opts,
206
+ );
207
+ }
242
208
 
243
- return val;
244
- }
209
+ case 'Identifier': {
210
+ return getIdentifier(node, globals, scope, opts);
211
+ }
245
212
 
246
- case 'ObjectExpression': {
247
- const val = createNode();
248
- val.type = 'object';
249
- for (const prop of node.properties) {
250
- if ([
251
- // typescript-eslint, espree, acorn, etc.
252
- 'SpreadElement',
213
+ case 'Literal': {
214
+ const val = createNode();
215
+ val.type = 'literal';
216
+ val.value = node;
253
217
 
254
- // @babel/eslint-parser
255
- 'ExperimentalSpreadProperty',
256
- ].includes(prop.type)) {
257
- continue;
258
- }
218
+ return val;
219
+ }
259
220
 
260
- const propVal = getSymbol(
261
- /** @type {import('eslint').Rule.Node} */ (
262
- /** @type {import('estree').Property} */
263
- (prop).value
264
- ),
221
+ case 'MemberExpression': {
222
+ const obj = getSymbol(
223
+ /** @type {import('eslint').Rule.Node} */
224
+ (node.object),
265
225
  globals,
266
226
  scope,
267
227
  opts,
268
228
  );
269
- /* c8 ignore next 8 */
270
- if (propVal) {
271
- val.props[
272
- /** @type {import('estree').PrivateIdentifier} */
273
- (
274
- /** @type {import('estree').Property} */ (prop).key
275
- ).name
276
- ] = propVal;
229
+ const propertySymbol = getSymbol(
230
+ /** @type {import('eslint').Rule.Node} */
231
+ (node.property),
232
+ globals,
233
+ scope,
234
+ {
235
+ simpleIdentifier: !node.computed,
236
+ },
237
+ );
238
+ const propertyValue = getSymbolValue(propertySymbol);
239
+
240
+ /* c8 ignore else */
241
+ if (obj && propertyValue && obj.props[propertyValue]) {
242
+ const block = obj.props[propertyValue];
243
+
244
+ return block;
277
245
  }
246
+ /* c8 ignore next 11 */
247
+ /*
248
+ if (opts.createMissingProps && propertyValue) {
249
+ obj.props[propertyValue] = createNode();
250
+
251
+ return obj.props[propertyValue];
252
+ }
253
+ */
254
+ // eslint-disable-next-line @stylistic/padding-line-between-statements -- c8
255
+ debug(`MemberExpression: Missing property ${
256
+ /** @type {import('estree').PrivateIdentifier} */ (node.property).name
257
+ }`);
258
+ /* c8 ignore next 2 */
259
+ return null;
278
260
  }
279
261
 
280
- return val;
281
- }
262
+ case 'ObjectExpression': {
263
+ const val = createNode();
264
+ val.type = 'object';
265
+ for (const prop of node.properties) {
266
+ if ([
267
+ // @babel/eslint-parser
268
+ 'ExperimentalSpreadProperty',
282
269
 
283
- case 'Literal': {
284
- const val = createNode();
285
- val.type = 'literal';
286
- val.value = node;
270
+ // typescript-eslint, espree, acorn, etc.
271
+ 'SpreadElement',
272
+ ].includes(prop.type)) {
273
+ continue;
274
+ }
287
275
 
288
- return val;
289
- }
276
+ const propVal = getSymbol(
277
+ /** @type {import('eslint').Rule.Node} */ (
278
+ /** @type {import('estree').Property} */
279
+ (prop).value
280
+ ),
281
+ globals,
282
+ scope,
283
+ opts,
284
+ );
285
+ /* c8 ignore next 8 */
286
+ if (propVal) {
287
+ val.props[
288
+ /** @type {import('estree').PrivateIdentifier} */
289
+ (
290
+ /** @type {import('estree').Property} */ (prop).key
291
+ ).name
292
+ ] = propVal;
293
+ }
294
+ }
295
+
296
+ return val;
297
+ }
290
298
  }
291
- /* c8 ignore next */
299
+ /* c8 ignore next 2 */
300
+ // eslint-disable-next-line @stylistic/padding-line-between-statements -- c8
292
301
  return null;
293
302
  };
294
303
 
@@ -317,81 +326,84 @@ createSymbol = function (node, globals, value, scope, isGlobal) {
317
326
 
318
327
  let symbol;
319
328
  switch (node.type) {
320
- case 'FunctionDeclaration':
321
- /* c8 ignore next */
322
- // @ts-expect-error TS OK
323
- // Fall through
324
- case 'TSEnumDeclaration': case 'TSInterfaceDeclaration':
325
- /* c8 ignore next */
326
- // @ts-expect-error TS OK
327
- // Fall through
328
- case 'TSTypeAliasDeclaration': case 'ClassDeclaration': {
329
- const nde = /** @type {import('estree').ClassDeclaration} */ (node);
330
- /* c8 ignore else */
331
- if (nde.id && nde.id.type === 'Identifier') {
332
- return createSymbol(
329
+ case 'ClassDeclaration':
330
+ /* c8 ignore next */
331
+ // @ts-expect-error TS OK
332
+ // Fall through
333
+ case 'FunctionDeclaration': case 'TSEnumDeclaration':
334
+ /* c8 ignore next */
335
+ // @ts-expect-error TS OK
336
+ // Fall through
337
+ case 'TSInterfaceDeclaration': case 'TSTypeAliasDeclaration': {
338
+ const nde = /** @type {import('estree').ClassDeclaration} */ (node);
339
+ /* c8 ignore else */
340
+ if (nde.id && nde.id.type === 'Identifier') {
341
+ return createSymbol(
333
342
  /** @type {import('eslint').Rule.Node} */ (nde.id),
334
- globals,
335
- node,
336
- globals,
337
- );
343
+ globals,
344
+ node,
345
+ globals,
346
+ );
347
+ }
348
+ /* c8 ignore next 3 */
349
+ // eslint-disable-next-line @stylistic/padding-line-between-statements -- c8
350
+ break;
338
351
  }
339
- /* c8 ignore next 2 */
340
- break;
341
- }
342
352
 
343
- case 'Identifier': {
344
- const nde = /** @type {import('estree').Identifier} */ (node);
345
- if (value) {
346
- const valueSymbol = getSymbol(value, globals, block);
347
- /* c8 ignore else */
348
- if (valueSymbol) {
349
- createBlockSymbol(block, nde.name, valueSymbol, globals, isGlobal);
353
+ case 'Identifier': {
354
+ const nde = /** @type {import('estree').Identifier} */ (node);
355
+ if (value) {
356
+ const valueSymbol = getSymbol(value, globals, block);
357
+ /* c8 ignore else */
358
+ if (valueSymbol) {
359
+ createBlockSymbol(block, nde.name, valueSymbol, globals, isGlobal);
360
+
361
+ return block.props[nde.name];
362
+ }
363
+ /* c8 ignore next 2 */
364
+ // eslint-disable-next-line @stylistic/padding-line-between-statements -- c8
365
+ debug('Identifier: Missing value symbol for %s', nde.name);
366
+ } else {
367
+ createBlockSymbol(block, nde.name, createNode(), globals, isGlobal);
350
368
 
351
369
  return block.props[nde.name];
352
370
  }
353
- /* c8 ignore next */
354
- debug('Identifier: Missing value symbol for %s', nde.name);
355
- } else {
356
- createBlockSymbol(block, nde.name, createNode(), globals, isGlobal);
357
-
358
- return block.props[nde.name];
371
+ /* c8 ignore next 3 */
372
+ // eslint-disable-next-line @stylistic/padding-line-between-statements -- c8
373
+ break;
359
374
  }
360
- /* c8 ignore next 2 */
361
- break;
362
- }
363
375
 
364
- case 'MemberExpression': {
365
- const nde = /** @type {import('estree').MemberExpression} */ (node);
366
- symbol = getSymbol(
376
+ case 'MemberExpression': {
377
+ const nde = /** @type {import('estree').MemberExpression} */ (node);
378
+ symbol = getSymbol(
367
379
  /** @type {import('eslint').Rule.Node} */ (nde.object), globals, block,
368
- );
380
+ );
369
381
 
370
- const propertySymbol = getSymbol(
382
+ const propertySymbol = getSymbol(
371
383
  /** @type {import('eslint').Rule.Node} */ (nde.property),
372
- globals,
373
- block,
374
- {
375
- simpleIdentifier: !nde.computed,
376
- },
377
- );
378
- const propertyValue = getSymbolValue(propertySymbol);
379
- if (symbol && propertyValue) {
380
- createBlockSymbol(symbol, propertyValue, getSymbol(
384
+ globals,
385
+ block,
386
+ {
387
+ simpleIdentifier: !nde.computed,
388
+ },
389
+ );
390
+ const propertyValue = getSymbolValue(propertySymbol);
391
+ if (symbol && propertyValue) {
392
+ createBlockSymbol(symbol, propertyValue, getSymbol(
381
393
  /** @type {import('eslint').Rule.Node} */
382
- (value), globals, block,
383
- ), globals, isGlobal);
384
- return symbol.props[propertyValue];
385
- }
386
-
387
- debug(
388
- 'MemberExpression: Missing symbol: %s',
389
- /** @type {import('estree').Identifier} */ (
390
- nde.property
391
- ).name,
392
- );
393
- break;
394
- }
394
+ (value), globals, block,
395
+ ), globals, isGlobal);
396
+ return symbol.props[propertyValue];
397
+ }
398
+
399
+ debug(
400
+ 'MemberExpression: Missing symbol: %s',
401
+ /** @type {import('estree').Identifier} */ (
402
+ nde.property
403
+ ).name,
404
+ );
405
+ break;
406
+ }
395
407
  }
396
408
 
397
409
  return null;
@@ -406,63 +418,63 @@ createSymbol = function (node, globals, value, scope, isGlobal) {
406
418
  */
407
419
  const initVariables = function (node, globals, opts) {
408
420
  switch (node.type) {
409
- case 'Program': {
410
- for (const childNode of node.body) {
411
- initVariables(
421
+ case 'ExportNamedDeclaration': {
422
+ if (node.declaration) {
423
+ initVariables(
412
424
  /** @type {import('eslint').Rule.Node} */
413
- (childNode),
425
+ (node.declaration),
426
+ globals,
427
+ opts,
428
+ );
429
+ }
430
+
431
+ break;
432
+ }
433
+
434
+ case 'ExpressionStatement': {
435
+ initVariables(
436
+ /** @type {import('eslint').Rule.Node} */
437
+ (node.expression),
414
438
  globals,
415
439
  opts,
416
440
  );
441
+ break;
417
442
  }
418
443
 
419
- break;
420
- }
444
+ case 'Program': {
445
+ for (const childNode of node.body) {
446
+ initVariables(
447
+ /** @type {import('eslint').Rule.Node} */
448
+ (childNode),
449
+ globals,
450
+ opts,
451
+ );
452
+ }
421
453
 
422
- case 'ExpressionStatement': {
423
- initVariables(
424
- /** @type {import('eslint').Rule.Node} */
425
- (node.expression),
426
- globals,
427
- opts,
428
- );
429
- break;
430
- }
454
+ break;
455
+ }
431
456
 
432
- case 'VariableDeclaration': {
433
- for (const declaration of node.declarations) {
457
+ case 'VariableDeclaration': {
458
+ for (const declaration of node.declarations) {
434
459
  // let and const
435
- const symbol = createSymbol(
460
+ const symbol = createSymbol(
436
461
  /** @type {import('eslint').Rule.Node} */
437
- (declaration.id),
438
- globals,
439
- null,
440
- globals,
441
- );
442
- if (opts.initWindow && node.kind === 'var' && globals.props.window) {
462
+ (declaration.id),
463
+ globals,
464
+ null,
465
+ globals,
466
+ );
467
+ if (opts.initWindow && node.kind === 'var' && globals.props.window) {
443
468
  // If var, also add to window
444
- globals.props.window.props[
469
+ globals.props.window.props[
445
470
  /** @type {import('estree').Identifier} */
446
- (declaration.id).name
447
- ] = symbol;
471
+ (declaration.id).name
472
+ ] = symbol;
473
+ }
448
474
  }
449
- }
450
-
451
- break;
452
- }
453
475
 
454
- case 'ExportNamedDeclaration': {
455
- if (node.declaration) {
456
- initVariables(
457
- /** @type {import('eslint').Rule.Node} */
458
- (node.declaration),
459
- globals,
460
- opts,
461
- );
476
+ break;
462
477
  }
463
-
464
- break;
465
- }
466
478
  }
467
479
  };
468
480
 
@@ -482,168 +494,169 @@ const mapVariables = function (node, globals, opt, isExport) {
482
494
  const opts = opt || {};
483
495
  /* c8 ignore next */
484
496
  switch (node.type) {
485
- case 'Program': {
486
- if (opts.ancestorsOnly) {
487
- return false;
497
+ case 'AssignmentExpression': {
498
+ createSymbol(
499
+ /** @type {import('eslint').Rule.Node} */
500
+ (node.left),
501
+ globals,
502
+ /** @type {import('eslint').Rule.Node} */
503
+ (node.right),
504
+ );
505
+ break;
488
506
  }
489
507
 
490
- for (const childNode of node.body) {
491
- mapVariables(
492
- /** @type {import('eslint').Rule.Node} */
493
- (childNode),
508
+ case 'ClassDeclaration': {
509
+ createSymbol(
510
+ /** @type {import('eslint').Rule.Node|null} */ (node.id),
511
+ globals,
512
+ /** @type {import('eslint').Rule.Node} */ (node.body),
494
513
  globals,
495
- opts,
496
514
  );
515
+ break;
497
516
  }
498
517
 
499
- break;
500
- }
501
-
502
- case 'ExpressionStatement': {
503
- mapVariables(
504
- /** @type {import('eslint').Rule.Node} */
505
- (node.expression),
506
- globals,
507
- opts,
508
- );
509
- break;
510
- }
511
-
512
- case 'AssignmentExpression': {
513
- createSymbol(
514
- /** @type {import('eslint').Rule.Node} */
515
- (node.left),
516
- globals,
517
- /** @type {import('eslint').Rule.Node} */
518
- (node.right),
519
- );
520
- break;
521
- }
522
-
523
- case 'VariableDeclaration': {
524
- for (const declaration of node.declarations) {
525
- const isGlobal = Boolean(opts.initWindow && node.kind === 'var' && globals.props.window);
518
+ case 'ExportDefaultDeclaration': {
526
519
  const symbol = createSymbol(
527
- /** @type {import('eslint').Rule.Node} */
528
- (declaration.id),
520
+ /** @type {import('eslint').Rule.Node} */
521
+ (node.declaration),
529
522
  globals,
530
523
  /** @type {import('eslint').Rule.Node} */
531
- (declaration.init),
532
- globals,
533
- isGlobal,
524
+ (node.declaration),
534
525
  );
535
- if (symbol && isExport) {
526
+ if (symbol) {
536
527
  symbol.exported = true;
528
+ /* c8 ignore next 6 */
529
+ } else {
530
+ // if (!node.id) {
531
+ globals.ANONYMOUS_DEFAULT = /** @type {import('eslint').Rule.Node} */ (
532
+ node.declaration
533
+ );
537
534
  }
535
+
536
+ break;
538
537
  }
539
538
 
540
- break;
541
- }
539
+ case 'ExportNamedDeclaration': {
540
+ if (node.declaration) {
541
+ if (node.declaration.type === 'VariableDeclaration') {
542
+ mapVariables(
543
+ /** @type {import('eslint').Rule.Node} */
544
+ (node.declaration),
545
+ globals,
546
+ opts,
547
+ true,
548
+ );
549
+ } else {
550
+ const symbol = createSymbol(
551
+ /** @type {import('eslint').Rule.Node} */
552
+ (node.declaration),
553
+ globals,
554
+ /** @type {import('eslint').Rule.Node} */
555
+ (node.declaration),
556
+ );
557
+ /* c8 ignore next 3 */
558
+ if (symbol) {
559
+ symbol.exported = true;
560
+ }
561
+ }
562
+ }
542
563
 
543
- case 'TSTypeAliasDeclaration':
544
- case 'FunctionDeclaration': {
545
- /* c8 ignore next 10 */
546
- if (/** @type {import('estree').Identifier} */ (node.id).type === 'Identifier') {
547
- createSymbol(
564
+ for (const specifier of node.specifiers) {
565
+ mapVariables(
548
566
  /** @type {import('eslint').Rule.Node} */
549
- (node.id),
567
+ (specifier),
568
+ globals,
569
+ opts,
570
+ );
571
+ }
572
+
573
+ break;
574
+ }
575
+
576
+ case 'ExportSpecifier': {
577
+ const symbol = getSymbol(
578
+ /** @type {import('eslint').Rule.Node} */
579
+ (node.local),
550
580
  globals,
551
- node,
552
581
  globals,
553
- true,
554
582
  );
555
- }
583
+ /* c8 ignore next 3 */
584
+ if (symbol) {
585
+ symbol.exported = true;
586
+ }
556
587
 
557
- break;
558
- }
588
+ break;
589
+ }
559
590
 
560
- case 'ExportDefaultDeclaration': {
561
- const symbol = createSymbol(
562
- /** @type {import('eslint').Rule.Node} */
563
- (node.declaration),
564
- globals,
591
+ case 'ExpressionStatement': {
592
+ mapVariables(
565
593
  /** @type {import('eslint').Rule.Node} */
566
- (node.declaration),
567
- );
568
- if (symbol) {
569
- symbol.exported = true;
570
- /* c8 ignore next 6 */
571
- } else {
572
- // if (!node.id) {
573
- globals.ANONYMOUS_DEFAULT = /** @type {import('eslint').Rule.Node} */ (
574
- node.declaration
594
+ (node.expression),
595
+ globals,
596
+ opts,
575
597
  );
598
+ break;
576
599
  }
577
600
 
578
- break;
579
- }
601
+ case 'FunctionDeclaration':
580
602
 
581
- case 'ExportNamedDeclaration': {
582
- if (node.declaration) {
583
- if (node.declaration.type === 'VariableDeclaration') {
603
+ case 'TSTypeAliasDeclaration': {
604
+ /* c8 ignore next 10 */
605
+ if (/** @type {import('estree').Identifier} */ (node.id).type === 'Identifier') {
606
+ createSymbol(
607
+ /** @type {import('eslint').Rule.Node} */
608
+ (node.id),
609
+ globals,
610
+ node,
611
+ globals,
612
+ true,
613
+ );
614
+ }
615
+
616
+ break;
617
+ }
618
+
619
+ case 'Program': {
620
+ if (opts.ancestorsOnly) {
621
+ return false;
622
+ }
623
+
624
+ for (const childNode of node.body) {
584
625
  mapVariables(
585
- /** @type {import('eslint').Rule.Node} */
586
- (node.declaration),
626
+ /** @type {import('eslint').Rule.Node} */
627
+ (childNode),
587
628
  globals,
588
629
  opts,
589
- true,
590
630
  );
591
- } else {
631
+ }
632
+
633
+ break;
634
+ }
635
+
636
+ case 'VariableDeclaration': {
637
+ for (const declaration of node.declarations) {
638
+ const isGlobal = Boolean(opts.initWindow && node.kind === 'var' && globals.props.window);
592
639
  const symbol = createSymbol(
593
- /** @type {import('eslint').Rule.Node} */
594
- (node.declaration),
640
+ /** @type {import('eslint').Rule.Node} */
641
+ (declaration.id),
595
642
  globals,
596
643
  /** @type {import('eslint').Rule.Node} */
597
- (node.declaration),
644
+ (declaration.init),
645
+ globals,
646
+ isGlobal,
598
647
  );
599
- /* c8 ignore next 3 */
600
- if (symbol) {
648
+ if (symbol && isExport) {
601
649
  symbol.exported = true;
602
650
  }
603
651
  }
604
- }
605
652
 
606
- for (const specifier of node.specifiers) {
607
- mapVariables(
608
- /** @type {import('eslint').Rule.Node} */
609
- (specifier),
610
- globals,
611
- opts,
612
- );
613
- }
614
-
615
- break;
616
- }
617
-
618
- case 'ExportSpecifier': {
619
- const symbol = getSymbol(
620
- /** @type {import('eslint').Rule.Node} */
621
- (node.local),
622
- globals,
623
- globals,
624
- );
625
- /* c8 ignore next 3 */
626
- if (symbol) {
627
- symbol.exported = true;
653
+ break;
628
654
  }
629
655
 
630
- break;
631
- }
632
-
633
- case 'ClassDeclaration': {
634
- createSymbol(
635
- /** @type {import('eslint').Rule.Node|null} */ (node.id),
636
- globals,
637
- /** @type {import('eslint').Rule.Node} */ (node.body),
638
- globals,
639
- );
640
- break;
641
- }
642
-
643
- default: {
656
+ default: {
644
657
  /* c8 ignore next */
645
- return false;
646
- }
658
+ return false;
659
+ }
647
660
  }
648
661
 
649
662
  return true;
@@ -698,10 +711,10 @@ const findNode = function (node, block, cache) {
698
711
  };
699
712
 
700
713
  const exportTypes = new Set([
701
- 'ExportNamedDeclaration', 'ExportDefaultDeclaration',
714
+ 'ExportDefaultDeclaration', 'ExportNamedDeclaration',
702
715
  ]);
703
716
  const ignorableNestedTypes = new Set([
704
- 'FunctionDeclaration', 'ArrowFunctionExpression', 'FunctionExpression',
717
+ 'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression',
705
718
  ]);
706
719
 
707
720
  /**
@@ -730,25 +743,25 @@ const getExportAncestor = function (nde) {
730
743
  };
731
744
 
732
745
  const canBeExportedByAncestorType = new Set([
733
- 'TSPropertySignature',
734
- 'TSMethodSignature',
735
746
  'ClassProperty',
736
- 'PropertyDefinition',
737
747
  'Method',
748
+ 'PropertyDefinition',
749
+ 'TSMethodSignature',
750
+ 'TSPropertySignature',
738
751
  ]);
739
752
 
740
753
  const canExportChildrenType = new Set([
754
+ 'ClassBody',
755
+ 'ClassDeclaration',
756
+ 'ClassDefinition',
757
+ 'ClassExpression',
758
+ 'Program',
741
759
  'TSInterfaceBody',
742
760
  'TSInterfaceDeclaration',
743
- 'TSTypeLiteral',
744
761
  'TSTypeAliasDeclaration',
762
+ 'TSTypeLiteral',
745
763
  'TSTypeParameterInstantiation',
746
764
  'TSTypeReference',
747
- 'ClassDeclaration',
748
- 'ClassBody',
749
- 'ClassDefinition',
750
- 'ClassExpression',
751
- 'Program',
752
765
  ]);
753
766
 
754
767
  /**
@@ -891,8 +904,8 @@ const parse = function (ast, node, opt) {
891
904
  };
892
905
 
893
906
  const accessibilityNodes = new Set([
894
- 'PropertyDefinition',
895
907
  'MethodDefinition',
908
+ 'PropertyDefinition',
896
909
  ]);
897
910
 
898
911
  /**