eslint-plugin-jsdoc 65.4.5 → 65.4.7
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
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@es-joy/escodegen": "^5.0.1",
|
|
9
|
-
"@es-joy/jsdoccomment": "~1.
|
|
9
|
+
"@es-joy/jsdoccomment": "~1.2.0",
|
|
10
10
|
"@es-joy/resolve.exports": "1.2.0",
|
|
11
|
-
"@typescript-eslint/utils": "^8.72.
|
|
11
|
+
"@typescript-eslint/utils": "^8.72.2",
|
|
12
12
|
"are-docs-informative": "^0.1.1",
|
|
13
13
|
"comment-parser": "1.4.9",
|
|
14
14
|
"debug": "^4.4.3",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"description": "JSDoc linting rules for ESLint.",
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
28
|
-
"@babel/core": "8.1.
|
|
29
|
-
"@babel/eslint-parser": "8.
|
|
28
|
+
"@babel/core": "8.1.2",
|
|
29
|
+
"@babel/eslint-parser": "8.1.2",
|
|
30
30
|
"@babel/plugin-transform-flow-strip-types": "8.0.1",
|
|
31
31
|
"@babel/preset-env": "8.0.7",
|
|
32
32
|
"@es-joy/jsdoc-eslint-parser": "^0.29.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@types/node": "^26.6.6",
|
|
45
45
|
"@types/semver": "^7.8.0",
|
|
46
46
|
"@types/spdx-expression-parse": "^4.0.0",
|
|
47
|
-
"@typescript-eslint/types": "8.72.
|
|
47
|
+
"@typescript-eslint/types": "8.72.2",
|
|
48
48
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
49
49
|
"babel-plugin-transform-import-meta": "^3.1.0",
|
|
50
50
|
"c8": "^12.0.0",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"eslint-config-canonical": "^47.4.2",
|
|
56
56
|
"eslint-plugin-eslint-plugin": "^7.6.2",
|
|
57
57
|
"gitdown": "^4.1.1",
|
|
58
|
-
"glob": "^14.0.
|
|
58
|
+
"glob": "^14.0.6",
|
|
59
59
|
"globals": "^17.14.0",
|
|
60
60
|
"husky": "^9.1.7",
|
|
61
61
|
"jsdoc-type-pratt-parser": "^9.5.0",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"sinon": "^22.1.0",
|
|
72
72
|
"ts-api-utils": "^2.5.0",
|
|
73
73
|
"typescript": "6.0.3",
|
|
74
|
-
"typescript-eslint": "8.72.
|
|
74
|
+
"typescript-eslint": "8.72.2"
|
|
75
75
|
},
|
|
76
76
|
"engines": {
|
|
77
77
|
"node": "^22.22.2 || >=24.15.0"
|
|
@@ -164,5 +164,5 @@
|
|
|
164
164
|
"test-cov": "TIMING=1 c8 --reporter text pnpm run test-no-cov",
|
|
165
165
|
"test-index": "pnpm run test-no-cov test/rules/index.js"
|
|
166
166
|
},
|
|
167
|
-
"version": "65.4.
|
|
167
|
+
"version": "65.4.7"
|
|
168
168
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import iterateJsdoc from '../iterateJsdoc.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
// initial letter: \\p{Upper}
|
|
5
|
-
const matchDescriptionDefault = '^\n?([A-Z`\\d_][\\s\\S]*[.?!`\\p{RGI_Emoji}]\\s*)?$';
|
|
3
|
+
const matchDescriptionDefault = '^\n?([\\p{Upper}`\\d_][\\s\\S]*[.?!`\\p{RGI_Emoji}]\\s*)?$';
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* @param {string} value
|
|
@@ -303,6 +303,79 @@ export default iterateJsdoc(({
|
|
|
303
303
|
.filter(Boolean));
|
|
304
304
|
}
|
|
305
305
|
|
|
306
|
+
/**
|
|
307
|
+
* @typedef {{
|
|
308
|
+
* parsedType: import('jsdoc-type-pratt-parser').RootResult;
|
|
309
|
+
* tag: import('comment-parser').Spec|import('@es-joy/jsdoccomment').JsdocInlineTagNoType & {
|
|
310
|
+
* line?: import('../iterateJsdoc.js').Integer
|
|
311
|
+
* }
|
|
312
|
+
* }} TypeAndTagInfo
|
|
313
|
+
*/
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* @param {string} propertyName
|
|
317
|
+
* @returns {(tag: (import('@es-joy/jsdoccomment').JsdocInlineTagNoType & {
|
|
318
|
+
* name?: string,
|
|
319
|
+
* type?: string,
|
|
320
|
+
* line?: import('../iterateJsdoc.js').Integer
|
|
321
|
+
* })|import('comment-parser').Spec & {
|
|
322
|
+
* namepathOrURL?: string
|
|
323
|
+
* }
|
|
324
|
+
* ) => undefined|TypeAndTagInfo}
|
|
325
|
+
*/
|
|
326
|
+
const tagToParsedType = (propertyName) => {
|
|
327
|
+
return (tag) => {
|
|
328
|
+
try {
|
|
329
|
+
const potentialType = tag[
|
|
330
|
+
/** @type {"type"|"name"|"namepathOrURL"} */ (propertyName)
|
|
331
|
+
];
|
|
332
|
+
return {
|
|
333
|
+
parsedType: mode === 'permissive' ?
|
|
334
|
+
tryParseType(/** @type {string} */ (potentialType), undefined, {
|
|
335
|
+
computedPropertyParser: espree,
|
|
336
|
+
}) :
|
|
337
|
+
parseType(/** @type {string} */ (potentialType), mode, {
|
|
338
|
+
computedPropertyParser: espree,
|
|
339
|
+
}),
|
|
340
|
+
tag,
|
|
341
|
+
};
|
|
342
|
+
} catch {
|
|
343
|
+
return undefined;
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
const typeTags = utils.filterTags(({
|
|
349
|
+
tag,
|
|
350
|
+
}) => {
|
|
351
|
+
return tag !== 'import' && utils.tagMightHaveTypePosition(tag) && (tag !== 'suppress' || settings.mode !== 'closure');
|
|
352
|
+
}).map(tagToParsedType('type'));
|
|
353
|
+
|
|
354
|
+
const namepathReferencingTags = utils.filterTags(({
|
|
355
|
+
tag,
|
|
356
|
+
}) => {
|
|
357
|
+
return utils.isNamepathReferencingTag(tag);
|
|
358
|
+
}).map(tagToParsedType('name'));
|
|
359
|
+
|
|
360
|
+
const namepathOrUrlReferencingTags = utils.filterAllTags(({
|
|
361
|
+
tag,
|
|
362
|
+
}) => {
|
|
363
|
+
return utils.isNamepathOrUrlReferencingTag(tag);
|
|
364
|
+
}).map(tagToParsedType('namepathOrURL'));
|
|
365
|
+
|
|
366
|
+
const tagsWithTypes = /** @type {TypeAndTagInfo[]} */ ([
|
|
367
|
+
...typeTags,
|
|
368
|
+
...namepathReferencingTags,
|
|
369
|
+
...namepathOrUrlReferencingTags,
|
|
370
|
+
// Remove types which failed to parse
|
|
371
|
+
].filter(Boolean));
|
|
372
|
+
|
|
373
|
+
// Skip collecting defined types when there is nothing to check
|
|
374
|
+
if (!tagsWithTypes.length) {
|
|
375
|
+
state.foundTypedefValues = foundTypedefValues;
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
|
|
306
379
|
const allComments = sourceCode.getAllComments();
|
|
307
380
|
const comments = getJSDocCommentBlocks(sourceCode);
|
|
308
381
|
|
|
@@ -780,66 +853,6 @@ export default iterateJsdoc(({
|
|
|
780
853
|
],
|
|
781
854
|
));
|
|
782
855
|
|
|
783
|
-
/**
|
|
784
|
-
* @typedef {{
|
|
785
|
-
* parsedType: import('jsdoc-type-pratt-parser').RootResult;
|
|
786
|
-
* tag: import('comment-parser').Spec|import('@es-joy/jsdoccomment').JsdocInlineTagNoType & {
|
|
787
|
-
* line?: import('../iterateJsdoc.js').Integer
|
|
788
|
-
* }
|
|
789
|
-
* }} TypeAndTagInfo
|
|
790
|
-
*/
|
|
791
|
-
|
|
792
|
-
/**
|
|
793
|
-
* @param {string} propertyName
|
|
794
|
-
* @returns {(tag: (import('@es-joy/jsdoccomment').JsdocInlineTagNoType & {
|
|
795
|
-
* name?: string,
|
|
796
|
-
* type?: string,
|
|
797
|
-
* line?: import('../iterateJsdoc.js').Integer
|
|
798
|
-
* })|import('comment-parser').Spec & {
|
|
799
|
-
* namepathOrURL?: string
|
|
800
|
-
* }
|
|
801
|
-
* ) => undefined|TypeAndTagInfo}
|
|
802
|
-
*/
|
|
803
|
-
const tagToParsedType = (propertyName) => {
|
|
804
|
-
return (tag) => {
|
|
805
|
-
try {
|
|
806
|
-
const potentialType = tag[
|
|
807
|
-
/** @type {"type"|"name"|"namepathOrURL"} */ (propertyName)
|
|
808
|
-
];
|
|
809
|
-
return {
|
|
810
|
-
parsedType: mode === 'permissive' ?
|
|
811
|
-
tryParseType(/** @type {string} */ (potentialType), undefined, {
|
|
812
|
-
computedPropertyParser: espree,
|
|
813
|
-
}) :
|
|
814
|
-
parseType(/** @type {string} */ (potentialType), mode, {
|
|
815
|
-
computedPropertyParser: espree,
|
|
816
|
-
}),
|
|
817
|
-
tag,
|
|
818
|
-
};
|
|
819
|
-
} catch {
|
|
820
|
-
return undefined;
|
|
821
|
-
}
|
|
822
|
-
};
|
|
823
|
-
};
|
|
824
|
-
|
|
825
|
-
const typeTags = utils.filterTags(({
|
|
826
|
-
tag,
|
|
827
|
-
}) => {
|
|
828
|
-
return tag !== 'import' && utils.tagMightHaveTypePosition(tag) && (tag !== 'suppress' || settings.mode !== 'closure');
|
|
829
|
-
}).map(tagToParsedType('type'));
|
|
830
|
-
|
|
831
|
-
const namepathReferencingTags = utils.filterTags(({
|
|
832
|
-
tag,
|
|
833
|
-
}) => {
|
|
834
|
-
return utils.isNamepathReferencingTag(tag);
|
|
835
|
-
}).map(tagToParsedType('name'));
|
|
836
|
-
|
|
837
|
-
const namepathOrUrlReferencingTags = utils.filterAllTags(({
|
|
838
|
-
tag,
|
|
839
|
-
}) => {
|
|
840
|
-
return utils.isNamepathOrUrlReferencingTag(tag);
|
|
841
|
-
}).map(tagToParsedType('namepathOrURL'));
|
|
842
|
-
|
|
843
856
|
const definedNamesAndNamepaths = new Set(utils.filterTags(({
|
|
844
857
|
tag,
|
|
845
858
|
}) => {
|
|
@@ -850,13 +863,6 @@ export default iterateJsdoc(({
|
|
|
850
863
|
return name;
|
|
851
864
|
}));
|
|
852
865
|
|
|
853
|
-
const tagsWithTypes = /** @type {TypeAndTagInfo[]} */ ([
|
|
854
|
-
...typeTags,
|
|
855
|
-
...namepathReferencingTags,
|
|
856
|
-
...namepathOrUrlReferencingTags,
|
|
857
|
-
// Remove types which failed to parse
|
|
858
|
-
].filter(Boolean));
|
|
859
|
-
|
|
860
866
|
for (const {
|
|
861
867
|
parsedType,
|
|
862
868
|
tag,
|
|
@@ -946,6 +952,27 @@ export default iterateJsdoc(({
|
|
|
946
952
|
return;
|
|
947
953
|
}
|
|
948
954
|
|
|
955
|
+
// The parameter named by the type predicate or assertion of a
|
|
956
|
+
// function type or signature (e.g., `(x: unknown) => x is string`)
|
|
957
|
+
if (
|
|
958
|
+
(
|
|
959
|
+
(parent?.type === 'JsdocTypePredicate' || parent?.type === 'JsdocTypeAsserts') &&
|
|
960
|
+
parent.left === nde
|
|
961
|
+
) || parent?.type === 'JsdocTypeAssertsPlain'
|
|
962
|
+
) {
|
|
963
|
+
const functionType =
|
|
964
|
+
/** @type {import('jsdoc-type-pratt-parser').FunctionResult|undefined} */ (
|
|
965
|
+
/** @type {{_parent?: import('jsdoc-type-pratt-parser').NonRootResult}} */ (
|
|
966
|
+
parent
|
|
967
|
+
)._parent
|
|
968
|
+
);
|
|
969
|
+
if (functionType?.parameters?.some((param) => {
|
|
970
|
+
return param.type === 'JsdocTypeKeyValue' && param.key === value;
|
|
971
|
+
})) {
|
|
972
|
+
return;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
|
|
949
976
|
if (!disableReporting) {
|
|
950
977
|
report(`The type '${val}' is undefined.`, null, tag);
|
|
951
978
|
}
|