eslint-plugin-jsdoc 53.0.1 → 54.1.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/WarnSettings.cjs +35 -18
- package/dist/WarnSettings.cjs.map +1 -1
- package/dist/alignTransform.cjs +305 -224
- package/dist/alignTransform.cjs.map +1 -1
- package/dist/defaultTagOrder.cjs +43 -132
- package/dist/defaultTagOrder.cjs.map +1 -1
- package/dist/exportParser.cjs +696 -478
- package/dist/exportParser.cjs.map +1 -1
- package/dist/generateRule.cjs +242 -0
- package/dist/generateRule.cjs.map +1 -0
- package/dist/getDefaultTagStructureForMode.cjs +288 -184
- package/dist/getDefaultTagStructureForMode.cjs.map +1 -1
- package/dist/getJsdocProcessorPlugin.cjs +550 -364
- package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
- package/dist/getJsdocProcessorPlugin.d.ts +65 -68
- package/dist/getJsdocProcessorPlugin.d.ts.map +1 -1
- package/dist/index.cjs +410 -2
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +17 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/iterateJsdoc.cjs +2007 -1539
- package/dist/iterateJsdoc.cjs.map +1 -1
- package/dist/iterateJsdoc.d.ts +350 -359
- package/dist/iterateJsdoc.d.ts.map +1 -1
- package/dist/jsdocUtils.cjs +1376 -1009
- package/dist/jsdocUtils.cjs.map +1 -1
- package/dist/rules/checkAccess.cjs +36 -29
- package/dist/rules/checkAccess.cjs.map +1 -1
- package/dist/rules/checkAlignment.cjs +54 -41
- package/dist/rules/checkAlignment.cjs.map +1 -1
- package/dist/rules/checkExamples.cjs +484 -327
- package/dist/rules/checkExamples.cjs.map +1 -1
- package/dist/rules/checkIndentation.cjs +65 -50
- package/dist/rules/checkIndentation.cjs.map +1 -1
- package/dist/rules/checkLineAlignment.cjs +311 -220
- package/dist/rules/checkLineAlignment.cjs.map +1 -1
- package/dist/rules/checkParamNames.cjs +335 -227
- package/dist/rules/checkParamNames.cjs.map +1 -1
- package/dist/rules/checkPropertyNames.cjs +106 -78
- package/dist/rules/checkPropertyNames.cjs.map +1 -1
- package/dist/rules/checkSyntax.cjs +34 -21
- package/dist/rules/checkSyntax.cjs.map +1 -1
- package/dist/rules/checkTagNames.cjs +210 -188
- package/dist/rules/checkTagNames.cjs.map +1 -1
- package/dist/rules/checkTemplateNames.cjs +178 -121
- package/dist/rules/checkTemplateNames.cjs.map +1 -1
- package/dist/rules/checkTypes.cjs +385 -291
- package/dist/rules/checkTypes.cjs.map +1 -1
- package/dist/rules/checkValues.cjs +146 -100
- package/dist/rules/checkValues.cjs.map +1 -1
- package/dist/rules/convertToJsdocComments.cjs +306 -228
- package/dist/rules/convertToJsdocComments.cjs.map +1 -1
- package/dist/rules/emptyTags.cjs +72 -62
- package/dist/rules/emptyTags.cjs.map +1 -1
- package/dist/rules/implementsOnClasses.cjs +56 -36
- package/dist/rules/implementsOnClasses.cjs.map +1 -1
- package/dist/rules/importsAsDependencies.cjs +99 -62
- package/dist/rules/importsAsDependencies.cjs.map +1 -1
- package/dist/rules/informativeDocs.cjs +142 -105
- package/dist/rules/informativeDocs.cjs.map +1 -1
- package/dist/rules/linesBeforeBlock.cjs +105 -70
- package/dist/rules/linesBeforeBlock.cjs.map +1 -1
- package/dist/rules/matchDescription.cjs +222 -160
- package/dist/rules/matchDescription.cjs.map +1 -1
- package/dist/rules/matchName.cjs +128 -73
- package/dist/rules/matchName.cjs.map +1 -1
- package/dist/rules/multilineBlocks.cjs +352 -235
- package/dist/rules/multilineBlocks.cjs.map +1 -1
- package/dist/rules/noBadBlocks.cjs +86 -63
- package/dist/rules/noBadBlocks.cjs.map +1 -1
- package/dist/rules/noBlankBlockDescriptions.cjs +57 -35
- package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -1
- package/dist/rules/noBlankBlocks.cjs +48 -26
- package/dist/rules/noBlankBlocks.cjs.map +1 -1
- package/dist/rules/noDefaults.cjs +79 -52
- package/dist/rules/noDefaults.cjs.map +1 -1
- package/dist/rules/noMissingSyntax.cjs +165 -115
- package/dist/rules/noMissingSyntax.cjs.map +1 -1
- package/dist/rules/noMultiAsterisks.cjs +89 -48
- package/dist/rules/noMultiAsterisks.cjs.map +1 -1
- package/dist/rules/noRestrictedSyntax.cjs +79 -45
- package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
- package/dist/rules/noTypes.cjs +80 -59
- package/dist/rules/noTypes.cjs.map +1 -1
- package/dist/rules/noUndefinedTypes.cjs +391 -297
- package/dist/rules/noUndefinedTypes.cjs.map +1 -1
- package/dist/rules/requireAsteriskPrefix.cjs +159 -108
- package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
- package/dist/rules/requireDescription.cjs +129 -89
- package/dist/rules/requireDescription.cjs.map +1 -1
- package/dist/rules/requireDescriptionCompleteSentence.cjs +262 -201
- package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
- package/dist/rules/requireExample.cjs +104 -73
- package/dist/rules/requireExample.cjs.map +1 -1
- package/dist/rules/requireFileOverview.cjs +129 -75
- package/dist/rules/requireFileOverview.cjs.map +1 -1
- package/dist/rules/requireHyphenBeforeParamDescription.cjs +133 -85
- package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
- package/dist/rules/requireJsdoc.cjs +559 -384
- package/dist/rules/requireJsdoc.cjs.map +1 -1
- package/dist/rules/requireParam.cjs +526 -336
- package/dist/rules/requireParam.cjs.map +1 -1
- package/dist/rules/requireParamDescription.cjs +80 -55
- package/dist/rules/requireParamDescription.cjs.map +1 -1
- package/dist/rules/requireParamName.cjs +50 -32
- package/dist/rules/requireParamName.cjs.map +1 -1
- package/dist/rules/requireParamType.cjs +80 -55
- package/dist/rules/requireParamType.cjs.map +1 -1
- package/dist/rules/requireProperty.cjs +42 -31
- package/dist/rules/requireProperty.cjs.map +1 -1
- package/dist/rules/requirePropertyDescription.cjs +25 -17
- package/dist/rules/requirePropertyDescription.cjs.map +1 -1
- package/dist/rules/requirePropertyName.cjs +25 -17
- package/dist/rules/requirePropertyName.cjs.map +1 -1
- package/dist/rules/requirePropertyType.cjs +25 -17
- package/dist/rules/requirePropertyType.cjs.map +1 -1
- package/dist/rules/requireReturns.cjs +203 -125
- package/dist/rules/requireReturns.cjs.map +1 -1
- package/dist/rules/requireReturnsCheck.cjs +103 -60
- package/dist/rules/requireReturnsCheck.cjs.map +1 -1
- package/dist/rules/requireReturnsDescription.cjs +54 -39
- package/dist/rules/requireReturnsDescription.cjs.map +1 -1
- package/dist/rules/requireReturnsType.cjs +50 -32
- package/dist/rules/requireReturnsType.cjs.map +1 -1
- package/dist/rules/requireTemplate.cjs +178 -119
- package/dist/rules/requireTemplate.cjs.map +1 -1
- package/dist/rules/requireThrows.cjs +95 -61
- package/dist/rules/requireThrows.cjs.map +1 -1
- package/dist/rules/requireYields.cjs +166 -106
- package/dist/rules/requireYields.cjs.map +1 -1
- package/dist/rules/requireYieldsCheck.cjs +152 -96
- package/dist/rules/requireYieldsCheck.cjs.map +1 -1
- package/dist/rules/sortTags.cjs +444 -258
- package/dist/rules/sortTags.cjs.map +1 -1
- package/dist/rules/tagLines.cjs +266 -179
- package/dist/rules/tagLines.cjs.map +1 -1
- package/dist/rules/textEscaping.cjs +127 -92
- package/dist/rules/textEscaping.cjs.map +1 -1
- package/dist/rules/validTypes.cjs +265 -252
- package/dist/rules/validTypes.cjs.map +1 -1
- package/dist/tagNames.cjs +170 -134
- package/dist/tagNames.cjs.map +1 -1
- package/dist/utils/hasReturnValue.cjs +474 -246
- package/dist/utils/hasReturnValue.cjs.map +1 -1
- package/package.json +41 -57
- package/src/WarnSettings.js +34 -0
- package/src/alignTransform.js +358 -0
- package/src/defaultTagOrder.js +169 -0
- package/src/exportParser.js +978 -0
- package/src/getDefaultTagStructureForMode.js +969 -0
- package/src/getJsdocProcessorPlugin.js +672 -0
- package/src/index.js +530 -0
- package/src/iterateJsdoc.js +2542 -0
- package/src/jsdocUtils.js +1896 -0
- package/src/rules/checkAccess.js +45 -0
- package/src/rules/checkAlignment.js +63 -0
- package/src/rules/checkExamples.js +589 -0
- package/src/rules/checkIndentation.js +75 -0
- package/src/rules/checkLineAlignment.js +372 -0
- package/src/rules/checkParamNames.js +474 -0
- package/src/rules/checkPropertyNames.js +152 -0
- package/src/rules/checkSyntax.js +30 -0
- package/src/rules/checkTagNames.js +314 -0
- package/src/rules/checkTemplateNames.js +204 -0
- package/src/rules/checkTypes.js +535 -0
- package/src/rules/checkValues.js +248 -0
- package/src/rules/convertToJsdocComments.js +398 -0
- package/src/rules/emptyTags.js +98 -0
- package/src/rules/implementsOnClasses.js +64 -0
- package/src/rules/importsAsDependencies.js +133 -0
- package/src/rules/informativeDocs.js +189 -0
- package/src/rules/linesBeforeBlock.js +134 -0
- package/src/rules/matchDescription.js +286 -0
- package/src/rules/matchName.js +151 -0
- package/src/rules/multilineBlocks.js +493 -0
- package/src/rules/noBadBlocks.js +119 -0
- package/src/rules/noBlankBlockDescriptions.js +69 -0
- package/src/rules/noBlankBlocks.js +53 -0
- package/src/rules/noDefaults.js +85 -0
- package/src/rules/noMissingSyntax.js +195 -0
- package/src/rules/noMultiAsterisks.js +134 -0
- package/src/rules/noRestrictedSyntax.js +91 -0
- package/src/rules/noTypes.js +93 -0
- package/src/rules/noUndefinedTypes.js +545 -0
- package/src/rules/requireAsteriskPrefix.js +190 -0
- package/src/rules/requireDescription.js +161 -0
- package/src/rules/requireDescriptionCompleteSentence.js +335 -0
- package/src/rules/requireExample.js +118 -0
- package/src/rules/requireFileOverview.js +154 -0
- package/src/rules/requireHyphenBeforeParamDescription.js +176 -0
- package/src/rules/requireJsdoc.js +744 -0
- package/src/rules/requireParam.js +602 -0
- package/src/rules/requireParamDescription.js +89 -0
- package/src/rules/requireParamName.js +55 -0
- package/src/rules/requireParamType.js +89 -0
- package/src/rules/requireProperty.js +48 -0
- package/src/rules/requirePropertyDescription.js +25 -0
- package/src/rules/requirePropertyName.js +25 -0
- package/src/rules/requirePropertyType.js +25 -0
- package/src/rules/requireReturns.js +238 -0
- package/src/rules/requireReturnsCheck.js +145 -0
- package/src/rules/requireReturnsDescription.js +59 -0
- package/src/rules/requireReturnsType.js +51 -0
- package/src/rules/requireTemplate.js +201 -0
- package/src/rules/requireThrows.js +111 -0
- package/src/rules/requireYields.js +216 -0
- package/src/rules/requireYieldsCheck.js +208 -0
- package/src/rules/sortTags.js +558 -0
- package/src/rules/tagLines.js +359 -0
- package/src/rules/textEscaping.js +154 -0
- package/src/rules/validTypes.js +401 -0
- package/src/tagNames.js +238 -0
- package/src/utils/hasReturnValue.js +572 -0
- package/dist/WarnSettings.js +0 -20
- package/dist/WarnSettings.js.map +0 -1
- package/dist/_virtual/rolldown_runtime.cjs +0 -32
- package/dist/_virtual/rolldown_runtime.js +0 -11
- package/dist/alignTransform.js +0 -241
- package/dist/alignTransform.js.map +0 -1
- package/dist/defaultTagOrder.js +0 -134
- package/dist/defaultTagOrder.js.map +0 -1
- package/dist/exportParser.js +0 -518
- package/dist/exportParser.js.map +0 -1
- package/dist/getDefaultTagStructureForMode.js +0 -188
- package/dist/getDefaultTagStructureForMode.js.map +0 -1
- package/dist/getJsdocProcessorPlugin.d.cts +0 -70
- package/dist/getJsdocProcessorPlugin.d.cts.map +0 -1
- package/dist/getJsdocProcessorPlugin.js +0 -383
- package/dist/getJsdocProcessorPlugin.js.map +0 -1
- package/dist/index.d.cts +0 -2
- package/dist/index.js +0 -3
- package/dist/iterateJsdoc.d.cts +0 -472
- package/dist/iterateJsdoc.d.cts.map +0 -1
- package/dist/iterateJsdoc.js +0 -1628
- package/dist/iterateJsdoc.js.map +0 -1
- package/dist/jsdocUtils.js +0 -1123
- package/dist/jsdocUtils.js.map +0 -1
- package/dist/plugin.cjs +0 -427
- package/dist/plugin.cjs.map +0 -1
- package/dist/plugin.js +0 -427
- package/dist/plugin.js.map +0 -1
- package/dist/rules/checkAccess.js +0 -33
- package/dist/rules/checkAccess.js.map +0 -1
- package/dist/rules/checkAlignment.js +0 -47
- package/dist/rules/checkAlignment.js.map +0 -1
- package/dist/rules/checkExamples.js +0 -348
- package/dist/rules/checkExamples.js.map +0 -1
- package/dist/rules/checkIndentation.js +0 -59
- package/dist/rules/checkIndentation.js.map +0 -1
- package/dist/rules/checkLineAlignment.js +0 -229
- package/dist/rules/checkLineAlignment.js.map +0 -1
- package/dist/rules/checkParamNames.js +0 -237
- package/dist/rules/checkParamNames.js.map +0 -1
- package/dist/rules/checkPropertyNames.js +0 -88
- package/dist/rules/checkPropertyNames.js.map +0 -1
- package/dist/rules/checkSyntax.js +0 -25
- package/dist/rules/checkSyntax.js.map +0 -1
- package/dist/rules/checkTagNames.js +0 -191
- package/dist/rules/checkTagNames.js.map +0 -1
- package/dist/rules/checkTemplateNames.js +0 -124
- package/dist/rules/checkTemplateNames.js.map +0 -1
- package/dist/rules/checkTypes.js +0 -299
- package/dist/rules/checkTypes.js.map +0 -1
- package/dist/rules/checkValues.js +0 -103
- package/dist/rules/checkValues.js.map +0 -1
- package/dist/rules/convertToJsdocComments.js +0 -231
- package/dist/rules/convertToJsdocComments.js.map +0 -1
- package/dist/rules/emptyTags.js +0 -67
- package/dist/rules/emptyTags.js.map +0 -1
- package/dist/rules/implementsOnClasses.js +0 -40
- package/dist/rules/implementsOnClasses.js.map +0 -1
- package/dist/rules/importsAsDependencies.js +0 -68
- package/dist/rules/importsAsDependencies.js.map +0 -1
- package/dist/rules/informativeDocs.js +0 -110
- package/dist/rules/informativeDocs.js.map +0 -1
- package/dist/rules/linesBeforeBlock.js +0 -75
- package/dist/rules/linesBeforeBlock.js.map +0 -1
- package/dist/rules/matchDescription.js +0 -167
- package/dist/rules/matchDescription.js.map +0 -1
- package/dist/rules/matchName.js +0 -77
- package/dist/rules/matchName.js.map +0 -1
- package/dist/rules/multilineBlocks.js +0 -245
- package/dist/rules/multilineBlocks.js.map +0 -1
- package/dist/rules/noBadBlocks.js +0 -68
- package/dist/rules/noBadBlocks.js.map +0 -1
- package/dist/rules/noBlankBlockDescriptions.js +0 -41
- package/dist/rules/noBlankBlockDescriptions.js.map +0 -1
- package/dist/rules/noBlankBlocks.js +0 -30
- package/dist/rules/noBlankBlocks.js.map +0 -1
- package/dist/rules/noDefaults.js +0 -56
- package/dist/rules/noDefaults.js.map +0 -1
- package/dist/rules/noMissingSyntax.js +0 -126
- package/dist/rules/noMissingSyntax.js.map +0 -1
- package/dist/rules/noMultiAsterisks.js +0 -58
- package/dist/rules/noMultiAsterisks.js.map +0 -1
- package/dist/rules/noRestrictedSyntax.js +0 -49
- package/dist/rules/noRestrictedSyntax.js.map +0 -1
- package/dist/rules/noTypes.js +0 -65
- package/dist/rules/noTypes.js.map +0 -1
- package/dist/rules/noUndefinedTypes.js +0 -303
- package/dist/rules/noUndefinedTypes.js.map +0 -1
- package/dist/rules/requireAsteriskPrefix.js +0 -112
- package/dist/rules/requireAsteriskPrefix.js.map +0 -1
- package/dist/rules/requireDescription.js +0 -95
- package/dist/rules/requireDescription.js.map +0 -1
- package/dist/rules/requireDescriptionCompleteSentence.js +0 -220
- package/dist/rules/requireDescriptionCompleteSentence.js.map +0 -1
- package/dist/rules/requireExample.js +0 -77
- package/dist/rules/requireExample.js.map +0 -1
- package/dist/rules/requireFileOverview.js +0 -81
- package/dist/rules/requireFileOverview.js.map +0 -1
- package/dist/rules/requireHyphenBeforeParamDescription.js +0 -89
- package/dist/rules/requireHyphenBeforeParamDescription.js.map +0 -1
- package/dist/rules/requireJsdoc.js +0 -404
- package/dist/rules/requireJsdoc.js.map +0 -1
- package/dist/rules/requireParam.js +0 -344
- package/dist/rules/requireParam.js.map +0 -1
- package/dist/rules/requireParamDescription.js +0 -59
- package/dist/rules/requireParamDescription.js.map +0 -1
- package/dist/rules/requireParamName.js +0 -36
- package/dist/rules/requireParamName.js.map +0 -1
- package/dist/rules/requireParamType.js +0 -59
- package/dist/rules/requireParamType.js.map +0 -1
- package/dist/rules/requireProperty.js +0 -35
- package/dist/rules/requireProperty.js.map +0 -1
- package/dist/rules/requirePropertyDescription.js +0 -21
- package/dist/rules/requirePropertyDescription.js.map +0 -1
- package/dist/rules/requirePropertyName.js +0 -21
- package/dist/rules/requirePropertyName.js.map +0 -1
- package/dist/rules/requirePropertyType.js +0 -21
- package/dist/rules/requirePropertyType.js.map +0 -1
- package/dist/rules/requireReturns.js +0 -131
- package/dist/rules/requireReturns.js.map +0 -1
- package/dist/rules/requireReturnsCheck.js +0 -66
- package/dist/rules/requireReturnsCheck.js.map +0 -1
- package/dist/rules/requireReturnsDescription.js +0 -43
- package/dist/rules/requireReturnsDescription.js.map +0 -1
- package/dist/rules/requireReturnsType.js +0 -36
- package/dist/rules/requireReturnsType.js.map +0 -1
- package/dist/rules/requireTemplate.js +0 -122
- package/dist/rules/requireTemplate.js.map +0 -1
- package/dist/rules/requireThrows.js +0 -67
- package/dist/rules/requireThrows.js.map +0 -1
- package/dist/rules/requireYields.js +0 -115
- package/dist/rules/requireYields.js.map +0 -1
- package/dist/rules/requireYieldsCheck.js +0 -105
- package/dist/rules/requireYieldsCheck.js.map +0 -1
- package/dist/rules/sortTags.js +0 -262
- package/dist/rules/sortTags.js.map +0 -1
- package/dist/rules/tagLines.js +0 -183
- package/dist/rules/tagLines.js.map +0 -1
- package/dist/rules/textEscaping.js +0 -102
- package/dist/rules/textEscaping.js.map +0 -1
- package/dist/rules/validTypes.js +0 -259
- package/dist/rules/validTypes.js.map +0 -1
- package/dist/tagNames.js +0 -144
- package/dist/tagNames.js.map +0 -1
- package/dist/utils/hasReturnValue.js +0 -265
- package/dist/utils/hasReturnValue.js.map +0 -1
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import iterateJsdoc from "../iterateJsdoc.js";
|
|
2
|
-
|
|
3
|
-
//#region src/rules/checkAlignment.js
|
|
4
|
-
/**
|
|
5
|
-
* @param {string} string
|
|
6
|
-
* @returns {string}
|
|
7
|
-
*/
|
|
8
|
-
const trimStart = (string) => {
|
|
9
|
-
return string.replace(/^\s+/v, "");
|
|
10
|
-
};
|
|
11
|
-
var checkAlignment_default = iterateJsdoc(({ indent, jsdocNode, report, sourceCode }) => {
|
|
12
|
-
const indentLevel = indent.length + 1;
|
|
13
|
-
const sourceLines = sourceCode.getText(jsdocNode).split("\n").slice(1).map((line) => {
|
|
14
|
-
return line.split("*")[0];
|
|
15
|
-
}).filter((line) => {
|
|
16
|
-
return !trimStart(line).length;
|
|
17
|
-
});
|
|
18
|
-
/** @type {import('eslint').Rule.ReportFixer} */
|
|
19
|
-
const fix = (fixer) => {
|
|
20
|
-
const replacement = sourceCode.getText(jsdocNode).split("\n").map((line, index) => {
|
|
21
|
-
const ignored = !index || trimStart(line.split("*")[0]).length;
|
|
22
|
-
return ignored ? line : `${indent} ${trimStart(line)}`;
|
|
23
|
-
}).join("\n");
|
|
24
|
-
return fixer.replaceText(jsdocNode, replacement);
|
|
25
|
-
};
|
|
26
|
-
sourceLines.some((line, lineNum) => {
|
|
27
|
-
if (line.length !== indentLevel) {
|
|
28
|
-
report("Expected JSDoc block to be aligned.", fix, { line: lineNum + 1 });
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
return false;
|
|
32
|
-
});
|
|
33
|
-
}, {
|
|
34
|
-
iterateAllJsdocs: true,
|
|
35
|
-
meta: {
|
|
36
|
-
docs: {
|
|
37
|
-
description: "Reports invalid alignment of JSDoc block asterisks.",
|
|
38
|
-
url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-alignment.md#repos-sticky-header"
|
|
39
|
-
},
|
|
40
|
-
fixable: "code",
|
|
41
|
-
type: "layout"
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
//#endregion
|
|
46
|
-
export { checkAlignment_default as default };
|
|
47
|
-
//# sourceMappingURL=checkAlignment.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"checkAlignment.js","names":[],"sources":["../../src/rules/checkAlignment.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * @param {string} string\n * @returns {string}\n */\nconst trimStart = (string) => {\n return string.replace(/^\\s+/v, '');\n};\n\nexport default iterateJsdoc(({\n indent,\n jsdocNode,\n report,\n sourceCode,\n}) => {\n // `indent` is whitespace from line 1 (`/**`), so slice and account for \"/\".\n const indentLevel = indent.length + 1;\n const sourceLines = sourceCode.getText(jsdocNode).split('\\n')\n .slice(1)\n .map((line) => {\n return line.split('*')[0];\n })\n .filter((line) => {\n return !trimStart(line).length;\n });\n\n /** @type {import('eslint').Rule.ReportFixer} */\n const fix = (fixer) => {\n const replacement = sourceCode.getText(jsdocNode).split('\\n')\n .map((line, index) => {\n // Ignore the first line and all lines not starting with `*`\n const ignored = !index || trimStart(line.split('*')[0]).length;\n\n return ignored ? line : `${indent} ${trimStart(line)}`;\n })\n .join('\\n');\n\n return fixer.replaceText(jsdocNode, replacement);\n };\n\n sourceLines.some((line, lineNum) => {\n if (line.length !== indentLevel) {\n report('Expected JSDoc block to be aligned.', fix, {\n line: lineNum + 1,\n });\n\n return true;\n }\n\n return false;\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Reports invalid alignment of JSDoc block asterisks.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-alignment.md#repos-sticky-header',\n },\n fixable: 'code',\n type: 'layout',\n },\n});\n"],"mappings":";;;;;;;AAMA,MAAM,YAAY,CAAC,WAAW;AAC5B,QAAO,OAAO,QAAQ,SAAS,GAAG;AACnC;AAED,6BAAe,aAAa,CAAC,EAC3B,QACA,WACA,QACA,YACD,KAAK;CAEJ,MAAM,cAAc,OAAO,SAAS;CACpC,MAAM,cAAc,WAAW,QAAQ,UAAU,CAAC,MAAM,KAAK,CAC1D,MAAM,EAAE,CACR,IAAI,CAAC,SAAS;AACb,SAAO,KAAK,MAAM,IAAI,CAAC;CACxB,EAAC,CACD,OAAO,CAAC,SAAS;AAChB,SAAO,CAAC,UAAU,KAAK,CAAC;CACzB,EAAC;;CAGJ,MAAM,MAAM,CAAC,UAAU;EACrB,MAAM,cAAc,WAAW,QAAQ,UAAU,CAAC,MAAM,KAAK,CAC1D,IAAI,CAAC,MAAM,UAAU;GAEpB,MAAM,UAAU,CAAC,SAAS,UAAU,KAAK,MAAM,IAAI,CAAC,GAAG,CAAC;AAExD,UAAO,UAAU,OAAO,GAAG,OAAO,CAAC,EAAE,UAAU,KAAK,EAAE;EACvD,EAAC,CACD,KAAK,KAAK;AAEb,SAAO,MAAM,YAAY,WAAW,YAAY;CACjD;CAED,YAAY,KAAK,CAAC,MAAM,YAAY;AAClC,MAAI,KAAK,WAAW,aAAa;GAC/B,OAAO,uCAAuC,KAAK,EACjD,MAAM,UAAU,EACjB,EAAC;AAEF,UAAO;EACR;AAED,SAAO;CACR,EAAC;AACH,GAAE;CACD,kBAAkB;CAClB,MAAM;EACJ,MAAM;GACJ,aAAa;GACb,KAAK;EACN;EACD,SAAS;EACT,MAAM;CACP;AACF,EAAC"}
|
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
import iterateJsdoc from "../iterateJsdoc.js";
|
|
2
|
-
import eslint, { ESLint } from "eslint";
|
|
3
|
-
import semver from "semver";
|
|
4
|
-
|
|
5
|
-
//#region src/rules/checkExamples.js
|
|
6
|
-
const { CLIEngine } = eslint;
|
|
7
|
-
const zeroBasedLineIndexAdjust = -1;
|
|
8
|
-
const likelyNestedJSDocIndentSpace = 1;
|
|
9
|
-
const preTagSpaceLength = 1;
|
|
10
|
-
const firstLinePrefixLength = preTagSpaceLength;
|
|
11
|
-
const hasCaptionRegex = /^\s*<caption>([\s\S]*?)<\/caption>/v;
|
|
12
|
-
/**
|
|
13
|
-
* @param {string} str
|
|
14
|
-
* @returns {string}
|
|
15
|
-
*/
|
|
16
|
-
const escapeStringRegexp = (str) => {
|
|
17
|
-
return str.replaceAll(/[.*+?^$\{\}\(\)\|\[\]\\]/gv, "\\$&");
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* @param {string} str
|
|
21
|
-
* @param {string} ch
|
|
22
|
-
* @returns {import('../iterateJsdoc.js').Integer}
|
|
23
|
-
*/
|
|
24
|
-
const countChars = (str, ch) => {
|
|
25
|
-
return (str.match(new RegExp(escapeStringRegexp(ch), "gv")) || []).length;
|
|
26
|
-
};
|
|
27
|
-
/** @type {import('eslint').Linter.RulesRecord} */
|
|
28
|
-
const defaultMdRules = {
|
|
29
|
-
"eol-last": 0,
|
|
30
|
-
"import/no-unresolved": 0,
|
|
31
|
-
"import/unambiguous": 0,
|
|
32
|
-
"jsdoc/require-file-overview": 0,
|
|
33
|
-
"jsdoc/require-jsdoc": 0,
|
|
34
|
-
"no-console": 0,
|
|
35
|
-
"no-multiple-empty-lines": 0,
|
|
36
|
-
"no-undef": 0,
|
|
37
|
-
"no-unused-vars": 0,
|
|
38
|
-
"node/no-missing-import": 0,
|
|
39
|
-
"node/no-missing-require": 0,
|
|
40
|
-
"padded-blocks": 0
|
|
41
|
-
};
|
|
42
|
-
/** @type {import('eslint').Linter.RulesRecord} */
|
|
43
|
-
const defaultExpressionRules = {
|
|
44
|
-
...defaultMdRules,
|
|
45
|
-
"chai-friendly/no-unused-expressions": "off",
|
|
46
|
-
"no-empty-function": "off",
|
|
47
|
-
"no-new": "off",
|
|
48
|
-
"no-unused-expressions": "off",
|
|
49
|
-
quotes: ["error", "double"],
|
|
50
|
-
semi: ["error", "never"],
|
|
51
|
-
strict: "off"
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* @param {string} text
|
|
55
|
-
* @returns {[
|
|
56
|
-
* import('../iterateJsdoc.js').Integer,
|
|
57
|
-
* import('../iterateJsdoc.js').Integer
|
|
58
|
-
* ]}
|
|
59
|
-
*/
|
|
60
|
-
const getLinesCols = (text) => {
|
|
61
|
-
const matchLines = countChars(text, "\n");
|
|
62
|
-
const colDelta = matchLines ? text.slice(text.lastIndexOf("\n") + 1).length : text.length;
|
|
63
|
-
return [matchLines, colDelta];
|
|
64
|
-
};
|
|
65
|
-
var checkExamples_default = iterateJsdoc(({ context, globalState, report, utils }) => {
|
|
66
|
-
if (semver.gte(ESLint.version, "8.0.0")) {
|
|
67
|
-
report("This rule does not work for ESLint 8+; you should disable this rule and usethe processor mentioned in the docs.", null, {
|
|
68
|
-
column: 1,
|
|
69
|
-
line: 1
|
|
70
|
-
});
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if (!globalState.has("checkExamples-matchingFileName")) globalState.set("checkExamples-matchingFileName", /* @__PURE__ */ new Map());
|
|
74
|
-
const matchingFileNameMap = globalState.get("checkExamples-matchingFileName");
|
|
75
|
-
const options = context.options[0] || {};
|
|
76
|
-
let { exampleCodeRegex = null, rejectExampleCodeRegex = null } = options;
|
|
77
|
-
const { allowInlineConfig = true, baseConfig = {}, captionRequired = false, checkDefaults = false, checkEslintrc = true, checkParams = false, checkProperties = false, configFile, matchingFileName = null, matchingFileNameDefaults = null, matchingFileNameParams = null, matchingFileNameProperties = null, noDefaultExampleRules = false, paddedIndent = 0, reportUnusedDisableDirectives = true } = options;
|
|
78
|
-
/**
|
|
79
|
-
* @type {never[]}
|
|
80
|
-
*/
|
|
81
|
-
const rulePaths = [];
|
|
82
|
-
const mdRules = noDefaultExampleRules ? void 0 : defaultMdRules;
|
|
83
|
-
const expressionRules = noDefaultExampleRules ? void 0 : defaultExpressionRules;
|
|
84
|
-
if (exampleCodeRegex) exampleCodeRegex = utils.getRegexFromString(exampleCodeRegex);
|
|
85
|
-
if (rejectExampleCodeRegex) rejectExampleCodeRegex = utils.getRegexFromString(rejectExampleCodeRegex);
|
|
86
|
-
/**
|
|
87
|
-
* @param {{
|
|
88
|
-
* filename: string,
|
|
89
|
-
* defaultFileName: string|undefined,
|
|
90
|
-
* source: string,
|
|
91
|
-
* targetTagName: string,
|
|
92
|
-
* rules?: import('eslint').Linter.RulesRecord|undefined,
|
|
93
|
-
* lines?: import('../iterateJsdoc.js').Integer,
|
|
94
|
-
* cols?: import('../iterateJsdoc.js').Integer,
|
|
95
|
-
* skipInit?: boolean,
|
|
96
|
-
* sources?: {
|
|
97
|
-
* nonJSPrefacingCols: import('../iterateJsdoc.js').Integer,
|
|
98
|
-
* nonJSPrefacingLines: import('../iterateJsdoc.js').Integer,
|
|
99
|
-
* string: string,
|
|
100
|
-
* }[],
|
|
101
|
-
* tag?: import('comment-parser').Spec & {
|
|
102
|
-
* line?: import('../iterateJsdoc.js').Integer,
|
|
103
|
-
* }|{
|
|
104
|
-
* line: import('../iterateJsdoc.js').Integer,
|
|
105
|
-
* }
|
|
106
|
-
* }} cfg
|
|
107
|
-
*/
|
|
108
|
-
const checkSource = ({ cols = 0, defaultFileName, filename, lines = 0, rules = expressionRules, skipInit, source, sources = [], tag = { line: 0 }, targetTagName }) => {
|
|
109
|
-
if (!skipInit) sources.push({
|
|
110
|
-
nonJSPrefacingCols: cols,
|
|
111
|
-
nonJSPrefacingLines: lines,
|
|
112
|
-
string: source
|
|
113
|
-
});
|
|
114
|
-
/**
|
|
115
|
-
* @param {{
|
|
116
|
-
* nonJSPrefacingCols: import('../iterateJsdoc.js').Integer,
|
|
117
|
-
* nonJSPrefacingLines: import('../iterateJsdoc.js').Integer,
|
|
118
|
-
* string: string
|
|
119
|
-
* }} cfg
|
|
120
|
-
*/
|
|
121
|
-
const checkRules = function({ nonJSPrefacingCols, nonJSPrefacingLines, string }) {
|
|
122
|
-
const cliConfig = {
|
|
123
|
-
allowInlineConfig,
|
|
124
|
-
baseConfig,
|
|
125
|
-
configFile,
|
|
126
|
-
reportUnusedDisableDirectives,
|
|
127
|
-
rulePaths,
|
|
128
|
-
rules,
|
|
129
|
-
useEslintrc: checkEslintrc
|
|
130
|
-
};
|
|
131
|
-
const cliConfigStr = JSON.stringify(cliConfig);
|
|
132
|
-
const src = paddedIndent ? string.replaceAll(new RegExp(`(^|\n) {${paddedIndent}}(?!$)`, "gv"), "\n") : string;
|
|
133
|
-
const fileNameMapKey = filename ? "a" + cliConfigStr + filename : "b" + cliConfigStr + defaultFileName;
|
|
134
|
-
const file = filename || defaultFileName;
|
|
135
|
-
let cliFile;
|
|
136
|
-
if (matchingFileNameMap.has(fileNameMapKey)) cliFile = matchingFileNameMap.get(fileNameMapKey);
|
|
137
|
-
else {
|
|
138
|
-
const cli = new CLIEngine(cliConfig);
|
|
139
|
-
let config;
|
|
140
|
-
if (filename || checkEslintrc) config = cli.getConfigForFile(file);
|
|
141
|
-
cliFile = new CLIEngine({
|
|
142
|
-
allowInlineConfig,
|
|
143
|
-
baseConfig: {
|
|
144
|
-
...baseConfig,
|
|
145
|
-
...config
|
|
146
|
-
},
|
|
147
|
-
configFile,
|
|
148
|
-
reportUnusedDisableDirectives,
|
|
149
|
-
rulePaths,
|
|
150
|
-
rules,
|
|
151
|
-
useEslintrc: false
|
|
152
|
-
});
|
|
153
|
-
matchingFileNameMap.set(fileNameMapKey, cliFile);
|
|
154
|
-
}
|
|
155
|
-
const { results: [{ messages }] } = cliFile.executeOnText(src);
|
|
156
|
-
if (!("line" in tag)) tag.line = tag.source[0].number;
|
|
157
|
-
const codeStartLine = tag.line + nonJSPrefacingLines;
|
|
158
|
-
const codeStartCol = likelyNestedJSDocIndentSpace;
|
|
159
|
-
for (const { column, line, message, ruleId, severity } of messages) {
|
|
160
|
-
const startLine = codeStartLine + line + zeroBasedLineIndexAdjust;
|
|
161
|
-
const startCol = codeStartCol + (line <= 1 ? nonJSPrefacingCols + firstLinePrefixLength : preTagSpaceLength) + column;
|
|
162
|
-
report("@" + targetTagName + " " + (severity === 2 ? "error" : "warning") + (ruleId ? " (" + ruleId + ")" : "") + ": " + message, null, {
|
|
163
|
-
column: startCol,
|
|
164
|
-
line: startLine
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
for (const targetSource of sources) checkRules(targetSource);
|
|
169
|
-
};
|
|
170
|
-
/**
|
|
171
|
-
*
|
|
172
|
-
* @param {string} filename
|
|
173
|
-
* @param {string} [ext] Since `eslint-plugin-markdown` v2, and
|
|
174
|
-
* ESLint 7, this is the default which other JS-fenced rules will used.
|
|
175
|
-
* Formerly "md" was the default.
|
|
176
|
-
* @returns {{defaultFileName: string|undefined, filename: string}}
|
|
177
|
-
*/
|
|
178
|
-
const getFilenameInfo = (filename, ext = "md/*.js") => {
|
|
179
|
-
let defaultFileName;
|
|
180
|
-
if (!filename) {
|
|
181
|
-
const jsFileName = context.getFilename();
|
|
182
|
-
if (typeof jsFileName === "string" && jsFileName.includes(".")) defaultFileName = jsFileName.replace(/\.[^.]*$/v, `.${ext}`);
|
|
183
|
-
else defaultFileName = `dummy.${ext}`;
|
|
184
|
-
}
|
|
185
|
-
return {
|
|
186
|
-
defaultFileName,
|
|
187
|
-
filename
|
|
188
|
-
};
|
|
189
|
-
};
|
|
190
|
-
if (checkDefaults) {
|
|
191
|
-
const filenameInfo = getFilenameInfo(matchingFileNameDefaults, "jsdoc-defaults");
|
|
192
|
-
utils.forEachPreferredTag("default", (tag, targetTagName) => {
|
|
193
|
-
if (!tag.description.trim()) return;
|
|
194
|
-
checkSource({
|
|
195
|
-
source: `(${utils.getTagDescription(tag)})`,
|
|
196
|
-
targetTagName,
|
|
197
|
-
...filenameInfo
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
if (checkParams) {
|
|
202
|
-
const filenameInfo = getFilenameInfo(matchingFileNameParams, "jsdoc-params");
|
|
203
|
-
utils.forEachPreferredTag("param", (tag, targetTagName) => {
|
|
204
|
-
if (!tag.default || !tag.default.trim()) return;
|
|
205
|
-
checkSource({
|
|
206
|
-
source: `(${tag.default})`,
|
|
207
|
-
targetTagName,
|
|
208
|
-
...filenameInfo
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
if (checkProperties) {
|
|
213
|
-
const filenameInfo = getFilenameInfo(matchingFileNameProperties, "jsdoc-properties");
|
|
214
|
-
utils.forEachPreferredTag("property", (tag, targetTagName) => {
|
|
215
|
-
if (!tag.default || !tag.default.trim()) return;
|
|
216
|
-
checkSource({
|
|
217
|
-
source: `(${tag.default})`,
|
|
218
|
-
targetTagName,
|
|
219
|
-
...filenameInfo
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
const tagName = utils.getPreferredTagName({ tagName: "example" });
|
|
224
|
-
if (!utils.hasTag(tagName)) return;
|
|
225
|
-
const matchingFilenameInfo = getFilenameInfo(matchingFileName);
|
|
226
|
-
utils.forEachPreferredTag("example", (tag, targetTagName) => {
|
|
227
|
-
let source = utils.getTagDescription(tag);
|
|
228
|
-
const match = source.match(hasCaptionRegex);
|
|
229
|
-
if (captionRequired && (!match || !match[1].trim())) report("Caption is expected for examples.", null, tag);
|
|
230
|
-
source = source.replace(hasCaptionRegex, "");
|
|
231
|
-
const [lines, cols] = match ? getLinesCols(match[0]) : [0, 0];
|
|
232
|
-
if (exampleCodeRegex && !exampleCodeRegex.test(source) || rejectExampleCodeRegex && rejectExampleCodeRegex.test(source)) return;
|
|
233
|
-
const sources = [];
|
|
234
|
-
let skipInit = false;
|
|
235
|
-
if (exampleCodeRegex) {
|
|
236
|
-
let nonJSPrefacingCols = 0;
|
|
237
|
-
let nonJSPrefacingLines = 0;
|
|
238
|
-
let startingIndex = 0;
|
|
239
|
-
let lastStringCount = 0;
|
|
240
|
-
let exampleCode;
|
|
241
|
-
exampleCodeRegex.lastIndex = 0;
|
|
242
|
-
while ((exampleCode = exampleCodeRegex.exec(source)) !== null) {
|
|
243
|
-
const { "0": n0, "1": n1, index } = exampleCode;
|
|
244
|
-
const preMatch = source.slice(startingIndex, index);
|
|
245
|
-
const [preMatchLines, colDelta] = getLinesCols(preMatch);
|
|
246
|
-
let nonJSPreface;
|
|
247
|
-
let nonJSPrefaceLineCount;
|
|
248
|
-
if (n1) {
|
|
249
|
-
const idx = n0.indexOf(n1);
|
|
250
|
-
nonJSPreface = n0.slice(0, idx);
|
|
251
|
-
nonJSPrefaceLineCount = countChars(nonJSPreface, "\n");
|
|
252
|
-
} else {
|
|
253
|
-
nonJSPreface = "";
|
|
254
|
-
nonJSPrefaceLineCount = 0;
|
|
255
|
-
}
|
|
256
|
-
nonJSPrefacingLines += lastStringCount + preMatchLines + nonJSPrefaceLineCount;
|
|
257
|
-
if (nonJSPrefaceLineCount) {
|
|
258
|
-
const charsInLastLine = nonJSPreface.slice(nonJSPreface.lastIndexOf("\n") + 1).length;
|
|
259
|
-
nonJSPrefacingCols += charsInLastLine;
|
|
260
|
-
} else nonJSPrefacingCols += colDelta + nonJSPreface.length;
|
|
261
|
-
const string = n1 || n0;
|
|
262
|
-
sources.push({
|
|
263
|
-
nonJSPrefacingCols,
|
|
264
|
-
nonJSPrefacingLines,
|
|
265
|
-
string
|
|
266
|
-
});
|
|
267
|
-
startingIndex = exampleCodeRegex.lastIndex;
|
|
268
|
-
lastStringCount = countChars(string, "\n");
|
|
269
|
-
if (!exampleCodeRegex.global) break;
|
|
270
|
-
}
|
|
271
|
-
skipInit = true;
|
|
272
|
-
}
|
|
273
|
-
checkSource({
|
|
274
|
-
cols,
|
|
275
|
-
lines,
|
|
276
|
-
rules: mdRules,
|
|
277
|
-
skipInit,
|
|
278
|
-
source,
|
|
279
|
-
sources,
|
|
280
|
-
tag,
|
|
281
|
-
targetTagName,
|
|
282
|
-
...matchingFilenameInfo
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
}, {
|
|
286
|
-
iterateAllJsdocs: true,
|
|
287
|
-
meta: {
|
|
288
|
-
docs: {
|
|
289
|
-
description: "Ensures that (JavaScript) examples within JSDoc adhere to ESLint rules.",
|
|
290
|
-
url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-examples.md#repos-sticky-header"
|
|
291
|
-
},
|
|
292
|
-
schema: [{
|
|
293
|
-
additionalProperties: false,
|
|
294
|
-
properties: {
|
|
295
|
-
allowInlineConfig: {
|
|
296
|
-
default: true,
|
|
297
|
-
type: "boolean"
|
|
298
|
-
},
|
|
299
|
-
baseConfig: { type: "object" },
|
|
300
|
-
captionRequired: {
|
|
301
|
-
default: false,
|
|
302
|
-
type: "boolean"
|
|
303
|
-
},
|
|
304
|
-
checkDefaults: {
|
|
305
|
-
default: false,
|
|
306
|
-
type: "boolean"
|
|
307
|
-
},
|
|
308
|
-
checkEslintrc: {
|
|
309
|
-
default: true,
|
|
310
|
-
type: "boolean"
|
|
311
|
-
},
|
|
312
|
-
checkParams: {
|
|
313
|
-
default: false,
|
|
314
|
-
type: "boolean"
|
|
315
|
-
},
|
|
316
|
-
checkProperties: {
|
|
317
|
-
default: false,
|
|
318
|
-
type: "boolean"
|
|
319
|
-
},
|
|
320
|
-
configFile: { type: "string" },
|
|
321
|
-
exampleCodeRegex: { type: "string" },
|
|
322
|
-
matchingFileName: { type: "string" },
|
|
323
|
-
matchingFileNameDefaults: { type: "string" },
|
|
324
|
-
matchingFileNameParams: { type: "string" },
|
|
325
|
-
matchingFileNameProperties: { type: "string" },
|
|
326
|
-
noDefaultExampleRules: {
|
|
327
|
-
default: false,
|
|
328
|
-
type: "boolean"
|
|
329
|
-
},
|
|
330
|
-
paddedIndent: {
|
|
331
|
-
default: 0,
|
|
332
|
-
type: "integer"
|
|
333
|
-
},
|
|
334
|
-
rejectExampleCodeRegex: { type: "string" },
|
|
335
|
-
reportUnusedDisableDirectives: {
|
|
336
|
-
default: true,
|
|
337
|
-
type: "boolean"
|
|
338
|
-
}
|
|
339
|
-
},
|
|
340
|
-
type: "object"
|
|
341
|
-
}],
|
|
342
|
-
type: "suggestion"
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
//#endregion
|
|
347
|
-
export { checkExamples_default as default };
|
|
348
|
-
//# sourceMappingURL=checkExamples.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"checkExamples.js","names":[],"sources":["../../src/rules/checkExamples.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport eslint, {\n ESLint,\n} from 'eslint';\nimport semver from 'semver';\n\nconst {\n // @ts-expect-error Older ESLint\n CLIEngine,\n} = eslint;\n\nconst zeroBasedLineIndexAdjust = -1;\nconst likelyNestedJSDocIndentSpace = 1;\nconst preTagSpaceLength = 1;\n\n// If a space is present, we should ignore it\nconst firstLinePrefixLength = preTagSpaceLength;\n\nconst hasCaptionRegex = /^\\s*<caption>([\\s\\S]*?)<\\/caption>/v;\n\n/**\n * @param {string} str\n * @returns {string}\n */\nconst escapeStringRegexp = (str) => {\n return str.replaceAll(/[.*+?^$\\{\\}\\(\\)\\|\\[\\]\\\\]/gv, '\\\\$&');\n};\n\n/**\n * @param {string} str\n * @param {string} ch\n * @returns {import('../iterateJsdoc.js').Integer}\n */\nconst countChars = (str, ch) => {\n return (str.match(new RegExp(escapeStringRegexp(ch), 'gv')) || []).length;\n};\n\n/** @type {import('eslint').Linter.RulesRecord} */\nconst defaultMdRules = {\n // \"always\" newline rule at end unlikely in sample code\n 'eol-last': 0,\n\n // Wouldn't generally expect example paths to resolve relative to JS file\n 'import/no-unresolved': 0,\n\n // Snippets likely too short to always include import/export info\n 'import/unambiguous': 0,\n\n 'jsdoc/require-file-overview': 0,\n\n // The end of a multiline comment would end the comment the example is in.\n 'jsdoc/require-jsdoc': 0,\n\n // Unlikely to have inadvertent debugging within examples\n 'no-console': 0,\n\n // Often wish to start `@example` code after newline; also may use\n // empty lines for spacing\n 'no-multiple-empty-lines': 0,\n\n // Many variables in examples will be `undefined`\n 'no-undef': 0,\n\n // Common to define variables for clarity without always using them\n 'no-unused-vars': 0,\n\n // See import/no-unresolved\n 'node/no-missing-import': 0,\n 'node/no-missing-require': 0,\n\n // Can generally look nicer to pad a little even if code imposes more stringency\n 'padded-blocks': 0,\n};\n\n/** @type {import('eslint').Linter.RulesRecord} */\nconst defaultExpressionRules = {\n ...defaultMdRules,\n 'chai-friendly/no-unused-expressions': 'off',\n 'no-empty-function': 'off',\n 'no-new': 'off',\n 'no-unused-expressions': 'off',\n quotes: [\n 'error', 'double',\n ],\n semi: [\n 'error', 'never',\n ],\n strict: 'off',\n};\n\n/**\n * @param {string} text\n * @returns {[\n * import('../iterateJsdoc.js').Integer,\n * import('../iterateJsdoc.js').Integer\n * ]}\n */\nconst getLinesCols = (text) => {\n const matchLines = countChars(text, '\\n');\n\n const colDelta = matchLines ?\n text.slice(text.lastIndexOf('\\n') + 1).length :\n text.length;\n\n return [\n matchLines, colDelta,\n ];\n};\n\nexport default iterateJsdoc(({\n context,\n globalState,\n report,\n utils,\n}) => {\n if (semver.gte(ESLint.version, '8.0.0')) {\n report(\n 'This rule does not work for ESLint 8+; you should disable this rule and use' +\n 'the processor mentioned in the docs.',\n null,\n {\n column: 1,\n line: 1,\n },\n );\n\n return;\n }\n\n if (!globalState.has('checkExamples-matchingFileName')) {\n globalState.set('checkExamples-matchingFileName', new Map());\n }\n\n const matchingFileNameMap = /** @type {Map<string, string>} */ (\n globalState.get('checkExamples-matchingFileName')\n );\n\n const options = context.options[0] || {};\n let {\n exampleCodeRegex = null,\n rejectExampleCodeRegex = null,\n } = options;\n const {\n allowInlineConfig = true,\n baseConfig = {},\n captionRequired = false,\n checkDefaults = false,\n checkEslintrc = true,\n checkParams = false,\n checkProperties = false,\n configFile,\n matchingFileName = null,\n matchingFileNameDefaults = null,\n matchingFileNameParams = null,\n matchingFileNameProperties = null,\n noDefaultExampleRules = false,\n paddedIndent = 0,\n reportUnusedDisableDirectives = true,\n } = options;\n\n // Make this configurable?\n /**\n * @type {never[]}\n */\n const rulePaths = [];\n\n const mdRules = noDefaultExampleRules ? undefined : defaultMdRules;\n\n const expressionRules = noDefaultExampleRules ? undefined : defaultExpressionRules;\n\n if (exampleCodeRegex) {\n exampleCodeRegex = utils.getRegexFromString(exampleCodeRegex);\n }\n\n if (rejectExampleCodeRegex) {\n rejectExampleCodeRegex = utils.getRegexFromString(rejectExampleCodeRegex);\n }\n\n /**\n * @param {{\n * filename: string,\n * defaultFileName: string|undefined,\n * source: string,\n * targetTagName: string,\n * rules?: import('eslint').Linter.RulesRecord|undefined,\n * lines?: import('../iterateJsdoc.js').Integer,\n * cols?: import('../iterateJsdoc.js').Integer,\n * skipInit?: boolean,\n * sources?: {\n * nonJSPrefacingCols: import('../iterateJsdoc.js').Integer,\n * nonJSPrefacingLines: import('../iterateJsdoc.js').Integer,\n * string: string,\n * }[],\n * tag?: import('comment-parser').Spec & {\n * line?: import('../iterateJsdoc.js').Integer,\n * }|{\n * line: import('../iterateJsdoc.js').Integer,\n * }\n * }} cfg\n */\n const checkSource = ({\n cols = 0,\n defaultFileName,\n filename,\n lines = 0,\n rules = expressionRules,\n skipInit,\n source,\n sources = [],\n tag = {\n line: 0,\n },\n targetTagName,\n }) => {\n if (!skipInit) {\n sources.push({\n nonJSPrefacingCols: cols,\n nonJSPrefacingLines: lines,\n string: source,\n });\n }\n\n /**\n * @param {{\n * nonJSPrefacingCols: import('../iterateJsdoc.js').Integer,\n * nonJSPrefacingLines: import('../iterateJsdoc.js').Integer,\n * string: string\n * }} cfg\n */\n const checkRules = function ({\n nonJSPrefacingCols,\n nonJSPrefacingLines,\n string,\n }) {\n const cliConfig = {\n allowInlineConfig,\n baseConfig,\n configFile,\n reportUnusedDisableDirectives,\n rulePaths,\n rules,\n useEslintrc: checkEslintrc,\n };\n const cliConfigStr = JSON.stringify(cliConfig);\n\n const src = paddedIndent ?\n string.replaceAll(new RegExp(`(^|\\n) {${paddedIndent}}(?!$)`, 'gv'), '\\n') :\n string;\n\n // Programmatic ESLint API: https://eslint.org/docs/developer-guide/nodejs-api\n const fileNameMapKey = filename ?\n 'a' + cliConfigStr + filename :\n 'b' + cliConfigStr + defaultFileName;\n const file = filename || defaultFileName;\n let cliFile;\n if (matchingFileNameMap.has(fileNameMapKey)) {\n cliFile = matchingFileNameMap.get(fileNameMapKey);\n } else {\n const cli = new CLIEngine(cliConfig);\n let config;\n if (filename || checkEslintrc) {\n config = cli.getConfigForFile(file);\n }\n\n // We need a new instance to ensure that the rules that may only\n // be available to `file` (if it has its own `.eslintrc`),\n // will be defined.\n cliFile = new CLIEngine({\n allowInlineConfig,\n baseConfig: {\n ...baseConfig,\n ...config,\n },\n configFile,\n reportUnusedDisableDirectives,\n rulePaths,\n rules,\n useEslintrc: false,\n });\n matchingFileNameMap.set(fileNameMapKey, cliFile);\n }\n\n const {\n results: [\n {\n messages,\n },\n ],\n } = cliFile.executeOnText(src);\n\n if (!('line' in tag)) {\n tag.line = tag.source[0].number;\n }\n\n // NOTE: `tag.line` can be 0 if of form `/** @tag ... */`\n const codeStartLine = /**\n * @type {import('comment-parser').Spec & {\n * line: import('../iterateJsdoc.js').Integer,\n * }}\n */ (tag).line + nonJSPrefacingLines;\n const codeStartCol = likelyNestedJSDocIndentSpace;\n\n for (const {\n column,\n line,\n message,\n ruleId,\n severity,\n } of messages) {\n const startLine = codeStartLine + line + zeroBasedLineIndexAdjust;\n const startCol = codeStartCol + (\n\n // This might not work for line 0, but line 0 is unlikely for examples\n line <= 1 ? nonJSPrefacingCols + firstLinePrefixLength : preTagSpaceLength\n ) + column;\n\n report(\n '@' + targetTagName + ' ' + (severity === 2 ? 'error' : 'warning') +\n (ruleId ? ' (' + ruleId + ')' : '') + ': ' +\n message,\n null,\n {\n column: startCol,\n line: startLine,\n },\n );\n }\n };\n\n for (const targetSource of sources) {\n checkRules(targetSource);\n }\n };\n\n /**\n *\n * @param {string} filename\n * @param {string} [ext] Since `eslint-plugin-markdown` v2, and\n * ESLint 7, this is the default which other JS-fenced rules will used.\n * Formerly \"md\" was the default.\n * @returns {{defaultFileName: string|undefined, filename: string}}\n */\n const getFilenameInfo = (filename, ext = 'md/*.js') => {\n let defaultFileName;\n if (!filename) {\n const jsFileName = context.getFilename();\n if (typeof jsFileName === 'string' && jsFileName.includes('.')) {\n defaultFileName = jsFileName.replace(/\\.[^.]*$/v, `.${ext}`);\n } else {\n defaultFileName = `dummy.${ext}`;\n }\n }\n\n return {\n defaultFileName,\n filename,\n };\n };\n\n if (checkDefaults) {\n const filenameInfo = getFilenameInfo(matchingFileNameDefaults, 'jsdoc-defaults');\n utils.forEachPreferredTag('default', (tag, targetTagName) => {\n if (!tag.description.trim()) {\n return;\n }\n\n checkSource({\n source: `(${utils.getTagDescription(tag)})`,\n targetTagName,\n ...filenameInfo,\n });\n });\n }\n\n if (checkParams) {\n const filenameInfo = getFilenameInfo(matchingFileNameParams, 'jsdoc-params');\n utils.forEachPreferredTag('param', (tag, targetTagName) => {\n if (!tag.default || !tag.default.trim()) {\n return;\n }\n\n checkSource({\n source: `(${tag.default})`,\n targetTagName,\n ...filenameInfo,\n });\n });\n }\n\n if (checkProperties) {\n const filenameInfo = getFilenameInfo(matchingFileNameProperties, 'jsdoc-properties');\n utils.forEachPreferredTag('property', (tag, targetTagName) => {\n if (!tag.default || !tag.default.trim()) {\n return;\n }\n\n checkSource({\n source: `(${tag.default})`,\n targetTagName,\n ...filenameInfo,\n });\n });\n }\n\n const tagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'example',\n }));\n if (!utils.hasTag(tagName)) {\n return;\n }\n\n const matchingFilenameInfo = getFilenameInfo(matchingFileName);\n\n utils.forEachPreferredTag('example', (tag, targetTagName) => {\n let source = /** @type {string} */ (utils.getTagDescription(tag));\n const match = source.match(hasCaptionRegex);\n\n if (captionRequired && (!match || !match[1].trim())) {\n report('Caption is expected for examples.', null, tag);\n }\n\n source = source.replace(hasCaptionRegex, '');\n const [\n lines,\n cols,\n ] = match ? getLinesCols(match[0]) : [\n 0, 0,\n ];\n\n if (exampleCodeRegex && !exampleCodeRegex.test(source) ||\n rejectExampleCodeRegex && rejectExampleCodeRegex.test(source)\n ) {\n return;\n }\n\n const sources = [];\n let skipInit = false;\n if (exampleCodeRegex) {\n let nonJSPrefacingCols = 0;\n let nonJSPrefacingLines = 0;\n\n let startingIndex = 0;\n let lastStringCount = 0;\n\n let exampleCode;\n exampleCodeRegex.lastIndex = 0;\n while ((exampleCode = exampleCodeRegex.exec(source)) !== null) {\n const {\n '0': n0,\n '1': n1,\n index,\n } = exampleCode;\n\n // Count anything preceding user regex match (can affect line numbering)\n const preMatch = source.slice(startingIndex, index);\n\n const [\n preMatchLines,\n colDelta,\n ] = getLinesCols(preMatch);\n\n let nonJSPreface;\n let nonJSPrefaceLineCount;\n if (n1) {\n const idx = n0.indexOf(n1);\n nonJSPreface = n0.slice(0, idx);\n nonJSPrefaceLineCount = countChars(nonJSPreface, '\\n');\n } else {\n nonJSPreface = '';\n nonJSPrefaceLineCount = 0;\n }\n\n nonJSPrefacingLines += lastStringCount + preMatchLines + nonJSPrefaceLineCount;\n\n // Ignore `preMatch` delta if newlines here\n if (nonJSPrefaceLineCount) {\n const charsInLastLine = nonJSPreface.slice(nonJSPreface.lastIndexOf('\\n') + 1).length;\n\n nonJSPrefacingCols += charsInLastLine;\n } else {\n nonJSPrefacingCols += colDelta + nonJSPreface.length;\n }\n\n const string = n1 || n0;\n sources.push({\n nonJSPrefacingCols,\n nonJSPrefacingLines,\n string,\n });\n startingIndex = exampleCodeRegex.lastIndex;\n lastStringCount = countChars(string, '\\n');\n if (!exampleCodeRegex.global) {\n break;\n }\n }\n\n skipInit = true;\n }\n\n checkSource({\n cols,\n lines,\n rules: mdRules,\n skipInit,\n source,\n sources,\n tag,\n targetTagName,\n ...matchingFilenameInfo,\n });\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Ensures that (JavaScript) examples within JSDoc adhere to ESLint rules.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-examples.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n allowInlineConfig: {\n default: true,\n type: 'boolean',\n },\n baseConfig: {\n type: 'object',\n },\n captionRequired: {\n default: false,\n type: 'boolean',\n },\n checkDefaults: {\n default: false,\n type: 'boolean',\n },\n checkEslintrc: {\n default: true,\n type: 'boolean',\n },\n checkParams: {\n default: false,\n type: 'boolean',\n },\n checkProperties: {\n default: false,\n type: 'boolean',\n },\n configFile: {\n type: 'string',\n },\n exampleCodeRegex: {\n type: 'string',\n },\n matchingFileName: {\n type: 'string',\n },\n matchingFileNameDefaults: {\n type: 'string',\n },\n matchingFileNameParams: {\n type: 'string',\n },\n matchingFileNameProperties: {\n type: 'string',\n },\n noDefaultExampleRules: {\n default: false,\n type: 'boolean',\n },\n paddedIndent: {\n default: 0,\n type: 'integer',\n },\n rejectExampleCodeRegex: {\n type: 'string',\n },\n reportUnusedDisableDirectives: {\n default: true,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;AAMA,MAAM,EAEJ,WACD,GAAG;AAEJ,MAAM,2BAA2B;AACjC,MAAM,+BAA+B;AACrC,MAAM,oBAAoB;AAG1B,MAAM,wBAAwB;AAE9B,MAAM,kBAAkB;;;;;AAMxB,MAAM,qBAAqB,CAAC,QAAQ;AAClC,QAAO,IAAI,WAAW,8BAA8B,OAAO;AAC5D;;;;;;AAOD,MAAM,aAAa,CAAC,KAAK,OAAO;AAC9B,SAAQ,IAAI,MAAM,IAAI,OAAO,mBAAmB,GAAG,EAAE,MAAM,IAAI,CAAE,GAAE;AACpE;;AAGD,MAAM,iBAAiB;CAErB,YAAY;CAGZ,wBAAwB;CAGxB,sBAAsB;CAEtB,+BAA+B;CAG/B,uBAAuB;CAGvB,cAAc;CAId,2BAA2B;CAG3B,YAAY;CAGZ,kBAAkB;CAGlB,0BAA0B;CAC1B,2BAA2B;CAG3B,iBAAiB;AAClB;;AAGD,MAAM,yBAAyB;CAC7B,GAAG;CACH,uCAAuC;CACvC,qBAAqB;CACrB,UAAU;CACV,yBAAyB;CACzB,QAAQ,CACN,SAAS,QACV;CACD,MAAM,CACJ,SAAS,OACV;CACD,QAAQ;AACT;;;;;;;;AASD,MAAM,eAAe,CAAC,SAAS;CAC7B,MAAM,aAAa,WAAW,MAAM,KAAK;CAEzC,MAAM,WAAW,aACf,KAAK,MAAM,KAAK,YAAY,KAAK,GAAG,EAAE,CAAC,SACvC,KAAK;AAEP,QAAO,CACL,YAAY,QACb;AACF;AAED,4BAAe,aAAa,CAAC,EAC3B,SACA,a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ACA;GACA,GAAG;EACJ,EAAC;CACH,EAAC;AACH,GAAE;CACD,kBAAkB;CAClB,MAAM;EACJ,MAAM;GACJ,aAAa;GACb,KAAK;EACN;EACD,QAAQ,CACN;GACE,sBAAsB;GACtB,YAAY;IACV,mBAAmB;KACjB,SAAS;KACT,MAAM;IACP;IACD,YAAY,EACV,MAAM,SACP;IACD,iBAAiB;KACf,SAAS;KACT,MAAM;IACP;IACD,eAAe;KACb,SAAS;KACT,MAAM;IACP;IACD,eAAe;KACb,SAAS;KACT,MAAM;IACP;IACD,aAAa;KACX,SAAS;KACT,MAAM;IACP;IACD,iBAAiB;KACf,SAAS;KACT,MAAM;IACP;IACD,YAAY,EACV,MAAM,SACP;IACD,kBAAkB,EAChB,MAAM,SACP;IACD,kBAAkB,EAChB,MAAM,SACP;IACD,0BAA0B,EACxB,MAAM,SACP;IACD,wBAAwB,EACtB,MAAM,SACP;IACD,4BAA4B,EAC1B,MAAM,SACP;IACD,uBAAuB;KACrB,SAAS;KACT,MAAM;IACP;IACD,cAAc;KACZ,SAAS;KACT,MAAM;IACP;IACD,wBAAwB,EACtB,MAAM,SACP;IACD,+BAA+B;KAC7B,SAAS;KACT,MAAM;IACP;GACF;GACD,MAAM;EACP,CACF;EACD,MAAM;CACP;AACF,EAAC"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import iterateJsdoc from "../iterateJsdoc.js";
|
|
2
|
-
|
|
3
|
-
//#region src/rules/checkIndentation.js
|
|
4
|
-
/**
|
|
5
|
-
* @param {string} str
|
|
6
|
-
* @param {string[]} excludeTags
|
|
7
|
-
* @returns {string}
|
|
8
|
-
*/
|
|
9
|
-
const maskExcludedContent = (str, excludeTags) => {
|
|
10
|
-
const regContent = new RegExp(`([ \\t]+\\*)[ \\t]@(?:${excludeTags.join("|")})(?=[ \\n])([\\w\\|\\W]*?\\n)(?=[ \\t]*\\*(?:[ \\t]*@\\w+\\s|\\/))`, "gv");
|
|
11
|
-
return str.replace(regContent, (_match, margin, code) => {
|
|
12
|
-
return (margin + "\n").repeat(code.match(/\n/gv).length);
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* @param {string} str
|
|
17
|
-
* @returns {string}
|
|
18
|
-
*/
|
|
19
|
-
const maskCodeBlocks = (str) => {
|
|
20
|
-
const regContent = /([ \t]+\*)[ \t]```[^\n]*?([\w\|\W]*?\n)(?=[ \t]*\*(?:[ \t]*(?:```|@\w+\s)|\/))/gv;
|
|
21
|
-
return str.replaceAll(regContent, (_match, margin, code) => {
|
|
22
|
-
return (margin + "\n").repeat(code.match(/\n/gv).length);
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
var checkIndentation_default = iterateJsdoc(({ context, jsdocNode, report, sourceCode }) => {
|
|
26
|
-
const options = context.options[0] || {};
|
|
27
|
-
const { excludeTags = ["example"] } = options;
|
|
28
|
-
const reg = /^(?:\/?\**|[ \t]*)\*[ \t]{2}/gmv;
|
|
29
|
-
const textWithoutCodeBlocks = maskCodeBlocks(sourceCode.getText(jsdocNode));
|
|
30
|
-
const text = excludeTags.length ? maskExcludedContent(textWithoutCodeBlocks, excludeTags) : textWithoutCodeBlocks;
|
|
31
|
-
if (reg.test(text)) {
|
|
32
|
-
const lineBreaks = text.slice(0, reg.lastIndex).match(/\n/gv) || [];
|
|
33
|
-
report("There must be no indentation.", null, { line: lineBreaks.length });
|
|
34
|
-
}
|
|
35
|
-
}, {
|
|
36
|
-
iterateAllJsdocs: true,
|
|
37
|
-
meta: {
|
|
38
|
-
docs: {
|
|
39
|
-
description: "Reports invalid padding inside JSDoc blocks.",
|
|
40
|
-
url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-indentation.md#repos-sticky-header"
|
|
41
|
-
},
|
|
42
|
-
schema: [{
|
|
43
|
-
additionalProperties: false,
|
|
44
|
-
properties: { excludeTags: {
|
|
45
|
-
items: {
|
|
46
|
-
pattern: "^\\S+$",
|
|
47
|
-
type: "string"
|
|
48
|
-
},
|
|
49
|
-
type: "array"
|
|
50
|
-
} },
|
|
51
|
-
type: "object"
|
|
52
|
-
}],
|
|
53
|
-
type: "layout"
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
//#endregion
|
|
58
|
-
export { checkIndentation_default as default };
|
|
59
|
-
//# sourceMappingURL=checkIndentation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"checkIndentation.js","names":[],"sources":["../../src/rules/checkIndentation.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * @param {string} str\n * @param {string[]} excludeTags\n * @returns {string}\n */\nconst maskExcludedContent = (str, excludeTags) => {\n const regContent = new RegExp(`([ \\\\t]+\\\\*)[ \\\\t]@(?:${excludeTags.join('|')})(?=[ \\\\n])([\\\\w\\\\|\\\\W]*?\\\\n)(?=[ \\\\t]*\\\\*(?:[ \\\\t]*@\\\\w+\\\\s|\\\\/))`, 'gv');\n\n return str.replace(regContent, (_match, margin, code) => {\n return (margin + '\\n').repeat(code.match(/\\n/gv).length);\n });\n};\n\n/**\n * @param {string} str\n * @returns {string}\n */\nconst maskCodeBlocks = (str) => {\n const regContent = /([ \\t]+\\*)[ \\t]```[^\\n]*?([\\w\\|\\W]*?\\n)(?=[ \\t]*\\*(?:[ \\t]*(?:```|@\\w+\\s)|\\/))/gv;\n\n return str.replaceAll(regContent, (_match, margin, code) => {\n return (margin + '\\n').repeat(code.match(/\\n/gv).length);\n });\n};\n\nexport default iterateJsdoc(({\n context,\n jsdocNode,\n report,\n sourceCode,\n}) => {\n const options = context.options[0] || {};\n const /** @type {{excludeTags: string[]}} */ {\n excludeTags = [\n 'example',\n ],\n } = options;\n\n const reg = /^(?:\\/?\\**|[ \\t]*)\\*[ \\t]{2}/gmv;\n const textWithoutCodeBlocks = maskCodeBlocks(sourceCode.getText(jsdocNode));\n const text = excludeTags.length ? maskExcludedContent(textWithoutCodeBlocks, excludeTags) : textWithoutCodeBlocks;\n\n if (reg.test(text)) {\n const lineBreaks = text.slice(0, reg.lastIndex).match(/\\n/gv) || [];\n report('There must be no indentation.', null, {\n line: lineBreaks.length,\n });\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Reports invalid padding inside JSDoc blocks.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-indentation.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n excludeTags: {\n items: {\n pattern: '^\\\\S+$',\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\n },\n});\n"],"mappings":";;;;;;;;AAOA,MAAM,sBAAsB,CAAC,KAAK,gBAAgB;CAChD,MAAM,aAAa,IAAI,OAAO,CAAC,sBAAsB,EAAE,YAAY,KAAK,IAAI,CAAC,kEAAkE,CAAC,EAAE;AAElJ,QAAO,IAAI,QAAQ,YAAY,CAAC,QAAQ,QAAQ,SAAS;AACvD,UAAQ,SAAS,MAAM,OAAO,KAAK,MAAM,OAAO,CAAC,OAAO;CACzD,EAAC;AACH;;;;;AAMD,MAAM,iBAAiB,CAAC,QAAQ;CAC9B,MAAM,aAAa;AAEnB,QAAO,IAAI,WAAW,YAAY,CAAC,QAAQ,QAAQ,SAAS;AAC1D,UAAQ,SAAS,MAAM,OAAO,KAAK,MAAM,OAAO,CAAC,OAAO;CACzD,EAAC;AACH;AAED,+BAAe,aAAa,CAAC,EAC3B,SACA,WACA,QACA,YACD,KAAK;CACJ,MAAM,UAAU,QAAQ,QAAQ,MAAM,CAAE;CACxC,MAA6C,EAC3C,cAAc,CACZ,SACD,GACF,GAAG;CAEJ,MAAM,MAAM;CACZ,MAAM,wBAAwB,eAAe,WAAW,QAAQ,UAAU,CAAC;CAC3E,MAAM,OAAO,YAAY,SAAS,oBAAoB,uBAAuB,YAAY,GAAG;AAE5F,KAAI,IAAI,KAAK,KAAK,EAAE;EAClB,MAAM,aAAa,KAAK,MAAM,GAAG,IA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