eslint-plugin-jsdoc 61.5.0 → 62.0.0
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/README.md +1 -2
- package/dist/cjs/iterateJsdoc.d.ts +4 -0
- package/dist/generateDocs.cjs +1 -1
- package/dist/generateDocs.cjs.map +1 -1
- package/dist/iterateJsdoc.cjs +3 -1
- package/dist/iterateJsdoc.cjs.map +1 -1
- package/dist/iterateJsdoc.d.ts +4 -0
- package/dist/rules/checkPropertyNames.cjs +29 -16
- package/dist/rules/checkPropertyNames.cjs.map +1 -1
- package/dist/rules/convertToJsdocComments.cjs +0 -2
- package/dist/rules/convertToJsdocComments.cjs.map +1 -1
- package/dist/rules/requireJsdoc.cjs +13 -3
- package/dist/rules/requireJsdoc.cjs.map +1 -1
- package/dist/rules.d.ts +6 -0
- package/package.json +28 -28
- package/src/iterateJsdoc.js +4 -1
- package/src/rules/checkPropertyNames.js +40 -24
- package/src/rules/convertToJsdocComments.js +0 -2
- package/src/rules/requireJsdoc.js +13 -3
- package/src/rules.d.ts +6 -0
package/package.json
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
"url": "http://gajus.com"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@es-joy/jsdoccomment": "~0.
|
|
8
|
+
"@es-joy/jsdoccomment": "~0.79.0",
|
|
9
9
|
"@es-joy/resolve.exports": "1.2.0",
|
|
10
10
|
"are-docs-informative": "^0.0.2",
|
|
11
11
|
"comment-parser": "1.4.1",
|
|
12
12
|
"debug": "^4.4.3",
|
|
13
13
|
"escape-string-regexp": "^4.0.0",
|
|
14
|
-
"espree": "^
|
|
15
|
-
"esquery": "^1.
|
|
14
|
+
"espree": "^11.0.0",
|
|
15
|
+
"esquery": "^1.7.0",
|
|
16
16
|
"html-entities": "^2.6.0",
|
|
17
17
|
"object-deep-merge": "^2.0.0",
|
|
18
18
|
"parse-imports-exports": "^0.2.4",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"@babel/plugin-transform-flow-strip-types": "^7.27.1",
|
|
31
31
|
"@babel/preset-env": "^7.28.5",
|
|
32
32
|
"@es-joy/escodegen": "^4.2.0",
|
|
33
|
-
"@es-joy/jsdoc-eslint-parser": "^0.
|
|
34
|
-
"@eslint/core": "^0.
|
|
33
|
+
"@es-joy/jsdoc-eslint-parser": "^0.27.0",
|
|
34
|
+
"@eslint/core": "^1.0.0",
|
|
35
35
|
"@hkdobrev/run-if-changed": "^0.6.3",
|
|
36
36
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
37
37
|
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
38
|
-
"@semantic-release/github": "^12.0.
|
|
39
|
-
"@semantic-release/npm": "^13.1.
|
|
38
|
+
"@semantic-release/github": "^12.0.2",
|
|
39
|
+
"@semantic-release/npm": "^13.1.3",
|
|
40
40
|
"@types/chai": "^5.2.3",
|
|
41
41
|
"@types/debug": "^4.1.12",
|
|
42
42
|
"@types/espree": "^10.1.0",
|
|
@@ -44,41 +44,41 @@
|
|
|
44
44
|
"@types/estree": "^1.0.8",
|
|
45
45
|
"@types/json-schema": "^7.0.15",
|
|
46
46
|
"@types/mocha": "^10.0.10",
|
|
47
|
-
"@types/node": "^
|
|
47
|
+
"@types/node": "^25.0.3",
|
|
48
48
|
"@types/semver": "^7.7.1",
|
|
49
49
|
"@types/spdx-expression-parse": "^3.0.5",
|
|
50
|
-
"@typescript-eslint/types": "^8.
|
|
50
|
+
"@typescript-eslint/types": "^8.52.0",
|
|
51
51
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
52
52
|
"babel-plugin-istanbul": "^7.0.1",
|
|
53
53
|
"babel-plugin-transform-import-meta": "^2.3.3",
|
|
54
54
|
"c8": "^10.1.3",
|
|
55
|
-
"camelcase": "^
|
|
56
|
-
"chai": "^6.2.
|
|
55
|
+
"camelcase": "^9.0.0",
|
|
56
|
+
"chai": "^6.2.2",
|
|
57
57
|
"decamelize": "^6.0.1",
|
|
58
|
-
"eslint": "9.39.
|
|
59
|
-
"eslint-config-canonical": "^
|
|
58
|
+
"eslint": "9.39.2",
|
|
59
|
+
"eslint-config-canonical": "^47.3.7",
|
|
60
60
|
"gitdown": "^4.1.1",
|
|
61
|
-
"glob": "^
|
|
62
|
-
"globals": "^
|
|
61
|
+
"glob": "^13.0.0",
|
|
62
|
+
"globals": "^17.0.0",
|
|
63
63
|
"husky": "^9.1.7",
|
|
64
|
-
"jsdoc-type-pratt-parser": "^
|
|
64
|
+
"jsdoc-type-pratt-parser": "^7.0.0",
|
|
65
65
|
"json-schema": "^0.4.0",
|
|
66
66
|
"json-schema-to-typescript": "^15.0.4",
|
|
67
|
-
"lint-staged": "^16.2.
|
|
68
|
-
"mocha": "^11.7.
|
|
69
|
-
"open-editor": "^
|
|
70
|
-
"playwright": "^1.
|
|
67
|
+
"lint-staged": "^16.2.7",
|
|
68
|
+
"mocha": "^11.7.5",
|
|
69
|
+
"open-editor": "^6.0.0",
|
|
70
|
+
"playwright": "^1.57.0",
|
|
71
71
|
"replace": "^1.2.2",
|
|
72
|
-
"rimraf": "^6.1.
|
|
73
|
-
"rollup": "^4.
|
|
74
|
-
"semantic-release": "^25.0.
|
|
75
|
-
"sinon": "^21.0.
|
|
76
|
-
"ts-api-utils": "^2.
|
|
72
|
+
"rimraf": "^6.1.2",
|
|
73
|
+
"rollup": "^4.55.1",
|
|
74
|
+
"semantic-release": "^25.0.2",
|
|
75
|
+
"sinon": "^21.0.1",
|
|
76
|
+
"ts-api-utils": "^2.4.0",
|
|
77
77
|
"typescript": "5.9.3",
|
|
78
|
-
"typescript-eslint": "^8.
|
|
78
|
+
"typescript-eslint": "^8.52.0"
|
|
79
79
|
},
|
|
80
80
|
"engines": {
|
|
81
|
-
"node": "
|
|
81
|
+
"node": "^20.19.0 || ^22.13.0 || >=24"
|
|
82
82
|
},
|
|
83
83
|
"keywords": [
|
|
84
84
|
"eslint",
|
|
@@ -192,5 +192,5 @@
|
|
|
192
192
|
"test-cov": "TIMING=1 c8 --reporter text pnpm run test-no-cov",
|
|
193
193
|
"test-index": "pnpm run test-no-cov test/rules/index.js"
|
|
194
194
|
},
|
|
195
|
-
"version": "
|
|
195
|
+
"version": "62.0.0"
|
|
196
196
|
}
|
package/src/iterateJsdoc.js
CHANGED
|
@@ -1681,7 +1681,6 @@ const getUtils = (
|
|
|
1681
1681
|
|
|
1682
1682
|
/** @type {GetClassNode} */
|
|
1683
1683
|
utils.getClassNode = () => {
|
|
1684
|
-
// eslint-disable-next-line canonical/no-use-extend-native -- Not extending
|
|
1685
1684
|
return [
|
|
1686
1685
|
...ancestors, node,
|
|
1687
1686
|
].toReversed().find((parent) => {
|
|
@@ -1803,6 +1802,7 @@ const getUtils = (
|
|
|
1803
1802
|
* ignoreInternal?: boolean,
|
|
1804
1803
|
* ignorePrivate?: boolean,
|
|
1805
1804
|
* exemptDestructuredRootsFromChecks?: boolean,
|
|
1805
|
+
* skipInvokedExpressionsForCommentFinding?: boolean
|
|
1806
1806
|
* }} Settings
|
|
1807
1807
|
*/
|
|
1808
1808
|
|
|
@@ -1822,6 +1822,7 @@ const getUtils = (
|
|
|
1822
1822
|
* implementsReplacesDocs: boolean,
|
|
1823
1823
|
* augmentsExtendsReplacesDocs: boolean,
|
|
1824
1824
|
* exemptDestructuredRootsFromChecks: boolean,
|
|
1825
|
+
* skipInvokedExpressionsForCommentFinding: boolean,
|
|
1825
1826
|
* mode: import('./jsdocUtils.js').ParserMode,
|
|
1826
1827
|
* contexts: Context[],
|
|
1827
1828
|
* }
|
|
@@ -1841,6 +1842,8 @@ const getSettings = (context) => {
|
|
|
1841
1842
|
ignoreInternal: Boolean(context.settings.jsdoc?.ignoreInternal),
|
|
1842
1843
|
maxLines: Number(context.settings.jsdoc?.maxLines ?? 1),
|
|
1843
1844
|
minLines: Number(context.settings.jsdoc?.minLines ?? 0),
|
|
1845
|
+
skipInvokedExpressionsForCommentFinding:
|
|
1846
|
+
Boolean(context.settings.jsdoc?.skipInvokedExpressionsForCommentFinding),
|
|
1844
1847
|
|
|
1845
1848
|
// `check-tag-names` and many returns/param rules
|
|
1846
1849
|
tagNamePreference: context.settings.jsdoc?.tagNamePreference ?? {},
|
|
@@ -12,34 +12,50 @@ const validatePropertyNames = (
|
|
|
12
12
|
enableFixer,
|
|
13
13
|
jsdoc, utils,
|
|
14
14
|
) => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const jsdocTypedefs = utils.getJsdocTagsDeep('typedef');
|
|
16
|
+
let propertyTagGroups;
|
|
17
|
+
if (jsdocTypedefs && jsdocTypedefs.length > 1) {
|
|
18
|
+
propertyTagGroups = jsdocTypedefs.map(({
|
|
19
|
+
idx,
|
|
20
|
+
}, index) => {
|
|
21
|
+
return Object.entries(jsdoc.tags).slice(idx, jsdocTypedefs[index + 1]?.idx);
|
|
22
|
+
});
|
|
23
|
+
} else {
|
|
24
|
+
propertyTagGroups = [
|
|
25
|
+
Object.entries(jsdoc.tags),
|
|
26
|
+
];
|
|
27
|
+
}
|
|
20
28
|
|
|
21
|
-
return
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const dupeTagInfo = propertyTags.find(([
|
|
27
|
-
tgsIndex,
|
|
28
|
-
tg,
|
|
29
|
-
], idx) => {
|
|
30
|
-
tagsIndex = Number(tgsIndex);
|
|
31
|
-
|
|
32
|
-
return tg.name === tag.name && idx !== index;
|
|
29
|
+
return propertyTagGroups.some((propertyTagGroup) => {
|
|
30
|
+
const propertyTags = propertyTagGroup.filter(([
|
|
31
|
+
, tag,
|
|
32
|
+
]) => {
|
|
33
|
+
return tag.tag === targetTagName;
|
|
33
34
|
});
|
|
34
|
-
if (dupeTagInfo) {
|
|
35
|
-
utils.reportJSDoc(`Duplicate @${targetTagName} "${tag.name}"`, dupeTagInfo[1], enableFixer ? () => {
|
|
36
|
-
utils.removeTag(tagsIndex);
|
|
37
|
-
} : null);
|
|
38
35
|
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
return propertyTags.some(([
|
|
37
|
+
, tag,
|
|
38
|
+
], index) => {
|
|
39
|
+
/** @type {import('../iterateJsdoc.js').Integer} */
|
|
40
|
+
let tagsIndex;
|
|
41
|
+
const dupeTagInfo = propertyTags.find(([
|
|
42
|
+
tgsIndex,
|
|
43
|
+
tg,
|
|
44
|
+
], idx) => {
|
|
45
|
+
tagsIndex = Number(tgsIndex);
|
|
46
|
+
|
|
47
|
+
return tg.name === tag.name && idx !== index;
|
|
48
|
+
});
|
|
49
|
+
if (dupeTagInfo) {
|
|
50
|
+
utils.reportJSDoc(`Duplicate @${targetTagName} "${tag.name}"`, dupeTagInfo[1], enableFixer ? () => {
|
|
51
|
+
utils.removeTag(tagsIndex);
|
|
52
|
+
} : null);
|
|
41
53
|
|
|
42
|
-
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return false;
|
|
58
|
+
});
|
|
43
59
|
});
|
|
44
60
|
};
|
|
45
61
|
|
|
@@ -111,7 +111,6 @@ export default {
|
|
|
111
111
|
|
|
112
112
|
const decorator = getDecorator(
|
|
113
113
|
/** @type {import('eslint').Rule.Node} */
|
|
114
|
-
// @ts-expect-error Bug?
|
|
115
114
|
(baseNode),
|
|
116
115
|
);
|
|
117
116
|
if (decorator) {
|
|
@@ -204,7 +203,6 @@ export default {
|
|
|
204
203
|
reportingNonJsdoc = true;
|
|
205
204
|
|
|
206
205
|
/** @type {AddComment} */
|
|
207
|
-
// eslint-disable-next-line unicorn/consistent-function-scoping -- Avoid conflicts
|
|
208
206
|
const addComment = (inlineCommentBlock, commentToAdd, indent, lines, fixer) => {
|
|
209
207
|
const insertion = (
|
|
210
208
|
inlineCommentBlock || enforceJsdocLineStyle === 'single' ?
|
|
@@ -36,6 +36,13 @@ const OPTIONS_SCHEMA = {
|
|
|
36
36
|
additionalProperties: false,
|
|
37
37
|
description: 'Has the following optional keys.\n',
|
|
38
38
|
properties: {
|
|
39
|
+
checkAllFunctionExpressions: {
|
|
40
|
+
default: false,
|
|
41
|
+
description: `Normally, when \`FunctionExpression\` is checked, additional checks are
|
|
42
|
+
added to check the parent contexts where reporting is likely to be desired. If you really
|
|
43
|
+
want to check *all* function expressions, then set this to \`true\`.`,
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
},
|
|
39
46
|
checkConstructors: {
|
|
40
47
|
default: true,
|
|
41
48
|
description: `A value indicating whether \`constructor\`s should be checked. Defaults to
|
|
@@ -378,6 +385,7 @@ const getOption = (context, baseObject, option, key) => {
|
|
|
378
385
|
* @param {import('eslint').Rule.RuleContext} context
|
|
379
386
|
* @param {import('../iterateJsdoc.js').Settings} settings
|
|
380
387
|
* @returns {{
|
|
388
|
+
* checkAllFunctionExpressions: boolean,
|
|
381
389
|
* contexts: (string|{
|
|
382
390
|
* context: string,
|
|
383
391
|
* inlineCommentBlock: boolean,
|
|
@@ -396,6 +404,7 @@ const getOption = (context, baseObject, option, key) => {
|
|
|
396
404
|
*/
|
|
397
405
|
const getOptions = (context, settings) => {
|
|
398
406
|
const {
|
|
407
|
+
checkAllFunctionExpressions = false,
|
|
399
408
|
contexts = settings.contexts || [],
|
|
400
409
|
enableFixer = true,
|
|
401
410
|
exemptEmptyConstructors = true,
|
|
@@ -408,6 +417,7 @@ const getOptions = (context, settings) => {
|
|
|
408
417
|
} = context.options[0] || {};
|
|
409
418
|
|
|
410
419
|
return {
|
|
420
|
+
checkAllFunctionExpressions,
|
|
411
421
|
contexts,
|
|
412
422
|
enableFixer,
|
|
413
423
|
exemptEmptyConstructors,
|
|
@@ -503,7 +513,7 @@ const isFunctionWithOverload = (node) => {
|
|
|
503
513
|
return false;
|
|
504
514
|
}
|
|
505
515
|
|
|
506
|
-
const functionName = node.id
|
|
516
|
+
const functionName = node.id?.name;
|
|
507
517
|
|
|
508
518
|
const idx = parent.body.indexOf(child);
|
|
509
519
|
const prevSibling = parent.body[idx - 1];
|
|
@@ -536,6 +546,7 @@ export default {
|
|
|
536
546
|
const opts = getOptions(context, settings);
|
|
537
547
|
|
|
538
548
|
const {
|
|
549
|
+
checkAllFunctionExpressions,
|
|
539
550
|
contexts,
|
|
540
551
|
enableFixer,
|
|
541
552
|
exemptEmptyConstructors,
|
|
@@ -670,7 +681,6 @@ export default {
|
|
|
670
681
|
|
|
671
682
|
const decorator = getDecorator(
|
|
672
683
|
/** @type {import('eslint').Rule.Node} */
|
|
673
|
-
// @ts-expect-error Bug?
|
|
674
684
|
(baseNode),
|
|
675
685
|
);
|
|
676
686
|
if (decorator) {
|
|
@@ -831,7 +841,7 @@ export default {
|
|
|
831
841
|
return;
|
|
832
842
|
}
|
|
833
843
|
|
|
834
|
-
if (
|
|
844
|
+
if (checkAllFunctionExpressions ||
|
|
835
845
|
[
|
|
836
846
|
'AssignmentExpression', 'ExportDefaultDeclaration', 'VariableDeclarator',
|
|
837
847
|
].includes(node.parent.type) ||
|
package/src/rules.d.ts
CHANGED
|
@@ -1639,6 +1639,12 @@ export interface Rules {
|
|
|
1639
1639
|
| []
|
|
1640
1640
|
| [
|
|
1641
1641
|
{
|
|
1642
|
+
/**
|
|
1643
|
+
* Normally, when `FunctionExpression` is checked, additional checks are
|
|
1644
|
+
* added to check the parent contexts where reporting is likely to be desired. If you really
|
|
1645
|
+
* want to check *all* function expressions, then set this to `true`.
|
|
1646
|
+
*/
|
|
1647
|
+
checkAllFunctionExpressions?: boolean;
|
|
1642
1648
|
/**
|
|
1643
1649
|
* A value indicating whether `constructor`s should be checked. Defaults to
|
|
1644
1650
|
* `true`. When `true`, `exemptEmptyConstructors` may still avoid reporting when
|