eslint-plugin-jsdoc 50.6.17 → 50.7.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/dist/alignTransform.cjs +10 -10
- package/dist/alignTransform.cjs.map +1 -1
- package/dist/exportParser.cjs +141 -135
- package/dist/exportParser.cjs.map +1 -1
- package/dist/generateRule.cjs +10 -12
- package/dist/generateRule.cjs.map +1 -1
- package/dist/getDefaultTagStructureForMode.cjs +73 -73
- package/dist/getDefaultTagStructureForMode.cjs.map +1 -1
- package/dist/getJsdocProcessorPlugin.cjs +121 -110
- package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
- package/dist/index.cjs +17 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/iterateJsdoc.cjs +87 -66
- package/dist/iterateJsdoc.cjs.map +1 -1
- package/dist/jsdocUtils.cjs +144 -142
- package/dist/jsdocUtils.cjs.map +1 -1
- package/dist/rules/checkAlignment.cjs +2 -2
- package/dist/rules/checkAlignment.cjs.map +1 -1
- package/dist/rules/checkExamples.cjs +22 -28
- package/dist/rules/checkExamples.cjs.map +1 -1
- package/dist/rules/checkIndentation.cjs +2 -2
- package/dist/rules/checkIndentation.cjs.map +1 -1
- package/dist/rules/checkLineAlignment.cjs +14 -14
- package/dist/rules/checkLineAlignment.cjs.map +1 -1
- package/dist/rules/checkParamNames.cjs +21 -15
- package/dist/rules/checkParamNames.cjs.map +1 -1
- package/dist/rules/checkPropertyNames.cjs +2 -2
- package/dist/rules/checkPropertyNames.cjs.map +1 -1
- package/dist/rules/checkTagNames.cjs +11 -11
- package/dist/rules/checkTagNames.cjs.map +1 -1
- package/dist/rules/checkTemplateNames.cjs +21 -22
- package/dist/rules/checkTemplateNames.cjs.map +1 -1
- package/dist/rules/checkTypes.cjs +10 -10
- package/dist/rules/checkTypes.cjs.map +1 -1
- package/dist/rules/checkValues.cjs +11 -14
- package/dist/rules/checkValues.cjs.map +1 -1
- package/dist/rules/convertToJsdocComments.cjs +26 -27
- package/dist/rules/convertToJsdocComments.cjs.map +1 -1
- package/dist/rules/emptyTags.cjs +6 -6
- package/dist/rules/emptyTags.cjs.map +1 -1
- package/dist/rules/importsAsDependencies.cjs.map +1 -1
- package/dist/rules/informativeDocs.cjs +12 -12
- package/dist/rules/informativeDocs.cjs.map +1 -1
- package/dist/rules/linesBeforeBlock.cjs +12 -12
- package/dist/rules/linesBeforeBlock.cjs.map +1 -1
- package/dist/rules/matchDescription.cjs +1 -1
- package/dist/rules/matchDescription.cjs.map +1 -1
- package/dist/rules/matchName.cjs +4 -4
- package/dist/rules/matchName.cjs.map +1 -1
- package/dist/rules/multilineBlocks.cjs +10 -10
- package/dist/rules/multilineBlocks.cjs.map +1 -1
- package/dist/rules/noBadBlocks.cjs +3 -3
- package/dist/rules/noBadBlocks.cjs.map +1 -1
- package/dist/rules/noMultiAsterisks.cjs +6 -6
- package/dist/rules/noMultiAsterisks.cjs.map +1 -1
- package/dist/rules/noRestrictedSyntax.cjs +2 -2
- package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
- package/dist/rules/noTypes.cjs.map +1 -1
- package/dist/rules/noUndefinedTypes.cjs +17 -20
- package/dist/rules/noUndefinedTypes.cjs.map +1 -1
- package/dist/rules/requireAsteriskPrefix.cjs +4 -4
- package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
- package/dist/rules/requireDescription.cjs +2 -2
- package/dist/rules/requireDescription.cjs.map +1 -1
- package/dist/rules/requireDescriptionCompleteSentence.cjs +8 -8
- package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
- package/dist/rules/requireFileOverview.cjs +6 -6
- package/dist/rules/requireFileOverview.cjs.map +1 -1
- package/dist/rules/requireHyphenBeforeParamDescription.cjs +1 -4
- package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
- package/dist/rules/requireJsdoc.cjs +19 -19
- package/dist/rules/requireJsdoc.cjs.map +1 -1
- package/dist/rules/requireParam.cjs +12 -12
- package/dist/rules/requireParam.cjs.map +1 -1
- package/dist/rules/requireProperty.cjs +1 -1
- package/dist/rules/requireProperty.cjs.map +1 -1
- package/dist/rules/requireReturns.cjs +3 -3
- package/dist/rules/requireReturns.cjs.map +1 -1
- package/dist/rules/requireReturnsCheck.cjs +1 -1
- package/dist/rules/requireReturnsCheck.cjs.map +1 -1
- package/dist/rules/requireReturnsDescription.cjs +1 -1
- package/dist/rules/requireReturnsDescription.cjs.map +1 -1
- package/dist/rules/requireTemplate.cjs +16 -15
- package/dist/rules/requireTemplate.cjs.map +1 -1
- package/dist/rules/requireYields.cjs +4 -4
- package/dist/rules/requireYields.cjs.map +1 -1
- package/dist/rules/requireYieldsCheck.cjs +6 -6
- package/dist/rules/requireYieldsCheck.cjs.map +1 -1
- package/dist/rules/sortTags.cjs +13 -13
- package/dist/rules/sortTags.cjs.map +1 -1
- package/dist/rules/tagLines.cjs +11 -11
- package/dist/rules/tagLines.cjs.map +1 -1
- package/dist/rules/textEscaping.cjs +2 -2
- package/dist/rules/textEscaping.cjs.map +1 -1
- package/dist/rules/validTypes.cjs +15 -15
- package/dist/rules/validTypes.cjs.map +1 -1
- package/dist/tagNames.cjs +1 -1
- package/dist/tagNames.cjs.map +1 -1
- package/dist/utils/hasReturnValue.cjs +176 -176
- package/dist/utils/hasReturnValue.cjs.map +1 -1
- package/eslint.config.js +36 -32
- package/package.json +30 -30
- package/pnpm-workspace.yaml +1 -0
- package/src/alignTransform.js +15 -15
- package/src/exportParser.js +386 -373
- package/src/getDefaultTagStructureForMode.js +45 -45
- package/src/getJsdocProcessorPlugin.js +175 -128
- package/src/index.js +66 -37
- package/src/iterateJsdoc.js +61 -28
- package/src/jsdocUtils.js +354 -338
- package/src/rules/checkAlignment.js +2 -2
- package/src/rules/checkExamples.js +16 -20
- package/src/rules/checkIndentation.js +2 -2
- package/src/rules/checkLineAlignment.js +10 -10
- package/src/rules/checkParamNames.js +22 -14
- package/src/rules/checkPropertyNames.js +1 -1
- package/src/rules/checkTagNames.js +7 -7
- package/src/rules/checkTemplateNames.js +52 -38
- package/src/rules/checkTypes.js +7 -7
- package/src/rules/checkValues.js +16 -17
- package/src/rules/convertToJsdocComments.js +47 -37
- package/src/rules/emptyTags.js +14 -7
- package/src/rules/importsAsDependencies.js +3 -1
- package/src/rules/informativeDocs.js +58 -58
- package/src/rules/linesBeforeBlock.js +25 -17
- package/src/rules/matchDescription.js +1 -1
- package/src/rules/matchName.js +2 -2
- package/src/rules/multilineBlocks.js +10 -10
- package/src/rules/noBadBlocks.js +3 -3
- package/src/rules/noMultiAsterisks.js +4 -4
- package/src/rules/noRestrictedSyntax.js +1 -1
- package/src/rules/noTypes.js +1 -1
- package/src/rules/noUndefinedTypes.js +29 -23
- package/src/rules/requireAsteriskPrefix.js +3 -3
- package/src/rules/requireDescription.js +1 -1
- package/src/rules/requireDescriptionCompleteSentence.js +6 -6
- package/src/rules/requireFileOverview.js +3 -3
- package/src/rules/requireHyphenBeforeParamDescription.js +2 -5
- package/src/rules/requireJsdoc.js +14 -14
- package/src/rules/requireParam.js +9 -9
- package/src/rules/requireProperty.js +1 -1
- package/src/rules/requireReturns.js +1 -1
- package/src/rules/requireReturnsCheck.js +1 -1
- package/src/rules/requireReturnsDescription.js +1 -1
- package/src/rules/requireTemplate.js +59 -38
- package/src/rules/requireYields.js +3 -3
- package/src/rules/requireYieldsCheck.js +1 -1
- package/src/rules/sortTags.js +7 -7
- package/src/rules/tagLines.js +8 -8
- package/src/rules/textEscaping.js +2 -0
- package/src/rules/validTypes.js +29 -29
- package/src/tagNames.js +2 -2
- package/src/utils/hasReturnValue.js +298 -283
package/dist/iterateJsdoc.cjs
CHANGED
|
@@ -16,8 +16,7 @@ var _jsdoccomment = require("@es-joy/jsdoccomment");
|
|
|
16
16
|
var _commentParser = require("comment-parser");
|
|
17
17
|
var _esquery = _interopRequireDefault(require("esquery"));
|
|
18
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
-
function
|
|
20
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
21
20
|
/**
|
|
22
21
|
* @typedef {number} Integer
|
|
23
22
|
*/
|
|
@@ -602,8 +601,8 @@ const globalState = new Map();
|
|
|
602
601
|
* @returns {BasicUtils}
|
|
603
602
|
*/
|
|
604
603
|
const getBasicUtils = (context, {
|
|
605
|
-
|
|
606
|
-
|
|
604
|
+
mode,
|
|
605
|
+
tagNamePreference
|
|
607
606
|
}) => {
|
|
608
607
|
/** @type {BasicUtils} */
|
|
609
608
|
const utils = {};
|
|
@@ -685,19 +684,19 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
685
684
|
} = context;
|
|
686
685
|
const utils = /** @type {Utils} */getBasicUtils(context, settings);
|
|
687
686
|
const {
|
|
688
|
-
|
|
689
|
-
overrideReplacesDocs,
|
|
687
|
+
augmentsExtendsReplacesDocs,
|
|
690
688
|
ignoreReplacesDocs,
|
|
691
689
|
implementsReplacesDocs,
|
|
692
|
-
augmentsExtendsReplacesDocs,
|
|
693
690
|
maxLines,
|
|
694
691
|
minLines,
|
|
695
|
-
mode
|
|
692
|
+
mode,
|
|
693
|
+
overrideReplacesDocs,
|
|
694
|
+
tagNamePreference
|
|
696
695
|
} = settings;
|
|
697
696
|
|
|
698
697
|
/** @type {IsIteratingFunction} */
|
|
699
698
|
utils.isIteratingFunction = () => {
|
|
700
|
-
return !iteratingAll || ['
|
|
699
|
+
return !iteratingAll || ['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'MethodDefinition'].includes(String(node && node.type));
|
|
701
700
|
};
|
|
702
701
|
|
|
703
702
|
/** @type {IsVirtualFunction} */
|
|
@@ -711,7 +710,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
711
710
|
if (specRewire) {
|
|
712
711
|
block = rewireSpecs(tagBlock);
|
|
713
712
|
}
|
|
714
|
-
return (0, _commentParser.stringify)(
|
|
713
|
+
return (0, _commentParser.stringify)(/** @type {import('comment-parser').Block} */
|
|
715
714
|
specRewire ? block : tagBlock);
|
|
716
715
|
};
|
|
717
716
|
|
|
@@ -769,8 +768,8 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
769
768
|
jsdoc.source.some(({
|
|
770
769
|
tokens: {
|
|
771
770
|
description,
|
|
772
|
-
|
|
773
|
-
|
|
771
|
+
end,
|
|
772
|
+
tag
|
|
774
773
|
}
|
|
775
774
|
}, idx) => {
|
|
776
775
|
if (tag) {
|
|
@@ -818,12 +817,12 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
818
817
|
let info;
|
|
819
818
|
jsdoc.source.some(({
|
|
820
819
|
tokens: {
|
|
821
|
-
description,
|
|
822
|
-
start,
|
|
823
820
|
delimiter,
|
|
821
|
+
description,
|
|
822
|
+
end,
|
|
824
823
|
postDelimiter,
|
|
825
|
-
|
|
826
|
-
|
|
824
|
+
start,
|
|
825
|
+
tag
|
|
827
826
|
}
|
|
828
827
|
}, idx) => {
|
|
829
828
|
if (delimiter === '/**') {
|
|
@@ -847,7 +846,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
847
846
|
|
|
848
847
|
/* c8 ignore else -- Won't be called if missing */
|
|
849
848
|
if (descLines.length) {
|
|
850
|
-
jsdoc.source.splice(
|
|
849
|
+
jsdoc.source.splice(/** @type {Integer} */startIdx, /** @type {Integer} */endIdx - (/** @type {Integer} */startIdx), ...setter(
|
|
851
850
|
/**
|
|
852
851
|
* @type {{
|
|
853
852
|
* delimiter: string,
|
|
@@ -865,8 +864,8 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
865
864
|
jsdoc.source.some(({
|
|
866
865
|
tokens: {
|
|
867
866
|
description,
|
|
868
|
-
|
|
869
|
-
|
|
867
|
+
end,
|
|
868
|
+
tag
|
|
870
869
|
}
|
|
871
870
|
}, idx) => {
|
|
872
871
|
/* c8 ignore next 3 -- Already checked */
|
|
@@ -933,8 +932,8 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
933
932
|
let spliceCount = 1;
|
|
934
933
|
tagSource.slice(tagIdx + 1).some(({
|
|
935
934
|
tokens: {
|
|
936
|
-
|
|
937
|
-
|
|
935
|
+
end: ending,
|
|
936
|
+
tag
|
|
938
937
|
}
|
|
939
938
|
}) => {
|
|
940
939
|
if (!tag && !ending) {
|
|
@@ -967,11 +966,12 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
967
966
|
lastIndex = sourceIndex;
|
|
968
967
|
return true;
|
|
969
968
|
}
|
|
970
|
-
/* c8 ignore next */
|
|
969
|
+
/* c8 ignore next 2 */
|
|
970
|
+
// eslint-disable-next-line @stylistic/padding-line-between-statements -- c8
|
|
971
971
|
return false;
|
|
972
972
|
});
|
|
973
973
|
for (const [idx, src] of jsdoc.source.slice(lastIndex).entries()) {
|
|
974
|
-
src.number = firstNumber + (
|
|
974
|
+
src.number = firstNumber + (/** @type {Integer} */lastIndex) + idx;
|
|
975
975
|
}
|
|
976
976
|
|
|
977
977
|
// Todo: Once rewiring of tags may be fixed in comment-parser to reflect
|
|
@@ -1095,11 +1095,12 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
1095
1095
|
lastIndex = sourceIndex;
|
|
1096
1096
|
return true;
|
|
1097
1097
|
}
|
|
1098
|
-
/* c8 ignore next */
|
|
1098
|
+
/* c8 ignore next 2 */
|
|
1099
|
+
// eslint-disable-next-line @stylistic/padding-line-between-statements -- c8
|
|
1099
1100
|
return false;
|
|
1100
1101
|
});
|
|
1101
1102
|
for (const [idx, src] of jsdoc.source.slice(lastIndex).entries()) {
|
|
1102
|
-
src.number = firstNumber + (
|
|
1103
|
+
src.number = firstNumber + (/** @type {Integer} */lastIndex) + idx;
|
|
1103
1104
|
}
|
|
1104
1105
|
};
|
|
1105
1106
|
|
|
@@ -1111,11 +1112,11 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
1111
1112
|
}]
|
|
1112
1113
|
} = jsdoc;
|
|
1113
1114
|
const {
|
|
1114
|
-
postDelimiter,
|
|
1115
1115
|
description,
|
|
1116
1116
|
lineEnd,
|
|
1117
|
-
tag,
|
|
1118
1117
|
name,
|
|
1118
|
+
postDelimiter,
|
|
1119
|
+
tag,
|
|
1119
1120
|
type
|
|
1120
1121
|
} = tokens;
|
|
1121
1122
|
let {
|
|
@@ -1170,7 +1171,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
1170
1171
|
|
|
1171
1172
|
/** @type {HasParams} */
|
|
1172
1173
|
utils.hasParams = () => {
|
|
1173
|
-
return jsdocUtils.hasParams(
|
|
1174
|
+
return jsdocUtils.hasParams(/** @type {Node} */node);
|
|
1174
1175
|
};
|
|
1175
1176
|
|
|
1176
1177
|
/** @type {IsGenerator} */
|
|
@@ -1181,7 +1182,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
1181
1182
|
* @type {import('estree').FunctionDeclaration|
|
|
1182
1183
|
* import('estree').FunctionExpression}
|
|
1183
1184
|
*/
|
|
1184
|
-
node.generator || node.type === 'MethodDefinition' && node.value.generator || ['
|
|
1185
|
+
node.generator || node.type === 'MethodDefinition' && node.value.generator || ['ExportDefaultDeclaration', 'ExportNamedDeclaration'].includes(node.type) && (/** @type {import('estree').FunctionDeclaration} */(_node$declaration =
|
|
1185
1186
|
/**
|
|
1186
1187
|
* @type {import('estree').ExportNamedDeclaration|
|
|
1187
1188
|
* import('estree').ExportDefaultDeclaration}
|
|
@@ -1191,7 +1192,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
1191
1192
|
|
|
1192
1193
|
/** @type {IsConstructor} */
|
|
1193
1194
|
utils.isConstructor = () => {
|
|
1194
|
-
return jsdocUtils.isConstructor(
|
|
1195
|
+
return jsdocUtils.isConstructor(/** @type {Node} */node);
|
|
1195
1196
|
};
|
|
1196
1197
|
|
|
1197
1198
|
/** @type {GetJsdocTagsDeep} */
|
|
@@ -1259,9 +1260,9 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
1259
1260
|
};
|
|
1260
1261
|
for (const method of ['tagMightHaveNamePosition', 'tagMightHaveTypePosition']) {
|
|
1261
1262
|
/** @type {TagMightHaveNamePositionTypePosition} */
|
|
1262
|
-
utils[(
|
|
1263
|
+
utils[(/** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */
|
|
1263
1264
|
method)] = (tagName, otherModeMaps) => {
|
|
1264
|
-
const result = jsdocUtils[(
|
|
1265
|
+
const result = jsdocUtils[(/** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */
|
|
1265
1266
|
method)](tagName);
|
|
1266
1267
|
if (result) {
|
|
1267
1268
|
return true;
|
|
@@ -1270,7 +1271,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
1270
1271
|
return false;
|
|
1271
1272
|
}
|
|
1272
1273
|
const otherResult = otherModeMaps.some(otherModeMap => {
|
|
1273
|
-
return jsdocUtils[(
|
|
1274
|
+
return jsdocUtils[(/** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */
|
|
1274
1275
|
method)](tagName, otherModeMap);
|
|
1275
1276
|
});
|
|
1276
1277
|
return otherResult ? {
|
|
@@ -1294,9 +1295,9 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
1294
1295
|
};
|
|
1295
1296
|
for (const method of ['tagMustHaveNamePosition', 'tagMustHaveTypePosition']) {
|
|
1296
1297
|
/** @type {TagMustHave} */
|
|
1297
|
-
utils[(
|
|
1298
|
+
utils[(/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */
|
|
1298
1299
|
method)] = (tagName, otherModeMaps) => {
|
|
1299
|
-
const result = jsdocUtils[(
|
|
1300
|
+
const result = jsdocUtils[(/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */
|
|
1300
1301
|
method)](tagName);
|
|
1301
1302
|
if (!result) {
|
|
1302
1303
|
return false;
|
|
@@ -1305,7 +1306,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
1305
1306
|
// if (!otherModeMaps) { return true; }
|
|
1306
1307
|
|
|
1307
1308
|
const otherResult = otherModeMaps.every(otherModeMap => {
|
|
1308
|
-
return jsdocUtils[(
|
|
1309
|
+
return jsdocUtils[(/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */
|
|
1309
1310
|
method)](tagName, otherModeMap);
|
|
1310
1311
|
});
|
|
1311
1312
|
return otherResult ? true : {
|
|
@@ -1315,9 +1316,9 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
1315
1316
|
}
|
|
1316
1317
|
for (const method of ['isNamepathDefiningTag', 'isNamepathReferencingTag', 'isNamepathOrUrlReferencingTag', 'tagMightHaveNamepath']) {
|
|
1317
1318
|
/** @type {IsNamepathX} */
|
|
1318
|
-
utils[(
|
|
1319
|
+
utils[(/** @type {"isNamepathDefiningTag"|"isNamepathReferencingTag"|"isNamepathOrUrlReferencingTag"|"tagMightHaveNamepath"} */
|
|
1319
1320
|
method)] = tagName => {
|
|
1320
|
-
return jsdocUtils[(
|
|
1321
|
+
return jsdocUtils[(/** @type {"isNamepathDefiningTag"|"isNamepathReferencingTag"|"isNamepathOrUrlReferencingTag"|"tagMightHaveNamepath"} */
|
|
1321
1322
|
method)](tagName);
|
|
1322
1323
|
};
|
|
1323
1324
|
}
|
|
@@ -1334,22 +1335,22 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
1334
1335
|
|
|
1335
1336
|
/** @type {HasValueOrExecutorHasNonEmptyResolveValue} */
|
|
1336
1337
|
utils.hasValueOrExecutorHasNonEmptyResolveValue = (anyPromiseAsReturn, allBranches) => {
|
|
1337
|
-
return jsdocUtils.hasValueOrExecutorHasNonEmptyResolveValue(
|
|
1338
|
+
return jsdocUtils.hasValueOrExecutorHasNonEmptyResolveValue(/** @type {Node} */node, anyPromiseAsReturn, allBranches);
|
|
1338
1339
|
};
|
|
1339
1340
|
|
|
1340
1341
|
/** @type {HasYieldValue} */
|
|
1341
1342
|
utils.hasYieldValue = () => {
|
|
1342
|
-
if (['
|
|
1343
|
-
return jsdocUtils.hasYieldValue(
|
|
1343
|
+
if (['ExportDefaultDeclaration', 'ExportNamedDeclaration'].includes(/** @type {Node} */node.type)) {
|
|
1344
|
+
return jsdocUtils.hasYieldValue(/** @type {import('estree').Declaration|import('estree').Expression} */
|
|
1344
1345
|
/** @type {import('estree').ExportNamedDeclaration|import('estree').ExportDefaultDeclaration} */
|
|
1345
1346
|
node.declaration);
|
|
1346
1347
|
}
|
|
1347
|
-
return jsdocUtils.hasYieldValue(
|
|
1348
|
+
return jsdocUtils.hasYieldValue(/** @type {Node} */node);
|
|
1348
1349
|
};
|
|
1349
1350
|
|
|
1350
1351
|
/** @type {HasYieldReturnValue} */
|
|
1351
1352
|
utils.hasYieldReturnValue = () => {
|
|
1352
|
-
return jsdocUtils.hasYieldValue(
|
|
1353
|
+
return jsdocUtils.hasYieldValue(/** @type {Node} */node, true);
|
|
1353
1354
|
};
|
|
1354
1355
|
|
|
1355
1356
|
/** @type {HasThrowValue} */
|
|
@@ -1434,10 +1435,10 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
1434
1435
|
/** @type {ForEachPreferredTag} */
|
|
1435
1436
|
utils.forEachPreferredTag = (tagName, arrayHandler, skipReportingBlockedTag) => {
|
|
1436
1437
|
return jsdocUtils.forEachPreferredTag(jsdoc, tagName, arrayHandler, {
|
|
1437
|
-
skipReportingBlockedTag,
|
|
1438
1438
|
context,
|
|
1439
1439
|
mode,
|
|
1440
1440
|
report,
|
|
1441
|
+
skipReportingBlockedTag,
|
|
1441
1442
|
tagNamePreference
|
|
1442
1443
|
});
|
|
1443
1444
|
};
|
|
@@ -1445,9 +1446,9 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
1445
1446
|
/** @type {FindContext} */
|
|
1446
1447
|
utils.findContext = (contexts, comment) => {
|
|
1447
1448
|
const foundContext = contexts.find(cntxt => {
|
|
1448
|
-
return typeof cntxt === 'string' ? _esquery.default.matches(
|
|
1449
|
+
return typeof cntxt === 'string' ? _esquery.default.matches(/** @type {Node} */node, _esquery.default.parse(cntxt), undefined, {
|
|
1449
1450
|
visitorKeys: sourceCode.visitorKeys
|
|
1450
|
-
}) : (!cntxt.context || cntxt.context === 'any' || _esquery.default.matches(
|
|
1451
|
+
}) : (!cntxt.context || cntxt.context === 'any' || _esquery.default.matches(/** @type {Node} */node, _esquery.default.parse(cntxt.context), undefined, {
|
|
1451
1452
|
visitorKeys: sourceCode.visitorKeys
|
|
1452
1453
|
})) && comment === cntxt.comment;
|
|
1453
1454
|
});
|
|
@@ -1493,12 +1494,35 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iterati
|
|
|
1493
1494
|
*/
|
|
1494
1495
|
|
|
1495
1496
|
/**
|
|
1496
|
-
* @
|
|
1497
|
+
* @typedef {{
|
|
1498
|
+
* settings?: {
|
|
1499
|
+
* jsdoc?: {
|
|
1500
|
+
* ignorePrivate: boolean,
|
|
1501
|
+
* ignoreInternal: boolean,
|
|
1502
|
+
* maxLines: Integer,
|
|
1503
|
+
* minLines: Integer,
|
|
1504
|
+
* tagNamePreference: import('./jsdocUtils.js').TagNamePreference,
|
|
1505
|
+
* preferredTypes: PreferredTypes,
|
|
1506
|
+
* structuredTags: StructuredTags,
|
|
1507
|
+
* overrideReplacesDocs: boolean,
|
|
1508
|
+
* ignoreReplacesDocs: boolean,
|
|
1509
|
+
* implementsReplacesDocs: boolean,
|
|
1510
|
+
* augmentsExtendsReplacesDocs: boolean,
|
|
1511
|
+
* exemptDestructuredRootsFromChecks: boolean,
|
|
1512
|
+
* mode: import('./jsdocUtils.js').ParserMode,
|
|
1513
|
+
* contexts: Context[],
|
|
1514
|
+
* }
|
|
1515
|
+
* }
|
|
1516
|
+
* }} JSDocSettings
|
|
1517
|
+
*/
|
|
1518
|
+
|
|
1519
|
+
/**
|
|
1520
|
+
* @param {import('eslint').Rule.RuleContext & JSDocSettings} context
|
|
1497
1521
|
* @returns {Settings|false}
|
|
1498
1522
|
*/
|
|
1499
1523
|
const getSettings = context => {
|
|
1500
|
-
var _context$settings$jsd, _context$settings$jsd2, _context$settings$jsd3, _context$settings$jsd4, _context$settings$jsd5, _context$settings$jsd6, _context$settings$jsd7, _context$settings$jsd8, _context$settings$jsd9, _context$settings$
|
|
1501
|
-
/*
|
|
1524
|
+
var _context$settings$jsd, _context$settings$jsd2, _context$settings$jsd3, _context$settings$jsd4, _context$settings$jsd5, _context$settings$jsd6, _context$settings$jsd7, _context$settings$jsd8, _context$settings$jsd9, _context$settings$jsd0, _context$settings$jsd1, _context$settings$jsd10, _context$settings$jsd11, _context$settings$jsd12;
|
|
1525
|
+
/* eslint-disable perfectionist/sort-objects */
|
|
1502
1526
|
const settings = {
|
|
1503
1527
|
// All rules
|
|
1504
1528
|
ignorePrivate: Boolean((_context$settings$jsd = context.settings.jsdoc) === null || _context$settings$jsd === void 0 ? void 0 : _context$settings$jsd.ignorePrivate),
|
|
@@ -1515,16 +1539,16 @@ const getSettings = context => {
|
|
|
1515
1539
|
// `require-returns`, `require-throw`, `require-yields`
|
|
1516
1540
|
overrideReplacesDocs: (_context$settings$jsd8 = context.settings.jsdoc) === null || _context$settings$jsd8 === void 0 ? void 0 : _context$settings$jsd8.overrideReplacesDocs,
|
|
1517
1541
|
ignoreReplacesDocs: (_context$settings$jsd9 = context.settings.jsdoc) === null || _context$settings$jsd9 === void 0 ? void 0 : _context$settings$jsd9.ignoreReplacesDocs,
|
|
1518
|
-
implementsReplacesDocs: (_context$settings$
|
|
1519
|
-
augmentsExtendsReplacesDocs: (_context$settings$
|
|
1542
|
+
implementsReplacesDocs: (_context$settings$jsd0 = context.settings.jsdoc) === null || _context$settings$jsd0 === void 0 ? void 0 : _context$settings$jsd0.implementsReplacesDocs,
|
|
1543
|
+
augmentsExtendsReplacesDocs: (_context$settings$jsd1 = context.settings.jsdoc) === null || _context$settings$jsd1 === void 0 ? void 0 : _context$settings$jsd1.augmentsExtendsReplacesDocs,
|
|
1520
1544
|
// `require-param-type`, `require-param-description`
|
|
1521
|
-
exemptDestructuredRootsFromChecks: (_context$settings$
|
|
1545
|
+
exemptDestructuredRootsFromChecks: (_context$settings$jsd10 = context.settings.jsdoc) === null || _context$settings$jsd10 === void 0 ? void 0 : _context$settings$jsd10.exemptDestructuredRootsFromChecks,
|
|
1522
1546
|
// Many rules, e.g., `check-tag-names`
|
|
1523
|
-
mode: ((_context$settings$
|
|
1547
|
+
mode: ((_context$settings$jsd11 = context.settings.jsdoc) === null || _context$settings$jsd11 === void 0 ? void 0 : _context$settings$jsd11.mode) ?? 'typescript',
|
|
1524
1548
|
// Many rules
|
|
1525
|
-
contexts: (_context$settings$
|
|
1549
|
+
contexts: (_context$settings$jsd12 = context.settings.jsdoc) === null || _context$settings$jsd12 === void 0 ? void 0 : _context$settings$jsd12.contexts
|
|
1526
1550
|
};
|
|
1527
|
-
/*
|
|
1551
|
+
/* eslint-enable perfectionist/sort-objects */
|
|
1528
1552
|
|
|
1529
1553
|
jsdocUtils.setTagStructure(settings.mode);
|
|
1530
1554
|
try {
|
|
@@ -1566,7 +1590,7 @@ const makeReport = (context, commentNode) => {
|
|
|
1566
1590
|
if (!('line' in jsdocLoc)) {
|
|
1567
1591
|
jsdocLoc.line = /** @type {import('comment-parser').Spec & {line?: Integer}} */jsdocLoc.source[0].number;
|
|
1568
1592
|
}
|
|
1569
|
-
const lineNumber = /** @type {import('eslint').AST.SourceLocation} */commentNode.loc.start.line + (
|
|
1593
|
+
const lineNumber = /** @type {import('eslint').AST.SourceLocation} */commentNode.loc.start.line + (/** @type {Integer} */jsdocLoc.line);
|
|
1570
1594
|
loc = {
|
|
1571
1595
|
end: {
|
|
1572
1596
|
column: 0,
|
|
@@ -1577,8 +1601,6 @@ const makeReport = (context, commentNode) => {
|
|
|
1577
1601
|
line: lineNumber
|
|
1578
1602
|
}
|
|
1579
1603
|
};
|
|
1580
|
-
|
|
1581
|
-
// Todo: Remove ignore once `check-examples` can be restored for ESLint 8+
|
|
1582
1604
|
if ('column' in jsdocLoc && typeof jsdocLoc.column === 'number') {
|
|
1583
1605
|
const colNumber = /** @type {import('eslint').AST.SourceLocation} */commentNode.loc.start.column + jsdocLoc.column;
|
|
1584
1606
|
loc.end.column = colNumber;
|
|
@@ -1720,7 +1742,7 @@ const getIndentAndJSDoc = function (lines, jsdocNode) {
|
|
|
1720
1742
|
if (indentChar !== ' ' && indentChar !== '\t') {
|
|
1721
1743
|
indentChar = ' ';
|
|
1722
1744
|
}
|
|
1723
|
-
const indnt = indentChar.repeat(
|
|
1745
|
+
const indnt = indentChar.repeat(/** @type {import('estree').SourceLocation} */
|
|
1724
1746
|
jsdocNode.loc.start.column);
|
|
1725
1747
|
const jsdc = (0, _jsdoccomment.parseComment)(jsdocNode, '');
|
|
1726
1748
|
return [indnt, jsdc];
|
|
@@ -1796,7 +1818,7 @@ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContext
|
|
|
1796
1818
|
const utils = getBasicUtils(context, /** @type {Settings} */settings);
|
|
1797
1819
|
for (const jsdocNode of jsdocNodes) {
|
|
1798
1820
|
const jsdocNde = /** @type {unknown} */jsdocNode;
|
|
1799
|
-
if (!/^\/\*\*\s/u.test(sourceCode.getText(
|
|
1821
|
+
if (!/^\/\*\*\s/u.test(sourceCode.getText(/** @type {import('estree').Node} */
|
|
1800
1822
|
jsdocNde))) {
|
|
1801
1823
|
continue;
|
|
1802
1824
|
}
|
|
@@ -1851,7 +1873,6 @@ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContext
|
|
|
1851
1873
|
}
|
|
1852
1874
|
};
|
|
1853
1875
|
return {
|
|
1854
|
-
// @ts-expect-error ESLint accepts
|
|
1855
1876
|
create(context) {
|
|
1856
1877
|
/* c8 ignore next -- Fallback to deprecated method */
|
|
1857
1878
|
const {
|
|
@@ -1888,7 +1909,7 @@ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContext
|
|
|
1888
1909
|
return;
|
|
1889
1910
|
}
|
|
1890
1911
|
trackedJsdocs.add(commentNode);
|
|
1891
|
-
callIterator(context, node, [(
|
|
1912
|
+
callIterator(context, node, [(/** @type {import('estree').Comment} */
|
|
1892
1913
|
commentNode)], /** @type {StateObject} */state);
|
|
1893
1914
|
},
|
|
1894
1915
|
'Program:exit'() {
|
|
@@ -1928,7 +1949,7 @@ const checkFile = (iterator, ruleConfig) => {
|
|
|
1928
1949
|
const allComms = /** @type {unknown} */sourceCode.getAllComments();
|
|
1929
1950
|
const utils = getBasicUtils(context, settings);
|
|
1930
1951
|
iterator({
|
|
1931
|
-
allComments: (
|
|
1952
|
+
allComments: (/** @type {import('estree').Node[]} */allComms),
|
|
1932
1953
|
context,
|
|
1933
1954
|
makeReport,
|
|
1934
1955
|
settings,
|
|
@@ -1949,14 +1970,14 @@ const checkFile = (iterator, ruleConfig) => {
|
|
|
1949
1970
|
function iterateJsdoc(iterator, ruleConfig) {
|
|
1950
1971
|
var _ruleConfig$meta;
|
|
1951
1972
|
const metaType = ruleConfig === null || ruleConfig === void 0 || (_ruleConfig$meta = ruleConfig.meta) === null || _ruleConfig$meta === void 0 ? void 0 : _ruleConfig$meta.type;
|
|
1952
|
-
if (!metaType || !['
|
|
1973
|
+
if (!metaType || !['layout', 'problem', 'suggestion'].includes(metaType)) {
|
|
1953
1974
|
throw new TypeError('Rule must include `meta.type` option (with value "problem", "suggestion", or "layout")');
|
|
1954
1975
|
}
|
|
1955
1976
|
if (typeof iterator !== 'function') {
|
|
1956
1977
|
throw new TypeError('The iterator argument must be a function.');
|
|
1957
1978
|
}
|
|
1958
1979
|
if (ruleConfig.checkFile) {
|
|
1959
|
-
return checkFile(
|
|
1980
|
+
return checkFile(/** @type {JsdocVisitorBasic} */iterator, ruleConfig);
|
|
1960
1981
|
}
|
|
1961
1982
|
if (ruleConfig.iterateAllJsdocs) {
|
|
1962
1983
|
return iterateAllJsdocs(iterator, ruleConfig);
|
|
@@ -2004,7 +2025,7 @@ function iterateJsdoc(iterator, ruleConfig) {
|
|
|
2004
2025
|
return (ctxt === null || ctxt === void 0 ? void 0 : ctxt.context) === 'any';
|
|
2005
2026
|
}));
|
|
2006
2027
|
if (hasPlainAny || hasObjectAny) {
|
|
2007
|
-
return iterateAllJsdocs(iterator, ruleConfig, hasObjectAny ? (
|
|
2028
|
+
return iterateAllJsdocs(iterator, ruleConfig, hasObjectAny ? (/** @type {ContextObject[]} */contexts) : null, ruleConfig.matchContext).create(context);
|
|
2008
2029
|
}
|
|
2009
2030
|
}
|
|
2010
2031
|
|