eslint-plugin-jsdoc 65.3.3 → 65.3.4
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/package.json +1 -1
- package/src/jsdocUtils.js +23 -7
package/package.json
CHANGED
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
|
/**
|