@cjser/es-joy__jsdoccomment 0.98.0-cjser.2 → 1.0.0-cjser.2
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/CHANGES.md +12 -0
- package/dist-cjser/index.cjs +31 -48
- package/package.json +19 -18
- package/src/commentParserToESTree.js +10 -8
- package/src/estreeToString.js +9 -7
- package/src/jsdoccomment.js +37 -35
- package/src/parseComment.js +4 -10
- package/src/parseInlineTags.js +1 -4
package/CHANGES.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# CHANGES for `@es-joy/jsdoccomment`
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
- chore: update jsdoc-type-pratt-parser, devDep.
|
|
6
|
+
|
|
7
|
+
## 0.100.0
|
|
8
|
+
|
|
9
|
+
- chore: update typescript-eslint/types, jsdoc-type-pratt-parser, devDeps
|
|
10
|
+
|
|
11
|
+
## 0.99.0
|
|
12
|
+
|
|
13
|
+
- chore: update typescript-eslint/types, jsdoc-type-pratt-parser, devDeps
|
|
14
|
+
|
|
3
15
|
## 0.98.0
|
|
4
16
|
|
|
5
17
|
- chore: update typescript-eslint/types, comment-parser, jsdoc-type-pratt-parser, devDeps
|
package/dist-cjser/index.cjs
CHANGED
|
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
|
-
// packages/@cjser/es-joy__jsdoccomment.tmp-26-
|
|
30
|
+
// packages/@cjser/es-joy__jsdoccomment.tmp-26-1792686817497/src/index.js
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
commentHandler: () => commentHandler,
|
|
@@ -52,11 +52,11 @@ module.exports = __toCommonJS(index_exports);
|
|
|
52
52
|
var import_jsdoc_type_pratt_parser4 = require("@cjser/jsdoc-type-pratt-parser");
|
|
53
53
|
__reExport(index_exports, require("@cjser/jsdoc-type-pratt-parser"), module.exports);
|
|
54
54
|
|
|
55
|
-
// packages/@cjser/es-joy__jsdoccomment.tmp-26-
|
|
55
|
+
// packages/@cjser/es-joy__jsdoccomment.tmp-26-1792686817497/src/commentHandler.js
|
|
56
56
|
var import_esquery = __toESM(require("esquery"), 1);
|
|
57
57
|
var import_jsdoc_type_pratt_parser2 = require("@cjser/jsdoc-type-pratt-parser");
|
|
58
58
|
|
|
59
|
-
// packages/@cjser/es-joy__jsdoccomment.tmp-26-
|
|
59
|
+
// packages/@cjser/es-joy__jsdoccomment.tmp-26-1792686817497/src/commentParserToESTree.js
|
|
60
60
|
var import_jsdoc_type_pratt_parser = require("@cjser/jsdoc-type-pratt-parser");
|
|
61
61
|
var stripEncapsulatingBrackets = (container, isArr) => {
|
|
62
62
|
if (isArr) {
|
|
@@ -318,17 +318,18 @@ var commentParserToESTree = (jsdoc, mode = "typescript", {
|
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
|
-
if (end
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
/** @type {JsdocTag} */
|
|
329
|
-
lastTag
|
|
330
|
-
);
|
|
321
|
+
if (!end || !tag) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
ast.terminal = end;
|
|
325
|
+
ast.hasPreterminalTagDescription = 1;
|
|
326
|
+
if (ast.terminal === "*/") {
|
|
327
|
+
ast.preterminalLineBreak = "";
|
|
331
328
|
}
|
|
329
|
+
cleanUpLastTag(
|
|
330
|
+
/** @type {JsdocTag} */
|
|
331
|
+
lastTag
|
|
332
|
+
);
|
|
332
333
|
});
|
|
333
334
|
ast.lastDescriptionLine = lastDescriptionLine;
|
|
334
335
|
ast.tags = tags;
|
|
@@ -342,7 +343,7 @@ var jsdocVisitorKeys = {
|
|
|
342
343
|
JsdocInlineTag: []
|
|
343
344
|
};
|
|
344
345
|
|
|
345
|
-
// packages/@cjser/es-joy__jsdoccomment.tmp-26-
|
|
346
|
+
// packages/@cjser/es-joy__jsdoccomment.tmp-26-1792686817497/src/commentHandler.js
|
|
346
347
|
var commentHandler = (settings, commentParserToESTreeOptions) => {
|
|
347
348
|
return (commentSelector, jsdoc) => {
|
|
348
349
|
const { mode } = settings;
|
|
@@ -371,10 +372,10 @@ var commentHandler = (settings, commentParserToESTreeOptions) => {
|
|
|
371
372
|
};
|
|
372
373
|
};
|
|
373
374
|
|
|
374
|
-
// packages/@cjser/es-joy__jsdoccomment.tmp-26-
|
|
375
|
+
// packages/@cjser/es-joy__jsdoccomment.tmp-26-1792686817497/src/estreeToString.js
|
|
375
376
|
var import_jsdoc_type_pratt_parser3 = require("@cjser/jsdoc-type-pratt-parser");
|
|
376
377
|
|
|
377
|
-
// packages/@cjser/es-joy__jsdoccomment.tmp-26-
|
|
378
|
+
// packages/@cjser/es-joy__jsdoccomment.tmp-26-1792686817497/src/inlineTagEscapes.js
|
|
378
379
|
function getLabelDelimiter(format) {
|
|
379
380
|
return format === "prefix" ? "]" : "}";
|
|
380
381
|
}
|
|
@@ -418,7 +419,7 @@ function encodeInlineTagText(text, format) {
|
|
|
418
419
|
return encoded;
|
|
419
420
|
}
|
|
420
421
|
|
|
421
|
-
// packages/@cjser/es-joy__jsdoccomment.tmp-26-
|
|
422
|
+
// packages/@cjser/es-joy__jsdoccomment.tmp-26-1792686817497/src/estreeToString.js
|
|
422
423
|
var stringifiers = {
|
|
423
424
|
/* eslint-enable jsdoc/reject-function-type -- Different functions */
|
|
424
425
|
JsdocBlock,
|
|
@@ -574,7 +575,7 @@ function JsdocTag(node, opts) {
|
|
|
574
575
|
return result;
|
|
575
576
|
}
|
|
576
577
|
|
|
577
|
-
// packages/@cjser/es-joy__jsdoccomment.tmp-26-
|
|
578
|
+
// packages/@cjser/es-joy__jsdoccomment.tmp-26-1792686817497/src/jsdoccomment.js
|
|
578
579
|
var isCommentToken = (token) => {
|
|
579
580
|
return ["Line", "Block", "Shebang"].includes(token.type);
|
|
580
581
|
};
|
|
@@ -628,13 +629,10 @@ var getTSFunctionComment = function(astNode) {
|
|
|
628
629
|
return astNode;
|
|
629
630
|
}
|
|
630
631
|
if (greatGrandparent.type === "VariableDeclarator") {
|
|
631
|
-
|
|
632
|
-
return astNode;
|
|
633
|
-
}
|
|
634
|
-
return greatGreatGrandparent.parent;
|
|
632
|
+
return !greatGreatGrandparent || !greatGreatGrandparent.parent ? astNode : greatGreatGrandparent.parent;
|
|
635
633
|
}
|
|
636
634
|
return astNode;
|
|
637
|
-
/* v8 ignore stop */
|
|
635
|
+
/* v8 ignore stop -- End of defensive fallback */
|
|
638
636
|
case "FunctionExpression":
|
|
639
637
|
if (!greatGreatGrandparent) {
|
|
640
638
|
return astNode;
|
|
@@ -653,17 +651,14 @@ var getTSFunctionComment = function(astNode) {
|
|
|
653
651
|
}
|
|
654
652
|
switch (greatGrandparent.type) {
|
|
655
653
|
case "ArrowFunctionExpression":
|
|
656
|
-
|
|
657
|
-
return greatGreatGrandparent.parent;
|
|
658
|
-
}
|
|
659
|
-
return astNode;
|
|
654
|
+
return greatGreatGrandparent.type === "VariableDeclarator" && greatGreatGrandparent.parent.type === "VariableDeclaration" ? greatGreatGrandparent.parent : astNode;
|
|
660
655
|
case "FunctionDeclaration":
|
|
661
656
|
return greatGrandparent;
|
|
662
657
|
case "VariableDeclarator":
|
|
663
658
|
if (greatGreatGrandparent.type === "VariableDeclaration") {
|
|
664
659
|
return greatGreatGrandparent;
|
|
665
660
|
}
|
|
666
|
-
/* v8 ignore next 2 */
|
|
661
|
+
/* v8 ignore next 2 -- Defensive fallthrough to default */
|
|
667
662
|
// Fallthrough
|
|
668
663
|
default:
|
|
669
664
|
return astNode;
|
|
@@ -739,10 +734,7 @@ var getReducedASTNode = function(nodeInput, sourceCode, settings) {
|
|
|
739
734
|
}
|
|
740
735
|
}
|
|
741
736
|
if (parent && parent.type !== "FunctionDeclaration" && parent.type !== "Program") {
|
|
742
|
-
|
|
743
|
-
return parent.parent;
|
|
744
|
-
}
|
|
745
|
-
return parent;
|
|
737
|
+
return parent.parent && parent.parent.type === "ExportNamedDeclaration" ? parent.parent : parent;
|
|
746
738
|
}
|
|
747
739
|
}
|
|
748
740
|
return node;
|
|
@@ -980,7 +972,7 @@ var getFollowingComment = function(sourceCode, astNodeInput) {
|
|
|
980
972
|
astNode.expression
|
|
981
973
|
);
|
|
982
974
|
break;
|
|
983
|
-
/* v8 ignore next 3 */
|
|
975
|
+
/* v8 ignore next 3 -- Defensive: no other node types expected */
|
|
984
976
|
default:
|
|
985
977
|
break;
|
|
986
978
|
}
|
|
@@ -988,10 +980,10 @@ var getFollowingComment = function(sourceCode, astNodeInput) {
|
|
|
988
980
|
return tokenAfter;
|
|
989
981
|
};
|
|
990
982
|
|
|
991
|
-
// packages/@cjser/es-joy__jsdoccomment.tmp-26-
|
|
983
|
+
// packages/@cjser/es-joy__jsdoccomment.tmp-26-1792686817497/src/parseComment.js
|
|
992
984
|
var import_comment_parser = require("comment-parser");
|
|
993
985
|
|
|
994
|
-
// packages/@cjser/es-joy__jsdoccomment.tmp-26-
|
|
986
|
+
// packages/@cjser/es-joy__jsdoccomment.tmp-26-1792686817497/src/parseInlineTags.js
|
|
995
987
|
function determineFormat(match) {
|
|
996
988
|
const { separator, text } = match.groups;
|
|
997
989
|
const [, textEnd] = match.indices.groups.text;
|
|
@@ -1002,10 +994,7 @@ function determineFormat(match) {
|
|
|
1002
994
|
if (separator === "|") {
|
|
1003
995
|
return "pipe";
|
|
1004
996
|
}
|
|
1005
|
-
|
|
1006
|
-
return "prefix";
|
|
1007
|
-
}
|
|
1008
|
-
return "space";
|
|
997
|
+
return textEnd < tagStart ? "prefix" : "space";
|
|
1009
998
|
}
|
|
1010
999
|
function parseDescription(description) {
|
|
1011
1000
|
const result = [];
|
|
@@ -1068,7 +1057,7 @@ function parseInlineTags(block) {
|
|
|
1068
1057
|
);
|
|
1069
1058
|
}
|
|
1070
1059
|
|
|
1071
|
-
// packages/@cjser/es-joy__jsdoccomment.tmp-26-
|
|
1060
|
+
// packages/@cjser/es-joy__jsdoccomment.tmp-26-1792686817497/src/parseComment.js
|
|
1072
1061
|
var {
|
|
1073
1062
|
name: nameTokenizer,
|
|
1074
1063
|
tag: tagTokenizer,
|
|
@@ -1128,10 +1117,7 @@ var getTokenizers = ({
|
|
|
1128
1117
|
* @returns {import('comment-parser').Spec}
|
|
1129
1118
|
*/
|
|
1130
1119
|
(spec) => {
|
|
1131
|
-
|
|
1132
|
-
return spec;
|
|
1133
|
-
}
|
|
1134
|
-
return preserveTypeTokenizer(spec);
|
|
1120
|
+
return noTypes.includes(spec.tag) ? spec : preserveTypeTokenizer(spec);
|
|
1135
1121
|
},
|
|
1136
1122
|
/**
|
|
1137
1123
|
* Name tokenizer.
|
|
@@ -1167,10 +1153,7 @@ var getTokenizers = ({
|
|
|
1167
1153
|
tokens.lineEnd = lineEnd || "";
|
|
1168
1154
|
return spec;
|
|
1169
1155
|
}
|
|
1170
|
-
|
|
1171
|
-
return spec;
|
|
1172
|
-
}
|
|
1173
|
-
return plainNameTokenizer(spec);
|
|
1156
|
+
return noNames.includes(spec.tag) || hasSeeWithLink(spec) ? spec : plainNameTokenizer(spec);
|
|
1174
1157
|
},
|
|
1175
1158
|
/**
|
|
1176
1159
|
* Description tokenizer.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cjser/es-joy__jsdoccomment",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-cjser.2",
|
|
4
4
|
"author": "Brett Zamir <brettz9@yahoo.com>",
|
|
5
5
|
"contributors": [],
|
|
6
6
|
"description": "Maintained replacement for ESLint's deprecated SourceCode#getJSDocComment along with other jsdoc utilities",
|
|
@@ -45,32 +45,33 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@types/estree": "^1.0.9",
|
|
48
|
-
"@typescript-eslint/types": "^8.
|
|
48
|
+
"@typescript-eslint/types": "^8.72.0",
|
|
49
49
|
"comment-parser": "1.4.9",
|
|
50
50
|
"esquery": "^1.7.0",
|
|
51
|
-
"@cjser/jsdoc-type-pratt-parser": "9.
|
|
51
|
+
"@cjser/jsdoc-type-pratt-parser": "9.4.0-cjser.2"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
55
|
+
"@es-joy/escodegen": "^4.2.0",
|
|
55
56
|
"@node-static/node-static": "^0.10.0",
|
|
56
57
|
"@types/esquery": "^1.5.4",
|
|
57
58
|
"@types/estraverse": "^5.1.7",
|
|
58
|
-
"@typescript-eslint/visitor-keys": "^8.
|
|
59
|
+
"@typescript-eslint/visitor-keys": "^8.72.0",
|
|
59
60
|
"@typhonjs-build-test/esm-d-ts": "0.4.0",
|
|
60
61
|
"@typhonjs-typedoc/typedoc-pkg": "^0.4.2",
|
|
61
|
-
"@vitest/coverage-v8": "^5.0.
|
|
62
|
-
"@vitest/ui": "^5.0.
|
|
63
|
-
"@webcoder49/code-input": "^2.
|
|
64
|
-
"eslint": "^10.
|
|
65
|
-
"eslint-config-ash-nazg": "43.
|
|
66
|
-
"eslint-plugin-jsdoc": "^
|
|
62
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
63
|
+
"@vitest/ui": "^5.0.5",
|
|
64
|
+
"@webcoder49/code-input": "^2.9.0",
|
|
65
|
+
"eslint": "^10.13.0",
|
|
66
|
+
"eslint-config-ash-nazg": "43.2.4",
|
|
67
|
+
"eslint-plugin-jsdoc": "^65.4.0",
|
|
67
68
|
"espree": "^11.2.0",
|
|
68
69
|
"estraverse": "^5.3.0",
|
|
69
70
|
"prismjs": "^1.30.0",
|
|
70
71
|
"typedoc": "^0.28.20",
|
|
71
72
|
"typescript": "6.0.3",
|
|
72
|
-
"typescript-eslint": "^8.
|
|
73
|
-
"vitest": "^5.0.
|
|
73
|
+
"typescript-eslint": "^8.72.0",
|
|
74
|
+
"vitest": "^5.0.5"
|
|
74
75
|
},
|
|
75
76
|
"files": [
|
|
76
77
|
"/dist",
|
|
@@ -90,18 +91,18 @@
|
|
|
90
91
|
"open": "open ./coverage/index.html",
|
|
91
92
|
"test": "npm run lint && npm run build && npm run test-cov",
|
|
92
93
|
"test-ui": "vitest --ui --coverage",
|
|
93
|
-
"test-cov": "vitest --coverage",
|
|
94
|
+
"test-cov": "vitest --coverage --run",
|
|
94
95
|
"tsc": "tsc",
|
|
95
96
|
"tsc:ts7": "npx -y -p typescript@^7 -c \"tsc\"",
|
|
96
97
|
"types": "esm-d-ts gen ./src/index.js --output ./dist/index.d.ts"
|
|
97
98
|
},
|
|
98
99
|
"main": "./dist-cjser/index.cjs",
|
|
99
100
|
"cjser": {
|
|
100
|
-
"sourceVersion": "0.
|
|
101
|
+
"sourceVersion": "1.0.0",
|
|
101
102
|
"cjserVersion": 2,
|
|
102
103
|
"original": {
|
|
103
104
|
"name": "@es-joy/jsdoccomment",
|
|
104
|
-
"version": "0.
|
|
105
|
+
"version": "1.0.0",
|
|
105
106
|
"exports": {
|
|
106
107
|
".": {
|
|
107
108
|
"types": "./dist/index.d.ts",
|
|
@@ -114,10 +115,10 @@
|
|
|
114
115
|
},
|
|
115
116
|
"dependencies": {
|
|
116
117
|
"@types/estree": "^1.0.9",
|
|
117
|
-
"@typescript-eslint/types": "^8.
|
|
118
|
+
"@typescript-eslint/types": "^8.72.0",
|
|
118
119
|
"comment-parser": "1.4.9",
|
|
119
120
|
"esquery": "^1.7.0",
|
|
120
|
-
"jsdoc-type-pratt-parser": "~9.
|
|
121
|
+
"jsdoc-type-pratt-parser": "~9.4.0"
|
|
121
122
|
},
|
|
122
123
|
"files": [
|
|
123
124
|
"/dist",
|
|
@@ -136,7 +137,7 @@
|
|
|
136
137
|
"open": "open ./coverage/index.html",
|
|
137
138
|
"test": "npm run lint && npm run build && npm run test-cov",
|
|
138
139
|
"test-ui": "vitest --ui --coverage",
|
|
139
|
-
"test-cov": "vitest --coverage",
|
|
140
|
+
"test-cov": "vitest --coverage --run",
|
|
140
141
|
"tsc": "tsc",
|
|
141
142
|
"tsc:ts7": "npx -y -p typescript@^7 -c \"tsc\"",
|
|
142
143
|
"types": "esm-d-ts gen ./src/index.js --output ./dist/index.d.ts"
|
|
@@ -492,17 +492,19 @@ const commentParserToESTree = (jsdoc, mode = 'typescript', {
|
|
|
492
492
|
}
|
|
493
493
|
|
|
494
494
|
// Clean-up where last line itself has tag content
|
|
495
|
-
if (end
|
|
496
|
-
|
|
497
|
-
|
|
495
|
+
if (!end || !tag) {
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
498
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
ast.preterminalLineBreak = '';
|
|
502
|
-
}
|
|
499
|
+
ast.terminal = end;
|
|
500
|
+
ast.hasPreterminalTagDescription = 1;
|
|
503
501
|
|
|
504
|
-
|
|
502
|
+
// Remove terminal line break at end when tag is defined on last line.
|
|
503
|
+
if (ast.terminal === '*/') {
|
|
504
|
+
ast.preterminalLineBreak = '';
|
|
505
505
|
}
|
|
506
|
+
|
|
507
|
+
cleanUpLastTag(/** @type {JsdocTag} */ (lastTag));
|
|
506
508
|
});
|
|
507
509
|
|
|
508
510
|
ast.lastDescriptionLine = lastDescriptionLine;
|
package/src/estreeToString.js
CHANGED
|
@@ -159,14 +159,14 @@ function JsdocTag (node, opts) {
|
|
|
159
159
|
|
|
160
160
|
result += '}';
|
|
161
161
|
}
|
|
162
|
-
/* v8 ignore start */
|
|
162
|
+
/* v8 ignore start -- Not covered by tests; JSDoc-specific type handling */
|
|
163
163
|
} else if (parsedType?.type.startsWith('JsdocType')) {
|
|
164
164
|
result += `{${prattStringify(
|
|
165
165
|
/** @type {import('@cjser/jsdoc-type-pratt-parser').RootResult} */ (
|
|
166
166
|
parsedType
|
|
167
167
|
)
|
|
168
168
|
)}}`;
|
|
169
|
-
/* v8 ignore stop */
|
|
169
|
+
/* v8 ignore stop -- End of untested JSDoc-specific type handling */
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
// Check if the name appears on a separate line from the tag/type
|
|
@@ -178,7 +178,8 @@ function JsdocTag (node, opts) {
|
|
|
178
178
|
|
|
179
179
|
if (descriptionLines.length > 0) {
|
|
180
180
|
const firstDescLine = descriptionLines[0];
|
|
181
|
-
/* v8 ignore next
|
|
181
|
+
/* v8 ignore next 4 -- Defensive: blank first line not
|
|
182
|
+
expected in practice */
|
|
182
183
|
if (firstDescLine.description === '' && firstDescLine.delimiter === '' &&
|
|
183
184
|
firstDescLine.postDelimiter === '' && firstDescLine.initial === '') {
|
|
184
185
|
// Empty first line, check if there's a second line with formatting
|
|
@@ -193,21 +194,22 @@ function JsdocTag (node, opts) {
|
|
|
193
194
|
}`;
|
|
194
195
|
nameLineOffset = 2;
|
|
195
196
|
} else {
|
|
196
|
-
/* v8 ignore start */
|
|
197
|
+
/* v8 ignore start -- Fallback is not expected to occur normally */
|
|
197
198
|
// Fallback: just add name (shouldn't normally happen)
|
|
198
199
|
result += name + postName;
|
|
199
200
|
nameLineOffset = 1;
|
|
200
|
-
/* v8 ignore stop */
|
|
201
|
+
/* v8 ignore stop -- End of fallback */
|
|
201
202
|
}
|
|
202
203
|
} else {
|
|
203
|
-
|
|
204
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
205
|
+
/* v8 ignore start -- Not covered by tests; first description line with content */
|
|
204
206
|
// First description line has content, use it for the name line
|
|
205
207
|
const nameLine = descriptionLines[0];
|
|
206
208
|
result += `${nameLine.initial}${
|
|
207
209
|
nameLine.delimiter
|
|
208
210
|
}${nameLine.postDelimiter}${name}${postName}${nameLine.description}`;
|
|
209
211
|
nameLineOffset = 1;
|
|
210
|
-
/* v8 ignore stop */
|
|
212
|
+
/* v8 ignore stop -- End of untested branch */
|
|
211
213
|
}
|
|
212
214
|
} else {
|
|
213
215
|
// No description lines, need to construct the name line
|
package/src/jsdoccomment.js
CHANGED
|
@@ -90,12 +90,12 @@ const looksLikeExport = function (astNode) {
|
|
|
90
90
|
*/
|
|
91
91
|
const getTSFunctionComment = function (astNode) {
|
|
92
92
|
const {parent} = astNode;
|
|
93
|
-
/* v8 ignore next 3 */
|
|
93
|
+
/* v8 ignore next 3 -- Defensive: nodes are expected to have a parent */
|
|
94
94
|
if (!parent) {
|
|
95
95
|
return astNode;
|
|
96
96
|
}
|
|
97
97
|
const grandparent = parent.parent;
|
|
98
|
-
/* v8 ignore next 3 */
|
|
98
|
+
/* v8 ignore next 3 -- Defensive: parent is expected to have a parent */
|
|
99
99
|
if (!grandparent) {
|
|
100
100
|
return astNode;
|
|
101
101
|
}
|
|
@@ -106,10 +106,10 @@ const getTSFunctionComment = function (astNode) {
|
|
|
106
106
|
grandparent.type === 'ExportNamedDeclaration'
|
|
107
107
|
) {
|
|
108
108
|
return grandparent;
|
|
109
|
-
/* v8 ignore start */
|
|
109
|
+
/* v8 ignore start -- Defensive: other node types not expected here */
|
|
110
110
|
}
|
|
111
111
|
return astNode;
|
|
112
|
-
/* v8 ignore stop */
|
|
112
|
+
/* v8 ignore stop -- End of defensive fallback */
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
const greatGrandparent = grandparent.parent;
|
|
@@ -123,7 +123,8 @@ const getTSFunctionComment = function (astNode) {
|
|
|
123
123
|
case 'TSPropertySignature':
|
|
124
124
|
return grandparent;
|
|
125
125
|
case 'ArrowFunctionExpression':
|
|
126
|
-
|
|
126
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
127
|
+
/* v8 ignore next 3 -- Defensive: arrow functions are expected to be nested */
|
|
127
128
|
if (!greatGrandparent) {
|
|
128
129
|
return astNode;
|
|
129
130
|
}
|
|
@@ -133,17 +134,17 @@ const getTSFunctionComment = function (astNode) {
|
|
|
133
134
|
|
|
134
135
|
// && greatGreatGrandparent.parent.type === 'VariableDeclaration'
|
|
135
136
|
) {
|
|
136
|
-
/* v8 ignore next 3 */
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
/* v8 ignore start */
|
|
137
|
+
/* v8 ignore next 3 -- Defensive: missing ancestors are not expected */
|
|
138
|
+
return !greatGreatGrandparent || !greatGreatGrandparent.parent
|
|
139
|
+
? astNode
|
|
140
|
+
: greatGreatGrandparent.parent;
|
|
141
|
+
/* v8 ignore start -- Defensive: other parent types not expected here */
|
|
142
142
|
}
|
|
143
143
|
return astNode;
|
|
144
|
-
/* v8 ignore stop */
|
|
144
|
+
/* v8 ignore stop -- End of defensive fallback */
|
|
145
145
|
case 'FunctionExpression':
|
|
146
|
-
|
|
146
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
147
|
+
/* v8 ignore next 3 -- Defensive: function expressions are expected to be nested */
|
|
147
148
|
if (!greatGreatGrandparent) {
|
|
148
149
|
return astNode;
|
|
149
150
|
}
|
|
@@ -153,38 +154,36 @@ const getTSFunctionComment = function (astNode) {
|
|
|
153
154
|
|
|
154
155
|
// Fallthrough
|
|
155
156
|
default:
|
|
156
|
-
|
|
157
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
158
|
+
/* v8 ignore next 3 -- Defensive: other grandparent types not expected here */
|
|
157
159
|
if (grandparent.type !== 'Identifier') {
|
|
158
160
|
return astNode;
|
|
159
161
|
}
|
|
160
162
|
}
|
|
161
163
|
|
|
162
|
-
/* v8 ignore next 3 */
|
|
164
|
+
/* v8 ignore next 3 -- Defensive: ancestor is expected to exist */
|
|
163
165
|
if (!greatGreatGrandparent) {
|
|
164
166
|
return astNode;
|
|
165
167
|
}
|
|
166
168
|
|
|
167
169
|
switch (greatGrandparent.type) {
|
|
168
170
|
case 'ArrowFunctionExpression':
|
|
169
|
-
|
|
170
|
-
greatGreatGrandparent.type === 'VariableDeclarator' &&
|
|
171
|
+
return greatGreatGrandparent.type === 'VariableDeclarator' &&
|
|
171
172
|
greatGreatGrandparent.parent.type === 'VariableDeclaration'
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return astNode;
|
|
173
|
+
? greatGreatGrandparent.parent
|
|
174
|
+
: astNode;
|
|
177
175
|
case 'FunctionDeclaration':
|
|
178
176
|
return greatGrandparent;
|
|
179
177
|
case 'VariableDeclarator':
|
|
180
|
-
|
|
178
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
179
|
+
/* v8 ignore next -- Else branch (non-declaration) not expected for variable declarators */
|
|
181
180
|
if (greatGreatGrandparent.type === 'VariableDeclaration') {
|
|
182
181
|
return greatGreatGrandparent;
|
|
183
182
|
}
|
|
184
|
-
/* v8 ignore next 2 */
|
|
183
|
+
/* v8 ignore next 2 -- Defensive fallthrough to default */
|
|
185
184
|
// Fallthrough
|
|
186
185
|
default:
|
|
187
|
-
/* v8 ignore next 3 */
|
|
186
|
+
/* v8 ignore next 3 -- Defensive default; unreachable in practice */
|
|
188
187
|
return astNode;
|
|
189
188
|
}
|
|
190
189
|
};
|
|
@@ -235,7 +234,8 @@ const getReducedASTNode = function (nodeInput, sourceCode, settings) {
|
|
|
235
234
|
case 'TSEnumDeclaration':
|
|
236
235
|
case 'ClassDeclaration':
|
|
237
236
|
case 'FunctionDeclaration':
|
|
238
|
-
|
|
237
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
238
|
+
/* v8 ignore next 3 -- Defensive: declarations are expected to have a parent */
|
|
239
239
|
if (!parent) {
|
|
240
240
|
return node;
|
|
241
241
|
}
|
|
@@ -247,7 +247,8 @@ const getReducedASTNode = function (nodeInput, sourceCode, settings) {
|
|
|
247
247
|
case 'ArrowFunctionExpression':
|
|
248
248
|
case 'TSEmptyBodyFunctionExpression':
|
|
249
249
|
case 'FunctionExpression':
|
|
250
|
-
|
|
250
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
251
|
+
/* v8 ignore next 3 -- Defensive: function expressions are expected to have a parent */
|
|
251
252
|
if (!parent) {
|
|
252
253
|
return node;
|
|
253
254
|
}
|
|
@@ -295,11 +296,10 @@ const getReducedASTNode = function (nodeInput, sourceCode, settings) {
|
|
|
295
296
|
if (parent && parent.type !== 'FunctionDeclaration' &&
|
|
296
297
|
parent.type !== 'Program'
|
|
297
298
|
) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
return parent;
|
|
299
|
+
return parent.parent &&
|
|
300
|
+
parent.parent.type === 'ExportNamedDeclaration'
|
|
301
|
+
? parent.parent
|
|
302
|
+
: parent;
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
|
|
@@ -365,7 +365,8 @@ const findJSDocComment = (astNode, sourceCode, settings, opts = {}) => {
|
|
|
365
365
|
break;
|
|
366
366
|
}
|
|
367
367
|
|
|
368
|
-
|
|
368
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
369
|
+
/* v8 ignore next 3 -- Defensive: tokens and locations are expected to exist */
|
|
369
370
|
if (!tokenBefore || !currentNode.loc || !tokenBefore.loc) {
|
|
370
371
|
return null;
|
|
371
372
|
}
|
|
@@ -635,7 +636,8 @@ const getNonJsdocComment = function (sourceCode, node, settings) {
|
|
|
635
636
|
* AST node or token to compare
|
|
636
637
|
*/
|
|
637
638
|
const compareLocEndToStart = (nodeA, nodeB) => {
|
|
638
|
-
|
|
639
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
640
|
+
/* v8 ignore next -- Defensive: fallback only for nodes lacking location info */
|
|
639
641
|
return (nodeA.loc?.end.line ?? 0) === (nodeB.loc?.start.line ?? 0);
|
|
640
642
|
};
|
|
641
643
|
|
|
@@ -708,7 +710,7 @@ const getFollowingComment = function (sourceCode, astNodeInput) {
|
|
|
708
710
|
);
|
|
709
711
|
break;
|
|
710
712
|
|
|
711
|
-
/* v8 ignore next 3 */
|
|
713
|
+
/* v8 ignore next 3 -- Defensive: no other node types expected */
|
|
712
714
|
default:
|
|
713
715
|
break;
|
|
714
716
|
}
|
package/src/parseComment.js
CHANGED
|
@@ -73,11 +73,7 @@ const getTokenizers = ({
|
|
|
73
73
|
* @returns {import('comment-parser').Spec}
|
|
74
74
|
*/
|
|
75
75
|
(spec) => {
|
|
76
|
-
|
|
77
|
-
return spec;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return preserveTypeTokenizer(spec);
|
|
76
|
+
return noTypes.includes(spec.tag) ? spec : preserveTypeTokenizer(spec);
|
|
81
77
|
},
|
|
82
78
|
|
|
83
79
|
/**
|
|
@@ -127,11 +123,9 @@ const getTokenizers = ({
|
|
|
127
123
|
return spec;
|
|
128
124
|
}
|
|
129
125
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return plainNameTokenizer(spec);
|
|
126
|
+
return noNames.includes(spec.tag) || hasSeeWithLink(spec)
|
|
127
|
+
? spec
|
|
128
|
+
: plainNameTokenizer(spec);
|
|
135
129
|
},
|
|
136
130
|
|
|
137
131
|
/**
|
package/src/parseInlineTags.js
CHANGED