eslint-plugin-jsdoc 52.0.1 → 52.0.3
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.
- package/dist/WarnSettings.cjs +18 -35
- package/dist/WarnSettings.cjs.map +1 -1
- package/dist/WarnSettings.js +20 -0
- package/dist/WarnSettings.js.map +1 -0
- package/dist/_virtual/rolldown_runtime.cjs +32 -0
- package/dist/_virtual/rolldown_runtime.js +11 -0
- package/dist/alignTransform.cjs +224 -305
- package/dist/alignTransform.cjs.map +1 -1
- package/dist/alignTransform.js +241 -0
- package/dist/alignTransform.js.map +1 -0
- package/dist/defaultTagOrder.cjs +132 -43
- package/dist/defaultTagOrder.cjs.map +1 -1
- package/dist/defaultTagOrder.js +134 -0
- package/dist/defaultTagOrder.js.map +1 -0
- package/dist/exportParser.cjs +478 -696
- package/dist/exportParser.cjs.map +1 -1
- package/dist/exportParser.js +518 -0
- package/dist/exportParser.js.map +1 -0
- package/dist/getDefaultTagStructureForMode.cjs +184 -288
- package/dist/getDefaultTagStructureForMode.cjs.map +1 -1
- package/dist/getDefaultTagStructureForMode.js +188 -0
- package/dist/getDefaultTagStructureForMode.js.map +1 -0
- package/dist/getJsdocProcessorPlugin.cjs +365 -532
- package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
- package/dist/getJsdocProcessorPlugin.d.cts +70 -0
- package/dist/getJsdocProcessorPlugin.d.cts.map +1 -0
- package/dist/getJsdocProcessorPlugin.d.ts +68 -90
- package/dist/getJsdocProcessorPlugin.d.ts.map +1 -1
- package/dist/getJsdocProcessorPlugin.js +383 -0
- package/dist/getJsdocProcessorPlugin.js.map +1 -0
- package/dist/index.cjs +398 -383
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +11 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +425 -0
- package/dist/index.js.map +1 -0
- package/dist/iterateJsdoc.cjs +1528 -1988
- package/dist/iterateJsdoc.cjs.map +1 -1
- package/dist/iterateJsdoc.d.cts +471 -0
- package/dist/iterateJsdoc.d.cts.map +1 -0
- package/dist/iterateJsdoc.d.ts +358 -349
- package/dist/iterateJsdoc.d.ts.map +1 -1
- package/dist/iterateJsdoc.js +1617 -0
- package/dist/iterateJsdoc.js.map +1 -0
- package/dist/jsdocUtils.cjs +1009 -1376
- package/dist/jsdocUtils.cjs.map +1 -1
- package/dist/jsdocUtils.js +1123 -0
- package/dist/jsdocUtils.js.map +1 -0
- package/dist/rules/checkAccess.cjs +29 -36
- package/dist/rules/checkAccess.cjs.map +1 -1
- package/dist/rules/checkAccess.js +33 -0
- package/dist/rules/checkAccess.js.map +1 -0
- package/dist/rules/checkAlignment.cjs +41 -54
- package/dist/rules/checkAlignment.cjs.map +1 -1
- package/dist/rules/checkAlignment.js +47 -0
- package/dist/rules/checkAlignment.js.map +1 -0
- package/dist/rules/checkExamples.cjs +327 -484
- package/dist/rules/checkExamples.cjs.map +1 -1
- package/dist/rules/checkExamples.js +348 -0
- package/dist/rules/checkExamples.js.map +1 -0
- package/dist/rules/checkIndentation.cjs +50 -65
- package/dist/rules/checkIndentation.cjs.map +1 -1
- package/dist/rules/checkIndentation.js +59 -0
- package/dist/rules/checkIndentation.js.map +1 -0
- package/dist/rules/checkLineAlignment.cjs +220 -311
- package/dist/rules/checkLineAlignment.cjs.map +1 -1
- package/dist/rules/checkLineAlignment.js +229 -0
- package/dist/rules/checkLineAlignment.js.map +1 -0
- package/dist/rules/checkParamNames.cjs +227 -335
- package/dist/rules/checkParamNames.cjs.map +1 -1
- package/dist/rules/checkParamNames.js +237 -0
- package/dist/rules/checkParamNames.js.map +1 -0
- package/dist/rules/checkPropertyNames.cjs +78 -106
- package/dist/rules/checkPropertyNames.cjs.map +1 -1
- package/dist/rules/checkPropertyNames.js +88 -0
- package/dist/rules/checkPropertyNames.js.map +1 -0
- package/dist/rules/checkSyntax.cjs +21 -34
- package/dist/rules/checkSyntax.cjs.map +1 -1
- package/dist/rules/checkSyntax.js +25 -0
- package/dist/rules/checkSyntax.js.map +1 -0
- package/dist/rules/checkTagNames.cjs +188 -210
- package/dist/rules/checkTagNames.cjs.map +1 -1
- package/dist/rules/checkTagNames.js +191 -0
- package/dist/rules/checkTagNames.js.map +1 -0
- package/dist/rules/checkTemplateNames.cjs +121 -178
- package/dist/rules/checkTemplateNames.cjs.map +1 -1
- package/dist/rules/checkTemplateNames.js +124 -0
- package/dist/rules/checkTemplateNames.js.map +1 -0
- package/dist/rules/checkTypes.cjs +291 -385
- package/dist/rules/checkTypes.cjs.map +1 -1
- package/dist/rules/checkTypes.js +299 -0
- package/dist/rules/checkTypes.js.map +1 -0
- package/dist/rules/checkValues.cjs +100 -146
- package/dist/rules/checkValues.cjs.map +1 -1
- package/dist/rules/checkValues.js +103 -0
- package/dist/rules/checkValues.js.map +1 -0
- package/dist/rules/convertToJsdocComments.cjs +228 -306
- package/dist/rules/convertToJsdocComments.cjs.map +1 -1
- package/dist/rules/convertToJsdocComments.js +231 -0
- package/dist/rules/convertToJsdocComments.js.map +1 -0
- package/dist/rules/emptyTags.cjs +62 -72
- package/dist/rules/emptyTags.cjs.map +1 -1
- package/dist/rules/emptyTags.js +67 -0
- package/dist/rules/emptyTags.js.map +1 -0
- package/dist/rules/implementsOnClasses.cjs +36 -56
- package/dist/rules/implementsOnClasses.cjs.map +1 -1
- package/dist/rules/implementsOnClasses.js +40 -0
- package/dist/rules/implementsOnClasses.js.map +1 -0
- package/dist/rules/importsAsDependencies.cjs +62 -99
- package/dist/rules/importsAsDependencies.cjs.map +1 -1
- package/dist/rules/importsAsDependencies.js +68 -0
- package/dist/rules/importsAsDependencies.js.map +1 -0
- package/dist/rules/informativeDocs.cjs +105 -142
- package/dist/rules/informativeDocs.cjs.map +1 -1
- package/dist/rules/informativeDocs.js +110 -0
- package/dist/rules/informativeDocs.js.map +1 -0
- package/dist/rules/linesBeforeBlock.cjs +70 -105
- package/dist/rules/linesBeforeBlock.cjs.map +1 -1
- package/dist/rules/linesBeforeBlock.js +75 -0
- package/dist/rules/linesBeforeBlock.js.map +1 -0
- package/dist/rules/matchDescription.cjs +160 -222
- package/dist/rules/matchDescription.cjs.map +1 -1
- package/dist/rules/matchDescription.js +167 -0
- package/dist/rules/matchDescription.js.map +1 -0
- package/dist/rules/matchName.cjs +73 -128
- package/dist/rules/matchName.cjs.map +1 -1
- package/dist/rules/matchName.js +77 -0
- package/dist/rules/matchName.js.map +1 -0
- package/dist/rules/multilineBlocks.cjs +235 -352
- package/dist/rules/multilineBlocks.cjs.map +1 -1
- package/dist/rules/multilineBlocks.js +245 -0
- package/dist/rules/multilineBlocks.js.map +1 -0
- package/dist/rules/noBadBlocks.cjs +63 -86
- package/dist/rules/noBadBlocks.cjs.map +1 -1
- package/dist/rules/noBadBlocks.js +68 -0
- package/dist/rules/noBadBlocks.js.map +1 -0
- package/dist/rules/noBlankBlockDescriptions.cjs +35 -57
- package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -1
- package/dist/rules/noBlankBlockDescriptions.js +41 -0
- package/dist/rules/noBlankBlockDescriptions.js.map +1 -0
- package/dist/rules/noBlankBlocks.cjs +26 -48
- package/dist/rules/noBlankBlocks.cjs.map +1 -1
- package/dist/rules/noBlankBlocks.js +30 -0
- package/dist/rules/noBlankBlocks.js.map +1 -0
- package/dist/rules/noDefaults.cjs +52 -79
- package/dist/rules/noDefaults.cjs.map +1 -1
- package/dist/rules/noDefaults.js +56 -0
- package/dist/rules/noDefaults.js.map +1 -0
- package/dist/rules/noMissingSyntax.cjs +115 -165
- package/dist/rules/noMissingSyntax.cjs.map +1 -1
- package/dist/rules/noMissingSyntax.js +126 -0
- package/dist/rules/noMissingSyntax.js.map +1 -0
- package/dist/rules/noMultiAsterisks.cjs +48 -89
- package/dist/rules/noMultiAsterisks.cjs.map +1 -1
- package/dist/rules/noMultiAsterisks.js +58 -0
- package/dist/rules/noMultiAsterisks.js.map +1 -0
- package/dist/rules/noRestrictedSyntax.cjs +45 -79
- package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
- package/dist/rules/noRestrictedSyntax.js +49 -0
- package/dist/rules/noRestrictedSyntax.js.map +1 -0
- package/dist/rules/noTypes.cjs +59 -80
- package/dist/rules/noTypes.cjs.map +1 -1
- package/dist/rules/noTypes.js +65 -0
- package/dist/rules/noTypes.js.map +1 -0
- package/dist/rules/noUndefinedTypes.cjs +297 -388
- package/dist/rules/noUndefinedTypes.cjs.map +1 -1
- package/dist/rules/noUndefinedTypes.js +303 -0
- package/dist/rules/noUndefinedTypes.js.map +1 -0
- package/dist/rules/requireAsteriskPrefix.cjs +108 -159
- package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
- package/dist/rules/requireAsteriskPrefix.js +112 -0
- package/dist/rules/requireAsteriskPrefix.js.map +1 -0
- package/dist/rules/requireDescription.cjs +89 -129
- package/dist/rules/requireDescription.cjs.map +1 -1
- package/dist/rules/requireDescription.js +95 -0
- package/dist/rules/requireDescription.js.map +1 -0
- package/dist/rules/requireDescriptionCompleteSentence.cjs +201 -262
- package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
- package/dist/rules/requireDescriptionCompleteSentence.js +220 -0
- package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -0
- package/dist/rules/requireExample.cjs +73 -104
- package/dist/rules/requireExample.cjs.map +1 -1
- package/dist/rules/requireExample.js +77 -0
- package/dist/rules/requireExample.js.map +1 -0
- package/dist/rules/requireFileOverview.cjs +75 -129
- package/dist/rules/requireFileOverview.cjs.map +1 -1
- package/dist/rules/requireFileOverview.js +81 -0
- package/dist/rules/requireFileOverview.js.map +1 -0
- package/dist/rules/requireHyphenBeforeParamDescription.cjs +85 -133
- package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
- package/dist/rules/requireHyphenBeforeParamDescription.js +89 -0
- package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -0
- package/dist/rules/requireJsdoc.cjs +384 -557
- package/dist/rules/requireJsdoc.cjs.map +1 -1
- package/dist/rules/requireJsdoc.js +404 -0
- package/dist/rules/requireJsdoc.js.map +1 -0
- package/dist/rules/requireParam.cjs +336 -526
- package/dist/rules/requireParam.cjs.map +1 -1
- package/dist/rules/requireParam.js +344 -0
- package/dist/rules/requireParam.js.map +1 -0
- package/dist/rules/requireParamDescription.cjs +55 -80
- package/dist/rules/requireParamDescription.cjs.map +1 -1
- package/dist/rules/requireParamDescription.js +59 -0
- package/dist/rules/requireParamDescription.js.map +1 -0
- package/dist/rules/requireParamName.cjs +32 -50
- package/dist/rules/requireParamName.cjs.map +1 -1
- package/dist/rules/requireParamName.js +36 -0
- package/dist/rules/requireParamName.js.map +1 -0
- package/dist/rules/requireParamType.cjs +55 -80
- package/dist/rules/requireParamType.cjs.map +1 -1
- package/dist/rules/requireParamType.js +59 -0
- package/dist/rules/requireParamType.js.map +1 -0
- package/dist/rules/requireProperty.cjs +31 -42
- package/dist/rules/requireProperty.cjs.map +1 -1
- package/dist/rules/requireProperty.js +35 -0
- package/dist/rules/requireProperty.js.map +1 -0
- package/dist/rules/requirePropertyDescription.cjs +17 -25
- package/dist/rules/requirePropertyDescription.cjs.map +1 -1
- package/dist/rules/requirePropertyDescription.js +21 -0
- package/dist/rules/requirePropertyDescription.js.map +1 -0
- package/dist/rules/requirePropertyName.cjs +17 -25
- package/dist/rules/requirePropertyName.cjs.map +1 -1
- package/dist/rules/requirePropertyName.js +21 -0
- package/dist/rules/requirePropertyName.js.map +1 -0
- package/dist/rules/requirePropertyType.cjs +17 -25
- package/dist/rules/requirePropertyType.cjs.map +1 -1
- package/dist/rules/requirePropertyType.js +21 -0
- package/dist/rules/requirePropertyType.js.map +1 -0
- package/dist/rules/requireReturns.cjs +125 -203
- package/dist/rules/requireReturns.cjs.map +1 -1
- package/dist/rules/requireReturns.js +131 -0
- package/dist/rules/requireReturns.js.map +1 -0
- package/dist/rules/requireReturnsCheck.cjs +60 -103
- package/dist/rules/requireReturnsCheck.cjs.map +1 -1
- package/dist/rules/requireReturnsCheck.js +66 -0
- package/dist/rules/requireReturnsCheck.js.map +1 -0
- package/dist/rules/requireReturnsDescription.cjs +39 -54
- package/dist/rules/requireReturnsDescription.cjs.map +1 -1
- package/dist/rules/requireReturnsDescription.js +43 -0
- package/dist/rules/requireReturnsDescription.js.map +1 -0
- package/dist/rules/requireReturnsType.cjs +32 -50
- package/dist/rules/requireReturnsType.cjs.map +1 -1
- package/dist/rules/requireReturnsType.js +36 -0
- package/dist/rules/requireReturnsType.js.map +1 -0
- package/dist/rules/requireTemplate.cjs +119 -178
- package/dist/rules/requireTemplate.cjs.map +1 -1
- package/dist/rules/requireTemplate.js +122 -0
- package/dist/rules/requireTemplate.js.map +1 -0
- package/dist/rules/requireThrows.cjs +61 -95
- package/dist/rules/requireThrows.cjs.map +1 -1
- package/dist/rules/requireThrows.js +67 -0
- package/dist/rules/requireThrows.js.map +1 -0
- package/dist/rules/requireYields.cjs +106 -166
- package/dist/rules/requireYields.cjs.map +1 -1
- package/dist/rules/requireYields.js +115 -0
- package/dist/rules/requireYields.js.map +1 -0
- package/dist/rules/requireYieldsCheck.cjs +96 -152
- package/dist/rules/requireYieldsCheck.cjs.map +1 -1
- package/dist/rules/requireYieldsCheck.js +105 -0
- package/dist/rules/requireYieldsCheck.js.map +1 -0
- package/dist/rules/sortTags.cjs +258 -444
- package/dist/rules/sortTags.cjs.map +1 -1
- package/dist/rules/sortTags.js +262 -0
- package/dist/rules/sortTags.js.map +1 -0
- package/dist/rules/tagLines.cjs +179 -266
- package/dist/rules/tagLines.cjs.map +1 -1
- package/dist/rules/tagLines.js +183 -0
- package/dist/rules/tagLines.js.map +1 -0
- package/dist/rules/textEscaping.cjs +92 -127
- package/dist/rules/textEscaping.cjs.map +1 -1
- package/dist/rules/textEscaping.js +102 -0
- package/dist/rules/textEscaping.js.map +1 -0
- package/dist/rules/validTypes.cjs +252 -265
- package/dist/rules/validTypes.cjs.map +1 -1
- package/dist/rules/validTypes.js +259 -0
- package/dist/rules/validTypes.js.map +1 -0
- package/dist/tagNames.cjs +134 -170
- package/dist/tagNames.cjs.map +1 -1
- package/dist/tagNames.js +144 -0
- package/dist/tagNames.js.map +1 -0
- package/dist/utils/hasReturnValue.cjs +246 -474
- package/dist/utils/hasReturnValue.cjs.map +1 -1
- package/dist/utils/hasReturnValue.js +265 -0
- package/dist/utils/hasReturnValue.js.map +1 -0
- package/package.json +48 -38
- package/dist/generateRule.cjs +0 -242
- package/dist/generateRule.cjs.map +0 -1
- package/src/WarnSettings.js +0 -34
- package/src/alignTransform.js +0 -358
- package/src/defaultTagOrder.js +0 -169
- package/src/exportParser.js +0 -978
- package/src/getDefaultTagStructureForMode.js +0 -969
- package/src/getJsdocProcessorPlugin.js +0 -652
- package/src/index.js +0 -530
- package/src/iterateJsdoc.js +0 -2518
- package/src/jsdocUtils.js +0 -1896
- package/src/rules/checkAccess.js +0 -45
- package/src/rules/checkAlignment.js +0 -63
- package/src/rules/checkExamples.js +0 -589
- package/src/rules/checkIndentation.js +0 -75
- package/src/rules/checkLineAlignment.js +0 -372
- package/src/rules/checkParamNames.js +0 -474
- package/src/rules/checkPropertyNames.js +0 -152
- package/src/rules/checkSyntax.js +0 -30
- package/src/rules/checkTagNames.js +0 -314
- package/src/rules/checkTemplateNames.js +0 -204
- package/src/rules/checkTypes.js +0 -535
- package/src/rules/checkValues.js +0 -248
- package/src/rules/convertToJsdocComments.js +0 -398
- package/src/rules/emptyTags.js +0 -98
- package/src/rules/implementsOnClasses.js +0 -64
- package/src/rules/importsAsDependencies.js +0 -133
- package/src/rules/informativeDocs.js +0 -189
- package/src/rules/linesBeforeBlock.js +0 -134
- package/src/rules/matchDescription.js +0 -286
- package/src/rules/matchName.js +0 -151
- package/src/rules/multilineBlocks.js +0 -493
- package/src/rules/noBadBlocks.js +0 -119
- package/src/rules/noBlankBlockDescriptions.js +0 -69
- package/src/rules/noBlankBlocks.js +0 -53
- package/src/rules/noDefaults.js +0 -85
- package/src/rules/noMissingSyntax.js +0 -195
- package/src/rules/noMultiAsterisks.js +0 -134
- package/src/rules/noRestrictedSyntax.js +0 -91
- package/src/rules/noTypes.js +0 -93
- package/src/rules/noUndefinedTypes.js +0 -543
- package/src/rules/requireAsteriskPrefix.js +0 -190
- package/src/rules/requireDescription.js +0 -161
- package/src/rules/requireDescriptionCompleteSentence.js +0 -335
- package/src/rules/requireExample.js +0 -118
- package/src/rules/requireFileOverview.js +0 -154
- package/src/rules/requireHyphenBeforeParamDescription.js +0 -176
- package/src/rules/requireJsdoc.js +0 -743
- package/src/rules/requireParam.js +0 -602
- package/src/rules/requireParamDescription.js +0 -89
- package/src/rules/requireParamName.js +0 -55
- package/src/rules/requireParamType.js +0 -89
- package/src/rules/requireProperty.js +0 -48
- package/src/rules/requirePropertyDescription.js +0 -25
- package/src/rules/requirePropertyName.js +0 -25
- package/src/rules/requirePropertyType.js +0 -25
- package/src/rules/requireReturns.js +0 -238
- package/src/rules/requireReturnsCheck.js +0 -145
- package/src/rules/requireReturnsDescription.js +0 -59
- package/src/rules/requireReturnsType.js +0 -51
- package/src/rules/requireTemplate.js +0 -201
- package/src/rules/requireThrows.js +0 -111
- package/src/rules/requireYields.js +0 -216
- package/src/rules/requireYieldsCheck.js +0 -208
- package/src/rules/sortTags.js +0 -558
- package/src/rules/tagLines.js +0 -359
- package/src/rules/textEscaping.js +0 -154
- package/src/rules/validTypes.js +0 -401
- package/src/tagNames.js +0 -238
- package/src/utils/hasReturnValue.js +0 -572
package/dist/exportParser.cjs
CHANGED
|
@@ -1,737 +1,519 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _jsdoccomment = require("@es-joy/jsdoccomment");
|
|
8
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
-
const debug = (0, _debug.default)('requireExportJsdoc');
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const __es_joy_jsdoccomment = require_rolldown_runtime.__toESM(require("@es-joy/jsdoccomment"));
|
|
3
|
+
const debug = require_rolldown_runtime.__toESM(require("debug"));
|
|
11
4
|
|
|
5
|
+
//#region src/exportParser.js
|
|
6
|
+
const debug$1 = (0, debug.default)("requireExportJsdoc");
|
|
12
7
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
* @typedef {{
|
|
9
|
+
* value: string
|
|
10
|
+
* }} ValueObject
|
|
11
|
+
*/
|
|
18
12
|
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
* @typedef {{
|
|
14
|
+
* type?: string,
|
|
15
|
+
* value?: ValueObject|import('eslint').Rule.Node|import('@typescript-eslint/types').TSESTree.Node,
|
|
16
|
+
* props: {
|
|
17
|
+
* [key: string]: CreatedNode|null,
|
|
18
|
+
* },
|
|
19
|
+
* special?: true,
|
|
20
|
+
* globalVars?: CreatedNode,
|
|
21
|
+
* exported?: boolean,
|
|
22
|
+
* ANONYMOUS_DEFAULT?: import('eslint').Rule.Node
|
|
23
|
+
* }} CreatedNode
|
|
24
|
+
*/
|
|
32
25
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const createNode = function
|
|
36
|
-
|
|
37
|
-
props: {}
|
|
38
|
-
};
|
|
26
|
+
* @returns {CreatedNode}
|
|
27
|
+
*/
|
|
28
|
+
const createNode = function() {
|
|
29
|
+
return { props: {} };
|
|
39
30
|
};
|
|
40
|
-
|
|
41
31
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const getSymbolValue = function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (symbol.type === 'literal') {
|
|
53
|
-
return /** @type {ValueObject} */symbol.value.value;
|
|
54
|
-
}
|
|
55
|
-
/* c8 ignore next 2 */
|
|
56
|
-
// eslint-disable-next-line @stylistic/padding-line-between-statements -- c8
|
|
57
|
-
return null;
|
|
32
|
+
* @param {CreatedNode|null} symbol
|
|
33
|
+
* @returns {string|null}
|
|
34
|
+
*/
|
|
35
|
+
const getSymbolValue = function(symbol) {
|
|
36
|
+
/* c8 ignore next 3 */
|
|
37
|
+
if (!symbol) return null;
|
|
38
|
+
/* c8 ignore else */
|
|
39
|
+
if (symbol.type === "literal") return symbol.value.value;
|
|
40
|
+
/* c8 ignore next 2 */
|
|
41
|
+
return null;
|
|
58
42
|
};
|
|
59
|
-
|
|
60
43
|
/**
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const getIdentifier = function
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// As scopes are not currently supported, they are not traversed upwards recursively
|
|
83
|
-
if (block.props[node.name]) {
|
|
84
|
-
return block.props[node.name];
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Seems this will only be entered once scopes added and entered
|
|
88
|
-
/* c8 ignore next 3 */
|
|
89
|
-
if (globals.props[node.name]) {
|
|
90
|
-
return globals.props[node.name];
|
|
91
|
-
}
|
|
92
|
-
return null;
|
|
44
|
+
*
|
|
45
|
+
* @param {import('estree').Identifier} node
|
|
46
|
+
* @param {CreatedNode} globals
|
|
47
|
+
* @param {CreatedNode} scope
|
|
48
|
+
* @param {SymbolOptions} opts
|
|
49
|
+
* @returns {CreatedNode|null}
|
|
50
|
+
*/
|
|
51
|
+
const getIdentifier = function(node, globals, scope, opts) {
|
|
52
|
+
if (opts.simpleIdentifier) {
|
|
53
|
+
const identifierLiteral = createNode();
|
|
54
|
+
identifierLiteral.type = "literal";
|
|
55
|
+
identifierLiteral.value = { value: node.name };
|
|
56
|
+
return identifierLiteral;
|
|
57
|
+
}
|
|
58
|
+
/* c8 ignore next */
|
|
59
|
+
const block = scope || globals;
|
|
60
|
+
if (block.props[node.name]) return block.props[node.name];
|
|
61
|
+
/* c8 ignore next 3 */
|
|
62
|
+
if (globals.props[node.name]) return globals.props[node.name];
|
|
63
|
+
return null;
|
|
93
64
|
};
|
|
94
|
-
|
|
95
65
|
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
66
|
+
* @callback CreateSymbol
|
|
67
|
+
* @param {import('eslint').Rule.Node|null} node
|
|
68
|
+
* @param {CreatedNode} globals
|
|
69
|
+
* @param {import('eslint').Rule.Node|import('@typescript-eslint/types').TSESTree.Node|null} value
|
|
70
|
+
* @param {CreatedNode} [scope]
|
|
71
|
+
* @param {boolean|SymbolOptions} [isGlobal]
|
|
72
|
+
* @returns {CreatedNode|null}
|
|
73
|
+
*/
|
|
105
74
|
/** @type {CreateSymbol} */
|
|
106
|
-
let createSymbol;
|
|
107
|
-
|
|
108
|
-
/* eslint-disable complexity -- Temporary */
|
|
109
|
-
|
|
75
|
+
let createSymbol;
|
|
110
76
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
77
|
+
* @typedef {{
|
|
78
|
+
* simpleIdentifier?: boolean
|
|
79
|
+
* }} SymbolOptions
|
|
80
|
+
*/
|
|
116
81
|
/**
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const getSymbol = function
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
/* c8 ignore else */
|
|
199
|
-
if (obj && propertyValue && obj.props[propertyValue]) {
|
|
200
|
-
const block = obj.props[propertyValue];
|
|
201
|
-
return block;
|
|
202
|
-
}
|
|
203
|
-
/* c8 ignore next 11 */
|
|
204
|
-
/*
|
|
205
|
-
if (opts.createMissingProps && propertyValue) {
|
|
206
|
-
obj.props[propertyValue] = createNode();
|
|
207
|
-
return obj.props[propertyValue];
|
|
208
|
-
}
|
|
209
|
-
*/
|
|
210
|
-
// eslint-disable-next-line @stylistic/padding-line-between-statements -- c8
|
|
211
|
-
debug(`MemberExpression: Missing property ${/** @type {import('estree').PrivateIdentifier} */node.property.name}`);
|
|
212
|
-
/* c8 ignore next 2 */
|
|
213
|
-
return null;
|
|
214
|
-
}
|
|
215
|
-
case 'ObjectExpression':
|
|
216
|
-
{
|
|
217
|
-
const val = createNode();
|
|
218
|
-
val.type = 'object';
|
|
219
|
-
for (const prop of node.properties) {
|
|
220
|
-
if ([
|
|
221
|
-
// @babel/eslint-parser
|
|
222
|
-
'ExperimentalSpreadProperty',
|
|
223
|
-
// typescript-eslint, espree, acorn, etc.
|
|
224
|
-
'SpreadElement'].includes(prop.type)) {
|
|
225
|
-
continue;
|
|
226
|
-
}
|
|
227
|
-
const propVal = getSymbol(/** @type {import('eslint').Rule.Node} */
|
|
228
|
-
/** @type {import('estree').Property} */
|
|
229
|
-
prop.value, globals, scope, opts);
|
|
230
|
-
/* c8 ignore next 8 */
|
|
231
|
-
if (propVal) {
|
|
232
|
-
val.props[/** @type {import('estree').PrivateIdentifier} */
|
|
233
|
-
(/** @type {import('estree').Property} */prop.key).name] = propVal;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return val;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
/* c8 ignore next 2 */
|
|
240
|
-
// eslint-disable-next-line @stylistic/padding-line-between-statements -- c8
|
|
241
|
-
return null;
|
|
82
|
+
*
|
|
83
|
+
* @param {import('eslint').Rule.Node|import('@typescript-eslint/types').TSESTree.Node} node
|
|
84
|
+
* @param {CreatedNode} globals
|
|
85
|
+
* @param {CreatedNode} scope
|
|
86
|
+
* @param {SymbolOptions} [opt]
|
|
87
|
+
* @returns {CreatedNode|null}
|
|
88
|
+
*/
|
|
89
|
+
const getSymbol = function(node, globals, scope, opt) {
|
|
90
|
+
const opts = opt || {};
|
|
91
|
+
/* c8 ignore next */
|
|
92
|
+
switch (node.type) {
|
|
93
|
+
case "ArrowFunctionExpression":
|
|
94
|
+
case "ClassDeclaration":
|
|
95
|
+
case "FunctionDeclaration":
|
|
96
|
+
case "FunctionExpression":
|
|
97
|
+
case "TSEnumDeclaration":
|
|
98
|
+
case "TSInterfaceDeclaration":
|
|
99
|
+
case "TSTypeAliasDeclaration": {
|
|
100
|
+
const val = createNode();
|
|
101
|
+
val.props.prototype = createNode();
|
|
102
|
+
val.props.prototype.type = "object";
|
|
103
|
+
val.type = "object";
|
|
104
|
+
val.value = node;
|
|
105
|
+
return val;
|
|
106
|
+
}
|
|
107
|
+
case "AssignmentExpression": return createSymbol(node.left, globals, node.right, scope, opts);
|
|
108
|
+
case "ClassBody": {
|
|
109
|
+
const val = createNode();
|
|
110
|
+
for (const method of node.body) {
|
|
111
|
+
if (!("key" in method)) continue;
|
|
112
|
+
val.props[method.key.name] = createNode();
|
|
113
|
+
/** @type {{[key: string]: CreatedNode}} */ val.props[method.key.name].type = "object";
|
|
114
|
+
/** @type {{[key: string]: CreatedNode}} */ val.props[method.key.name].value = method.value;
|
|
115
|
+
}
|
|
116
|
+
val.type = "object";
|
|
117
|
+
val.value = node.parent;
|
|
118
|
+
return val;
|
|
119
|
+
}
|
|
120
|
+
case "ClassExpression": return getSymbol(node.body, globals, scope, opts);
|
|
121
|
+
case "Identifier": return getIdentifier(node, globals, scope, opts);
|
|
122
|
+
case "Literal": {
|
|
123
|
+
const val = createNode();
|
|
124
|
+
val.type = "literal";
|
|
125
|
+
val.value = node;
|
|
126
|
+
return val;
|
|
127
|
+
}
|
|
128
|
+
case "MemberExpression": {
|
|
129
|
+
const obj = getSymbol(node.object, globals, scope, opts);
|
|
130
|
+
const propertySymbol = getSymbol(node.property, globals, scope, { simpleIdentifier: !node.computed });
|
|
131
|
+
const propertyValue = getSymbolValue(propertySymbol);
|
|
132
|
+
/* c8 ignore else */
|
|
133
|
+
if (obj && propertyValue && obj.props[propertyValue]) {
|
|
134
|
+
const block = obj.props[propertyValue];
|
|
135
|
+
return block;
|
|
136
|
+
}
|
|
137
|
+
/* c8 ignore next 11 */
|
|
138
|
+
debug$1(`MemberExpression: Missing property ${node.property.name}`);
|
|
139
|
+
/* c8 ignore next 2 */
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
case "ObjectExpression": {
|
|
143
|
+
const val = createNode();
|
|
144
|
+
val.type = "object";
|
|
145
|
+
for (const prop of node.properties) {
|
|
146
|
+
if (["ExperimentalSpreadProperty", "SpreadElement"].includes(prop.type)) continue;
|
|
147
|
+
const propVal = getSymbol(
|
|
148
|
+
/** @type {import('estree').Property} */
|
|
149
|
+
prop.value,
|
|
150
|
+
globals,
|
|
151
|
+
scope,
|
|
152
|
+
opts
|
|
153
|
+
);
|
|
154
|
+
/* c8 ignore next 8 */
|
|
155
|
+
if (propVal) val.props[prop.key.name] = propVal;
|
|
156
|
+
}
|
|
157
|
+
return val;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/* c8 ignore next 2 */
|
|
161
|
+
return null;
|
|
242
162
|
};
|
|
243
|
-
|
|
244
163
|
/**
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const createBlockSymbol = function
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
globals.props.window.props[name] = value;
|
|
257
|
-
}
|
|
164
|
+
*
|
|
165
|
+
* @param {CreatedNode} block
|
|
166
|
+
* @param {string} name
|
|
167
|
+
* @param {CreatedNode|null} value
|
|
168
|
+
* @param {CreatedNode} globals
|
|
169
|
+
* @param {boolean|SymbolOptions|undefined} isGlobal
|
|
170
|
+
* @returns {void}
|
|
171
|
+
*/
|
|
172
|
+
const createBlockSymbol = function(block, name, value, globals, isGlobal) {
|
|
173
|
+
block.props[name] = value;
|
|
174
|
+
if (isGlobal && globals.props.window && globals.props.window.special) globals.props.window.props[name] = value;
|
|
258
175
|
};
|
|
259
|
-
createSymbol = function
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
symbol = getSymbol(/** @type {import('eslint').Rule.Node} */nde.object, globals, block);
|
|
313
|
-
const propertySymbol = getSymbol(/** @type {import('eslint').Rule.Node} */nde.property, globals, block, {
|
|
314
|
-
simpleIdentifier: !nde.computed
|
|
315
|
-
});
|
|
316
|
-
const propertyValue = getSymbolValue(propertySymbol);
|
|
317
|
-
if (symbol && propertyValue) {
|
|
318
|
-
createBlockSymbol(symbol, propertyValue, getSymbol(/** @type {import('eslint').Rule.Node} */
|
|
319
|
-
value, globals, block), globals, isGlobal);
|
|
320
|
-
return symbol.props[propertyValue];
|
|
321
|
-
}
|
|
322
|
-
debug('MemberExpression: Missing symbol: %s', /** @type {import('estree').Identifier} */nde.property.name);
|
|
323
|
-
break;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
return null;
|
|
176
|
+
createSymbol = function(node, globals, value, scope, isGlobal) {
|
|
177
|
+
const block = scope || globals;
|
|
178
|
+
/* c8 ignore next 3 */
|
|
179
|
+
if (!node) return null;
|
|
180
|
+
let symbol;
|
|
181
|
+
switch (node.type) {
|
|
182
|
+
case "ClassDeclaration":
|
|
183
|
+
case "FunctionDeclaration":
|
|
184
|
+
case "TSEnumDeclaration":
|
|
185
|
+
case "TSInterfaceDeclaration":
|
|
186
|
+
case "TSTypeAliasDeclaration": {
|
|
187
|
+
const nde = node;
|
|
188
|
+
/* c8 ignore else */
|
|
189
|
+
if (nde.id && nde.id.type === "Identifier") return createSymbol(nde.id, globals, node, globals);
|
|
190
|
+
/* c8 ignore next 3 */
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
case "Identifier": {
|
|
194
|
+
const nde = node;
|
|
195
|
+
if (value) {
|
|
196
|
+
const valueSymbol = getSymbol(value, globals, block);
|
|
197
|
+
/* c8 ignore else */
|
|
198
|
+
if (valueSymbol) {
|
|
199
|
+
createBlockSymbol(block, nde.name, valueSymbol, globals, isGlobal);
|
|
200
|
+
return block.props[nde.name];
|
|
201
|
+
}
|
|
202
|
+
/* c8 ignore next 2 */
|
|
203
|
+
debug$1("Identifier: Missing value symbol for %s", nde.name);
|
|
204
|
+
} else {
|
|
205
|
+
createBlockSymbol(block, nde.name, createNode(), globals, isGlobal);
|
|
206
|
+
return block.props[nde.name];
|
|
207
|
+
}
|
|
208
|
+
/* c8 ignore next 3 */
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
case "MemberExpression": {
|
|
212
|
+
const nde = node;
|
|
213
|
+
symbol = getSymbol(nde.object, globals, block);
|
|
214
|
+
const propertySymbol = getSymbol(nde.property, globals, block, { simpleIdentifier: !nde.computed });
|
|
215
|
+
const propertyValue = getSymbolValue(propertySymbol);
|
|
216
|
+
if (symbol && propertyValue) {
|
|
217
|
+
createBlockSymbol(symbol, propertyValue, getSymbol(value, globals, block), globals, isGlobal);
|
|
218
|
+
return symbol.props[propertyValue];
|
|
219
|
+
}
|
|
220
|
+
debug$1(
|
|
221
|
+
"MemberExpression: Missing symbol: %s",
|
|
222
|
+
/** @type {import('estree').Identifier} */
|
|
223
|
+
nde.property.name
|
|
224
|
+
);
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return null;
|
|
327
229
|
};
|
|
328
|
-
|
|
329
230
|
/**
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
const initVariables = function
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
for (const childNode of node.body) {
|
|
355
|
-
initVariables(/** @type {import('eslint').Rule.Node} */
|
|
356
|
-
childNode, globals, opts);
|
|
357
|
-
}
|
|
358
|
-
break;
|
|
359
|
-
}
|
|
360
|
-
case 'VariableDeclaration':
|
|
361
|
-
{
|
|
362
|
-
for (const declaration of node.declarations) {
|
|
363
|
-
// let and const
|
|
364
|
-
const symbol = createSymbol(/** @type {import('eslint').Rule.Node} */
|
|
365
|
-
declaration.id, globals, null, globals);
|
|
366
|
-
if (opts.initWindow && node.kind === 'var' && globals.props.window) {
|
|
367
|
-
// If var, also add to window
|
|
368
|
-
globals.props.window.props[/** @type {import('estree').Identifier} */
|
|
369
|
-
declaration.id.name] = symbol;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
break;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
231
|
+
* Creates variables from variable definitions
|
|
232
|
+
* @param {import('eslint').Rule.Node} node
|
|
233
|
+
* @param {CreatedNode} globals
|
|
234
|
+
* @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opts
|
|
235
|
+
* @returns {void}
|
|
236
|
+
*/
|
|
237
|
+
const initVariables = function(node, globals, opts) {
|
|
238
|
+
switch (node.type) {
|
|
239
|
+
case "ExportNamedDeclaration":
|
|
240
|
+
if (node.declaration) initVariables(node.declaration, globals, opts);
|
|
241
|
+
break;
|
|
242
|
+
case "ExpressionStatement":
|
|
243
|
+
initVariables(node.expression, globals, opts);
|
|
244
|
+
break;
|
|
245
|
+
case "Program":
|
|
246
|
+
for (const childNode of node.body) initVariables(childNode, globals, opts);
|
|
247
|
+
break;
|
|
248
|
+
case "VariableDeclaration":
|
|
249
|
+
for (const declaration of node.declarations) {
|
|
250
|
+
const symbol = createSymbol(declaration.id, globals, null, globals);
|
|
251
|
+
if (opts.initWindow && node.kind === "var" && globals.props.window) globals.props.window.props[declaration.id.name] = symbol;
|
|
252
|
+
}
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
375
255
|
};
|
|
376
|
-
|
|
377
|
-
/* eslint-disable complexity -- Temporary */
|
|
378
|
-
|
|
379
256
|
/**
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
const mapVariables = function
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
{
|
|
444
|
-
const symbol = getSymbol(/** @type {import('eslint').Rule.Node} */
|
|
445
|
-
node.local, globals, globals);
|
|
446
|
-
/* c8 ignore next 3 */
|
|
447
|
-
if (symbol) {
|
|
448
|
-
symbol.exported = true;
|
|
449
|
-
}
|
|
450
|
-
break;
|
|
451
|
-
}
|
|
452
|
-
case 'ExpressionStatement':
|
|
453
|
-
{
|
|
454
|
-
mapVariables(/** @type {import('eslint').Rule.Node} */
|
|
455
|
-
node.expression, globals, opts);
|
|
456
|
-
break;
|
|
457
|
-
}
|
|
458
|
-
case 'FunctionDeclaration':
|
|
459
|
-
case 'TSTypeAliasDeclaration':
|
|
460
|
-
{
|
|
461
|
-
/* c8 ignore next 10 */
|
|
462
|
-
if (/** @type {import('estree').Identifier} */node.id.type === 'Identifier') {
|
|
463
|
-
createSymbol(/** @type {import('eslint').Rule.Node} */
|
|
464
|
-
node.id, globals, node, globals, true);
|
|
465
|
-
}
|
|
466
|
-
break;
|
|
467
|
-
}
|
|
468
|
-
case 'Program':
|
|
469
|
-
{
|
|
470
|
-
if (opts.ancestorsOnly) {
|
|
471
|
-
return false;
|
|
472
|
-
}
|
|
473
|
-
for (const childNode of node.body) {
|
|
474
|
-
mapVariables(/** @type {import('eslint').Rule.Node} */
|
|
475
|
-
childNode, globals, opts);
|
|
476
|
-
}
|
|
477
|
-
break;
|
|
478
|
-
}
|
|
479
|
-
case 'VariableDeclaration':
|
|
480
|
-
{
|
|
481
|
-
for (const declaration of node.declarations) {
|
|
482
|
-
const isGlobal = Boolean(opts.initWindow && node.kind === 'var' && globals.props.window);
|
|
483
|
-
const symbol = createSymbol(/** @type {import('eslint').Rule.Node} */
|
|
484
|
-
declaration.id, globals, /** @type {import('eslint').Rule.Node} */
|
|
485
|
-
declaration.init, globals, isGlobal);
|
|
486
|
-
if (symbol && isExport) {
|
|
487
|
-
symbol.exported = true;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
break;
|
|
491
|
-
}
|
|
492
|
-
default:
|
|
493
|
-
{
|
|
494
|
-
/* c8 ignore next */
|
|
495
|
-
return false;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
return true;
|
|
257
|
+
* Populates variable maps using AST
|
|
258
|
+
* @param {import('eslint').Rule.Node|import('@typescript-eslint/types').TSESTree.Node} node
|
|
259
|
+
* @param {CreatedNode} globals
|
|
260
|
+
* @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opt
|
|
261
|
+
* @param {true} [isExport]
|
|
262
|
+
* @returns {boolean}
|
|
263
|
+
*/
|
|
264
|
+
const mapVariables = function(node, globals, opt, isExport) {
|
|
265
|
+
/* c8 ignore next */
|
|
266
|
+
const opts = opt || {};
|
|
267
|
+
/* c8 ignore next */
|
|
268
|
+
switch (node.type) {
|
|
269
|
+
case "AssignmentExpression":
|
|
270
|
+
createSymbol(node.left, globals, node.right);
|
|
271
|
+
break;
|
|
272
|
+
case "ClassDeclaration":
|
|
273
|
+
createSymbol(node.id, globals, node.body, globals);
|
|
274
|
+
break;
|
|
275
|
+
case "ExportDefaultDeclaration": {
|
|
276
|
+
const symbol = createSymbol(node.declaration, globals, node.declaration);
|
|
277
|
+
if (symbol) symbol.exported = true;
|
|
278
|
+
else globals.ANONYMOUS_DEFAULT = node.declaration;
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
case "ExportNamedDeclaration":
|
|
282
|
+
if (node.declaration) if (node.declaration.type === "VariableDeclaration") mapVariables(node.declaration, globals, opts, true);
|
|
283
|
+
else {
|
|
284
|
+
const symbol = createSymbol(node.declaration, globals, node.declaration);
|
|
285
|
+
/* c8 ignore next 3 */
|
|
286
|
+
if (symbol) symbol.exported = true;
|
|
287
|
+
}
|
|
288
|
+
for (const specifier of node.specifiers) mapVariables(specifier, globals, opts);
|
|
289
|
+
break;
|
|
290
|
+
case "ExportSpecifier": {
|
|
291
|
+
const symbol = getSymbol(node.local, globals, globals);
|
|
292
|
+
/* c8 ignore next 3 */
|
|
293
|
+
if (symbol) symbol.exported = true;
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
case "ExpressionStatement":
|
|
297
|
+
mapVariables(node.expression, globals, opts);
|
|
298
|
+
break;
|
|
299
|
+
case "FunctionDeclaration":
|
|
300
|
+
case "TSTypeAliasDeclaration":
|
|
301
|
+
/* c8 ignore next 10 */
|
|
302
|
+
if (node.id.type === "Identifier") createSymbol(node.id, globals, node, globals, true);
|
|
303
|
+
break;
|
|
304
|
+
case "Program":
|
|
305
|
+
if (opts.ancestorsOnly) return false;
|
|
306
|
+
for (const childNode of node.body) mapVariables(childNode, globals, opts);
|
|
307
|
+
break;
|
|
308
|
+
case "VariableDeclaration":
|
|
309
|
+
for (const declaration of node.declarations) {
|
|
310
|
+
const isGlobal = Boolean(opts.initWindow && node.kind === "var" && globals.props.window);
|
|
311
|
+
const symbol = createSymbol(declaration.id, globals, declaration.init, globals, isGlobal);
|
|
312
|
+
if (symbol && isExport) symbol.exported = true;
|
|
313
|
+
}
|
|
314
|
+
break;
|
|
315
|
+
default:
|
|
316
|
+
/* c8 ignore next */
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
return true;
|
|
499
320
|
};
|
|
500
|
-
|
|
501
321
|
/**
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
const findNode = function
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
if (Array.isArray(propval)) {
|
|
526
|
-
/* c8 ignore next 5 */
|
|
527
|
-
if (propval.some(val => {
|
|
528
|
-
return findNode(node, val, blockCache);
|
|
529
|
-
})) {
|
|
530
|
-
return true;
|
|
531
|
-
}
|
|
532
|
-
} else if (findNode(node, propval, blockCache)) {
|
|
533
|
-
return true;
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
return false;
|
|
322
|
+
*
|
|
323
|
+
* @param {import('eslint').Rule.Node} node
|
|
324
|
+
* @param {CreatedNode|ValueObject|string|undefined|
|
|
325
|
+
* import('eslint').Rule.Node|import('@typescript-eslint/types').TSESTree.Node} block
|
|
326
|
+
* @param {(CreatedNode|ValueObject|string|
|
|
327
|
+
* import('eslint').Rule.Node|import('@typescript-eslint/types').TSESTree.Node)[]} [cache]
|
|
328
|
+
* @returns {boolean}
|
|
329
|
+
*/
|
|
330
|
+
const findNode = function(node, block, cache) {
|
|
331
|
+
let blockCache = cache || [];
|
|
332
|
+
if (!block || blockCache.includes(block)) return false;
|
|
333
|
+
blockCache = blockCache.slice();
|
|
334
|
+
blockCache.push(block);
|
|
335
|
+
if (typeof block === "object" && "type" in block && (block.type === "object" || block.type === "MethodDefinition") && block.value === node) return true;
|
|
336
|
+
if (typeof block !== "object") return false;
|
|
337
|
+
const props = "props" in block && block.props || "body" in block && block.body;
|
|
338
|
+
for (const propval of Object.values(props || {})) if (Array.isArray(propval)) {
|
|
339
|
+
/* c8 ignore next 5 */
|
|
340
|
+
if (propval.some((val) => {
|
|
341
|
+
return findNode(node, val, blockCache);
|
|
342
|
+
})) return true;
|
|
343
|
+
} else if (findNode(node, propval, blockCache)) return true;
|
|
344
|
+
return false;
|
|
537
345
|
};
|
|
538
|
-
const exportTypes = new Set([
|
|
539
|
-
const ignorableNestedTypes = new Set([
|
|
540
|
-
|
|
346
|
+
const exportTypes = new Set(["ExportDefaultDeclaration", "ExportNamedDeclaration"]);
|
|
347
|
+
const ignorableNestedTypes = new Set([
|
|
348
|
+
"ArrowFunctionExpression",
|
|
349
|
+
"FunctionDeclaration",
|
|
350
|
+
"FunctionExpression"
|
|
351
|
+
]);
|
|
541
352
|
/**
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
const getExportAncestor = function
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
}
|
|
557
|
-
node = node.parent;
|
|
558
|
-
idx++;
|
|
559
|
-
}
|
|
560
|
-
return false;
|
|
353
|
+
* @param {import('eslint').Rule.Node} nde
|
|
354
|
+
* @returns {import('eslint').Rule.Node|false}
|
|
355
|
+
*/
|
|
356
|
+
const getExportAncestor = function(nde) {
|
|
357
|
+
let node = nde;
|
|
358
|
+
let idx = 0;
|
|
359
|
+
const ignorableIfDeep = ignorableNestedTypes.has(nde?.type);
|
|
360
|
+
while (node) {
|
|
361
|
+
if (idx >= 2 && ignorableIfDeep) break;
|
|
362
|
+
if (exportTypes.has(node.type)) return node;
|
|
363
|
+
node = node.parent;
|
|
364
|
+
idx++;
|
|
365
|
+
}
|
|
366
|
+
return false;
|
|
561
367
|
};
|
|
562
|
-
const canBeExportedByAncestorType = new Set([
|
|
563
|
-
|
|
564
|
-
|
|
368
|
+
const canBeExportedByAncestorType = new Set([
|
|
369
|
+
"ClassProperty",
|
|
370
|
+
"Method",
|
|
371
|
+
"PropertyDefinition",
|
|
372
|
+
"TSMethodSignature",
|
|
373
|
+
"TSPropertySignature"
|
|
374
|
+
]);
|
|
375
|
+
const canExportChildrenType = new Set([
|
|
376
|
+
"ClassBody",
|
|
377
|
+
"ClassDeclaration",
|
|
378
|
+
"ClassDefinition",
|
|
379
|
+
"ClassExpression",
|
|
380
|
+
"Program",
|
|
381
|
+
"TSInterfaceBody",
|
|
382
|
+
"TSInterfaceDeclaration",
|
|
383
|
+
"TSTypeAliasDeclaration",
|
|
384
|
+
"TSTypeLiteral",
|
|
385
|
+
"TSTypeParameterInstantiation",
|
|
386
|
+
"TSTypeReference"
|
|
387
|
+
]);
|
|
565
388
|
/**
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
const isExportByAncestor = function
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
if (!canExportChildrenType.has(node.type)) {
|
|
579
|
-
return false;
|
|
580
|
-
}
|
|
581
|
-
node = node.parent;
|
|
582
|
-
}
|
|
583
|
-
return false;
|
|
389
|
+
* @param {import('eslint').Rule.Node} nde
|
|
390
|
+
* @returns {false|import('eslint').Rule.Node}
|
|
391
|
+
*/
|
|
392
|
+
const isExportByAncestor = function(nde) {
|
|
393
|
+
if (!canBeExportedByAncestorType.has(nde.type)) return false;
|
|
394
|
+
let node = nde.parent;
|
|
395
|
+
while (node) {
|
|
396
|
+
if (exportTypes.has(node.type)) return node;
|
|
397
|
+
if (!canExportChildrenType.has(node.type)) return false;
|
|
398
|
+
node = node.parent;
|
|
399
|
+
}
|
|
400
|
+
return false;
|
|
584
401
|
};
|
|
585
|
-
|
|
586
402
|
/**
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
const findExportedNode = function
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
blockCache.push(pval);
|
|
605
|
-
if (pval.exported && (node === pval.value || findNode(node, pval.value))) {
|
|
606
|
-
return true;
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
// No need to check `propval` for exported nodes as ESM
|
|
610
|
-
// exports are only global
|
|
611
|
-
}
|
|
612
|
-
return false;
|
|
403
|
+
*
|
|
404
|
+
* @param {CreatedNode} block
|
|
405
|
+
* @param {import('eslint').Rule.Node} node
|
|
406
|
+
* @param {CreatedNode[]} [cache] Currently unused
|
|
407
|
+
* @returns {boolean}
|
|
408
|
+
*/
|
|
409
|
+
const findExportedNode = function(block, node, cache) {
|
|
410
|
+
/* c8 ignore next 3 */
|
|
411
|
+
if (block === null) return false;
|
|
412
|
+
const blockCache = cache || [];
|
|
413
|
+
const { props } = block;
|
|
414
|
+
for (const propval of Object.values(props)) {
|
|
415
|
+
const pval = propval;
|
|
416
|
+
blockCache.push(pval);
|
|
417
|
+
if (pval.exported && (node === pval.value || findNode(node, pval.value))) return true;
|
|
418
|
+
}
|
|
419
|
+
return false;
|
|
613
420
|
};
|
|
614
|
-
|
|
615
421
|
/**
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
const isNodeExported = function
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
return true;
|
|
629
|
-
}
|
|
630
|
-
if (opt.esm && findExportedNode(globals, node)) {
|
|
631
|
-
return true;
|
|
632
|
-
}
|
|
633
|
-
return false;
|
|
422
|
+
*
|
|
423
|
+
* @param {import('eslint').Rule.Node} node
|
|
424
|
+
* @param {CreatedNode} globals
|
|
425
|
+
* @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opt
|
|
426
|
+
* @returns {boolean}
|
|
427
|
+
*/
|
|
428
|
+
const isNodeExported = function(node, globals, opt) {
|
|
429
|
+
const moduleExports = globals.props.module?.props?.exports;
|
|
430
|
+
if (opt.initModuleExports && moduleExports && findNode(node, moduleExports)) return true;
|
|
431
|
+
if (opt.initWindow && globals.props.window && findNode(node, globals.props.window)) return true;
|
|
432
|
+
if (opt.esm && findExportedNode(globals, node)) return true;
|
|
433
|
+
return false;
|
|
634
434
|
};
|
|
635
|
-
|
|
636
435
|
/**
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
const parseRecursive = function
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
return true;
|
|
647
|
-
}
|
|
648
|
-
return mapVariables(node, globalVars, opts);
|
|
436
|
+
*
|
|
437
|
+
* @param {import('eslint').Rule.Node} node
|
|
438
|
+
* @param {CreatedNode} globalVars
|
|
439
|
+
* @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opts
|
|
440
|
+
* @returns {boolean}
|
|
441
|
+
*/
|
|
442
|
+
const parseRecursive = function(node, globalVars, opts) {
|
|
443
|
+
if (node.parent && parseRecursive(node.parent, globalVars, opts)) return true;
|
|
444
|
+
return mapVariables(node, globalVars, opts);
|
|
649
445
|
};
|
|
650
|
-
|
|
651
446
|
/**
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
const parse = function
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
};
|
|
447
|
+
*
|
|
448
|
+
* @param {import('eslint').Rule.Node} ast
|
|
449
|
+
* @param {import('eslint').Rule.Node} node
|
|
450
|
+
* @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opt
|
|
451
|
+
* @returns {CreatedNode}
|
|
452
|
+
*/
|
|
453
|
+
const parse = function(ast, node, opt) {
|
|
454
|
+
/* c8 ignore next 6 */
|
|
455
|
+
const opts = opt || {
|
|
456
|
+
ancestorsOnly: false,
|
|
457
|
+
esm: true,
|
|
458
|
+
initModuleExports: true,
|
|
459
|
+
initWindow: true
|
|
460
|
+
};
|
|
461
|
+
const globalVars = createNode();
|
|
462
|
+
if (opts.initModuleExports) {
|
|
463
|
+
globalVars.props.module = createNode();
|
|
464
|
+
globalVars.props.module.props.exports = createNode();
|
|
465
|
+
globalVars.props.exports = globalVars.props.module.props.exports;
|
|
466
|
+
}
|
|
467
|
+
if (opts.initWindow) {
|
|
468
|
+
globalVars.props.window = createNode();
|
|
469
|
+
globalVars.props.window.special = true;
|
|
470
|
+
}
|
|
471
|
+
if (opts.ancestorsOnly) parseRecursive(node, globalVars, opts);
|
|
472
|
+
else {
|
|
473
|
+
initVariables(ast, globalVars, opts);
|
|
474
|
+
mapVariables(ast, globalVars, opts);
|
|
475
|
+
}
|
|
476
|
+
return {
|
|
477
|
+
globalVars,
|
|
478
|
+
props: {}
|
|
479
|
+
};
|
|
686
480
|
};
|
|
687
|
-
const accessibilityNodes = new Set([
|
|
688
|
-
|
|
481
|
+
const accessibilityNodes = new Set(["MethodDefinition", "PropertyDefinition"]);
|
|
689
482
|
/**
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
const isPrivate = node => {
|
|
695
|
-
|
|
483
|
+
*
|
|
484
|
+
* @param {import('eslint').Rule.Node} node
|
|
485
|
+
* @returns {boolean}
|
|
486
|
+
*/
|
|
487
|
+
const isPrivate = (node) => {
|
|
488
|
+
return accessibilityNodes.has(node.type) && "accessibility" in node && node.accessibility !== "public" && node.accessibility !== void 0 || "key" in node && node.key.type === "PrivateIdentifier";
|
|
696
489
|
};
|
|
697
|
-
|
|
698
490
|
/**
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
const isUncommentedExport = function
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
/**
|
|
721
|
-
* Some typescript types are not in variable map, but inherit exported (interface property and method)
|
|
722
|
-
*/
|
|
723
|
-
if (isExportByAncestor(node) && !(0, _jsdoccomment.findJSDocComment)(node, sourceCode, settings)) {
|
|
724
|
-
return true;
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
const ast = /** @type {unknown} */sourceCode.ast;
|
|
728
|
-
const parseResult = parse(/** @type {import('eslint').Rule.Node} */
|
|
729
|
-
ast, node, opt);
|
|
730
|
-
return isNodeExported(node, /** @type {CreatedNode} */parseResult.globalVars, opt);
|
|
491
|
+
*
|
|
492
|
+
* @param {import('eslint').Rule.Node} node
|
|
493
|
+
* @param {import('eslint').SourceCode} sourceCode
|
|
494
|
+
* @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opt
|
|
495
|
+
* @param {import('./iterateJsdoc.js').Settings} settings
|
|
496
|
+
* @returns {boolean}
|
|
497
|
+
*/
|
|
498
|
+
const isUncommentedExport = function(node, sourceCode, opt, settings) {
|
|
499
|
+
if (opt.esm) {
|
|
500
|
+
if (isPrivate(node) || node.parent && isPrivate(node.parent)) return false;
|
|
501
|
+
const exportNode = getExportAncestor(node);
|
|
502
|
+
if (exportNode && !(0, __es_joy_jsdoccomment.findJSDocComment)(exportNode, sourceCode, settings)) return true;
|
|
503
|
+
/**
|
|
504
|
+
* Some typescript types are not in variable map, but inherit exported (interface property and method)
|
|
505
|
+
*/
|
|
506
|
+
if (isExportByAncestor(node) && !(0, __es_joy_jsdoccomment.findJSDocComment)(node, sourceCode, settings)) return true;
|
|
507
|
+
}
|
|
508
|
+
const ast = sourceCode.ast;
|
|
509
|
+
const parseResult = parse(ast, node, opt);
|
|
510
|
+
return isNodeExported(node, parseResult.globalVars, opt);
|
|
731
511
|
};
|
|
732
|
-
var
|
|
733
|
-
|
|
734
|
-
|
|
512
|
+
var exportParser_default = {
|
|
513
|
+
isUncommentedExport,
|
|
514
|
+
parse
|
|
735
515
|
};
|
|
736
|
-
|
|
516
|
+
|
|
517
|
+
//#endregion
|
|
518
|
+
exports.default = exportParser_default;
|
|
737
519
|
//# sourceMappingURL=exportParser.cjs.map
|