eslint-plugin-jsdoc 65.3.3 → 65.3.5
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/exportParser.d.ts +0 -1
- package/package.json +1 -1
- package/src/exportParser.js +17 -7
- package/src/jsdocUtils.js +23 -7
package/dist/exportParser.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export type CreatedNode = {
|
|
|
15
15
|
special?: true;
|
|
16
16
|
globalVars?: CreatedNode;
|
|
17
17
|
exported?: boolean;
|
|
18
|
-
ANONYMOUS_DEFAULT?: import("eslint").Rule.Node;
|
|
19
18
|
};
|
|
20
19
|
export type CreateSymbol = (node: import("eslint").Rule.Node | null, globals: CreatedNode, value: import("eslint").Rule.Node | import("@typescript-eslint/types").TSESTree.Node | null, scope?: CreatedNode | undefined, isGlobal?: boolean | SymbolOptions | undefined) => CreatedNode | null;
|
|
21
20
|
export type SymbolOptions = {
|
package/package.json
CHANGED
package/src/exportParser.js
CHANGED
|
@@ -20,8 +20,7 @@ const debug = debugModule('requireExportJsdoc');
|
|
|
20
20
|
* },
|
|
21
21
|
* special?: true,
|
|
22
22
|
* globalVars?: CreatedNode,
|
|
23
|
-
* exported?: boolean
|
|
24
|
-
* ANONYMOUS_DEFAULT?: import('eslint').Rule.Node
|
|
23
|
+
* exported?: boolean
|
|
25
24
|
* }} CreatedNode
|
|
26
25
|
*/
|
|
27
26
|
|
|
@@ -519,12 +518,19 @@ const mapVariables = function (node, globals, opt, isExport) {
|
|
|
519
518
|
);
|
|
520
519
|
if (symbol) {
|
|
521
520
|
symbol.exported = true;
|
|
522
|
-
/* c8 ignore next 6 */
|
|
523
521
|
} else {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
522
|
+
// Anonymous default export, e.g., `export default class {}` or
|
|
523
|
+
// `export default {}`; `default` cannot be a variable name
|
|
524
|
+
const anonymousSymbol = getSymbol(
|
|
525
|
+
/** @type {import('eslint').Rule.Node} */
|
|
526
|
+
(node.declaration),
|
|
527
|
+
globals,
|
|
528
|
+
globals,
|
|
527
529
|
);
|
|
530
|
+
if (anonymousSymbol) {
|
|
531
|
+
anonymousSymbol.exported = true;
|
|
532
|
+
globals.props.default = anonymousSymbol;
|
|
533
|
+
}
|
|
528
534
|
}
|
|
529
535
|
|
|
530
536
|
break;
|
|
@@ -804,7 +810,11 @@ const findExportedNode = function (block, node, cache) {
|
|
|
804
810
|
for (const propval of Object.values(props)) {
|
|
805
811
|
const pval = /** @type {CreatedNode} */ (propval);
|
|
806
812
|
blockCache.push(pval);
|
|
807
|
-
if (pval.exported && (
|
|
813
|
+
if (pval.exported && (
|
|
814
|
+
node === pval.value || findNode(node, pval.value) ||
|
|
815
|
+
// Object literals, e.g., `export const obj = {method () {}}`
|
|
816
|
+
findNode(node, pval)
|
|
817
|
+
)) {
|
|
808
818
|
return true;
|
|
809
819
|
}
|
|
810
820
|
|
package/src/jsdocUtils.js
CHANGED
|
@@ -1083,18 +1083,34 @@ const isNameOrNamepathDefiningTag = (tag, tagMap = tagStructure) => {
|
|
|
1083
1083
|
tagStruct.get('namepathRole')));
|
|
1084
1084
|
};
|
|
1085
1085
|
|
|
1086
|
+
/**
|
|
1087
|
+
* The parsed JSDoc blocks of each file (and fix pass), keyed by its
|
|
1088
|
+
* `SourceCode` object. Rules such as `no-undefined-types` and
|
|
1089
|
+
* `require-returns-check` ask for all blocks of the file once per JSDoc
|
|
1090
|
+
* block they check, so without this, every comment of the file was parsed
|
|
1091
|
+
* again for each block (quadratic time on larger files).
|
|
1092
|
+
* @type {WeakMap<import('eslint').SourceCode, import('@es-joy/jsdoccomment').JsdocBlockWithInline[]>}
|
|
1093
|
+
*/
|
|
1094
|
+
const jsdocCommentBlocksCache = new WeakMap();
|
|
1095
|
+
|
|
1086
1096
|
/**
|
|
1087
1097
|
* @param {import('eslint').SourceCode} sourceCode
|
|
1088
1098
|
* @returns {import('@es-joy/jsdoccomment').JsdocBlockWithInline[]}
|
|
1089
1099
|
*/
|
|
1090
1100
|
const getJSDocCommentBlocks = (sourceCode) => {
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1101
|
+
let blocks = jsdocCommentBlocksCache.get(sourceCode);
|
|
1102
|
+
if (!blocks) {
|
|
1103
|
+
blocks = sourceCode.getAllComments()
|
|
1104
|
+
.filter((comment) => {
|
|
1105
|
+
return (/^\*(?!\*)/v).test(comment.value);
|
|
1106
|
+
})
|
|
1107
|
+
.map((commentNode) => {
|
|
1108
|
+
return parseComment(commentNode, '');
|
|
1109
|
+
});
|
|
1110
|
+
jsdocCommentBlocksCache.set(sourceCode, blocks);
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
return blocks;
|
|
1098
1114
|
};
|
|
1099
1115
|
|
|
1100
1116
|
/**
|