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