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
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import iterateJsdoc from '../iterateJsdoc.js';
|
|
2
|
+
|
|
3
|
+
export default iterateJsdoc(({
|
|
4
|
+
context,
|
|
5
|
+
indent,
|
|
6
|
+
jsdoc,
|
|
7
|
+
utils,
|
|
8
|
+
}) => {
|
|
9
|
+
const [
|
|
10
|
+
defaultRequireValue = 'always',
|
|
11
|
+
{
|
|
12
|
+
tags: tagMap = {},
|
|
13
|
+
} = {},
|
|
14
|
+
] = context.options;
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
source,
|
|
18
|
+
} = jsdoc;
|
|
19
|
+
|
|
20
|
+
const always = defaultRequireValue === 'always';
|
|
21
|
+
const never = defaultRequireValue === 'never';
|
|
22
|
+
|
|
23
|
+
/** @type {string} */
|
|
24
|
+
let currentTag;
|
|
25
|
+
source.some(({
|
|
26
|
+
number,
|
|
27
|
+
tokens,
|
|
28
|
+
}) => {
|
|
29
|
+
const {
|
|
30
|
+
delimiter,
|
|
31
|
+
description,
|
|
32
|
+
end,
|
|
33
|
+
tag,
|
|
34
|
+
} = tokens;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @returns {void}
|
|
38
|
+
*/
|
|
39
|
+
const neverFix = () => {
|
|
40
|
+
tokens.delimiter = '';
|
|
41
|
+
tokens.postDelimiter = '';
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @param {string} checkValue
|
|
46
|
+
* @returns {boolean}
|
|
47
|
+
*/
|
|
48
|
+
const checkNever = (checkValue) => {
|
|
49
|
+
if (delimiter && delimiter !== '/**' && (
|
|
50
|
+
never && !tagMap.always?.includes(checkValue) ||
|
|
51
|
+
tagMap.never?.includes(checkValue)
|
|
52
|
+
)) {
|
|
53
|
+
utils.reportJSDoc('Expected JSDoc line to have no prefix.', {
|
|
54
|
+
column: 0,
|
|
55
|
+
line: number,
|
|
56
|
+
}, neverFix);
|
|
57
|
+
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return false;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @returns {void}
|
|
66
|
+
*/
|
|
67
|
+
const alwaysFix = () => {
|
|
68
|
+
if (!tokens.start) {
|
|
69
|
+
tokens.start = indent + ' ';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
tokens.delimiter = '*';
|
|
73
|
+
tokens.postDelimiter = tag || description ? ' ' : '';
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @param {string} checkValue
|
|
78
|
+
* @returns {boolean}
|
|
79
|
+
*/
|
|
80
|
+
const checkAlways = (checkValue) => {
|
|
81
|
+
if (
|
|
82
|
+
!delimiter && (
|
|
83
|
+
always && !tagMap.never?.includes(checkValue) ||
|
|
84
|
+
tagMap.always?.includes(checkValue)
|
|
85
|
+
)
|
|
86
|
+
) {
|
|
87
|
+
utils.reportJSDoc('Expected JSDoc line to have the prefix.', {
|
|
88
|
+
column: 0,
|
|
89
|
+
line: number,
|
|
90
|
+
}, alwaysFix);
|
|
91
|
+
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return false;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
if (tag) {
|
|
99
|
+
// Remove at sign
|
|
100
|
+
currentTag = tag.slice(1);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (
|
|
104
|
+
// If this is the end but has a tag, the delimiter will also be
|
|
105
|
+
// populated and will be safely ignored later
|
|
106
|
+
end && !tag
|
|
107
|
+
) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (!currentTag) {
|
|
112
|
+
if (tagMap.any?.includes('*description')) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (checkNever('*description')) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (checkAlways('*description')) {
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (tagMap.any?.includes(currentTag)) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (checkNever(currentTag)) {
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (checkAlways(currentTag)) {
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return false;
|
|
140
|
+
});
|
|
141
|
+
}, {
|
|
142
|
+
iterateAllJsdocs: true,
|
|
143
|
+
meta: {
|
|
144
|
+
docs: {
|
|
145
|
+
description:
|
|
146
|
+
'Requires that each JSDoc line starts with an `*`.',
|
|
147
|
+
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-asterisk-prefix.md#repos-sticky-header',
|
|
148
|
+
},
|
|
149
|
+
fixable: 'code',
|
|
150
|
+
schema: [
|
|
151
|
+
{
|
|
152
|
+
enum: [
|
|
153
|
+
'always', 'never', 'any',
|
|
154
|
+
],
|
|
155
|
+
type: 'string',
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
additionalProperties: false,
|
|
159
|
+
properties: {
|
|
160
|
+
tags: {
|
|
161
|
+
additionalProperties: false,
|
|
162
|
+
properties: {
|
|
163
|
+
always: {
|
|
164
|
+
items: {
|
|
165
|
+
type: 'string',
|
|
166
|
+
},
|
|
167
|
+
type: 'array',
|
|
168
|
+
},
|
|
169
|
+
any: {
|
|
170
|
+
items: {
|
|
171
|
+
type: 'string',
|
|
172
|
+
},
|
|
173
|
+
type: 'array',
|
|
174
|
+
},
|
|
175
|
+
never: {
|
|
176
|
+
items: {
|
|
177
|
+
type: 'string',
|
|
178
|
+
},
|
|
179
|
+
type: 'array',
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
type: 'object',
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
type: 'object',
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
type: 'layout',
|
|
189
|
+
},
|
|
190
|
+
});
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import iterateJsdoc from '../iterateJsdoc.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {string} description
|
|
5
|
+
* @returns {import('../iterateJsdoc.js').Integer}
|
|
6
|
+
*/
|
|
7
|
+
const checkDescription = (description) => {
|
|
8
|
+
return description
|
|
9
|
+
.trim()
|
|
10
|
+
.split('\n')
|
|
11
|
+
.filter(Boolean)
|
|
12
|
+
.length;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default iterateJsdoc(({
|
|
16
|
+
context,
|
|
17
|
+
jsdoc,
|
|
18
|
+
report,
|
|
19
|
+
utils,
|
|
20
|
+
}) => {
|
|
21
|
+
if (utils.avoidDocs()) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const {
|
|
26
|
+
descriptionStyle = 'body',
|
|
27
|
+
} = context.options[0] || {};
|
|
28
|
+
|
|
29
|
+
let targetTagName = utils.getPreferredTagName({
|
|
30
|
+
// We skip reporting except when `@description` is essential to the rule,
|
|
31
|
+
// so user can block the tag and still meaningfully use this rule
|
|
32
|
+
// even if the tag is present (and `check-tag-names` is the one to
|
|
33
|
+
// normally report the fact that it is blocked but present)
|
|
34
|
+
skipReportingBlockedTag: descriptionStyle !== 'tag',
|
|
35
|
+
tagName: 'description',
|
|
36
|
+
});
|
|
37
|
+
if (!targetTagName) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const isBlocked = typeof targetTagName === 'object' && 'blocked' in targetTagName && targetTagName.blocked;
|
|
42
|
+
if (isBlocked) {
|
|
43
|
+
targetTagName = /** @type {{blocked: true; tagName: string;}} */ (
|
|
44
|
+
targetTagName
|
|
45
|
+
).tagName;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (descriptionStyle !== 'tag') {
|
|
49
|
+
const {
|
|
50
|
+
description,
|
|
51
|
+
} = utils.getDescription();
|
|
52
|
+
if (checkDescription(description || '')) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (descriptionStyle === 'body') {
|
|
57
|
+
const descTags = utils.getPresentTags([
|
|
58
|
+
'desc', 'description',
|
|
59
|
+
]);
|
|
60
|
+
if (descTags.length) {
|
|
61
|
+
const [
|
|
62
|
+
{
|
|
63
|
+
tag: tagName,
|
|
64
|
+
},
|
|
65
|
+
] = descTags;
|
|
66
|
+
report(`Remove the @${tagName} tag to leave a plain block description or add additional description text above the @${tagName} line.`);
|
|
67
|
+
} else {
|
|
68
|
+
report('Missing JSDoc block description.');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const functionExamples = isBlocked ?
|
|
76
|
+
[] :
|
|
77
|
+
jsdoc.tags.filter(({
|
|
78
|
+
tag,
|
|
79
|
+
}) => {
|
|
80
|
+
return tag === targetTagName;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (!functionExamples.length) {
|
|
84
|
+
report(
|
|
85
|
+
descriptionStyle === 'any' ?
|
|
86
|
+
`Missing JSDoc block description or @${targetTagName} declaration.` :
|
|
87
|
+
`Missing JSDoc @${targetTagName} declaration.`,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
for (const example of functionExamples) {
|
|
94
|
+
if (!checkDescription(`${example.name} ${utils.getTagDescription(example)}`)) {
|
|
95
|
+
report(`Missing JSDoc @${targetTagName} description.`, null, example);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}, {
|
|
99
|
+
contextDefaults: true,
|
|
100
|
+
meta: {
|
|
101
|
+
docs: {
|
|
102
|
+
description: 'Requires that all functions have a description.',
|
|
103
|
+
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-description.md#repos-sticky-header',
|
|
104
|
+
},
|
|
105
|
+
schema: [
|
|
106
|
+
{
|
|
107
|
+
additionalProperties: false,
|
|
108
|
+
properties: {
|
|
109
|
+
checkConstructors: {
|
|
110
|
+
default: true,
|
|
111
|
+
type: 'boolean',
|
|
112
|
+
},
|
|
113
|
+
checkGetters: {
|
|
114
|
+
default: true,
|
|
115
|
+
type: 'boolean',
|
|
116
|
+
},
|
|
117
|
+
checkSetters: {
|
|
118
|
+
default: true,
|
|
119
|
+
type: 'boolean',
|
|
120
|
+
},
|
|
121
|
+
contexts: {
|
|
122
|
+
items: {
|
|
123
|
+
anyOf: [
|
|
124
|
+
{
|
|
125
|
+
type: 'string',
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
additionalProperties: false,
|
|
129
|
+
properties: {
|
|
130
|
+
comment: {
|
|
131
|
+
type: 'string',
|
|
132
|
+
},
|
|
133
|
+
context: {
|
|
134
|
+
type: 'string',
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
type: 'object',
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
},
|
|
141
|
+
type: 'array',
|
|
142
|
+
},
|
|
143
|
+
descriptionStyle: {
|
|
144
|
+
enum: [
|
|
145
|
+
'body', 'tag', 'any',
|
|
146
|
+
],
|
|
147
|
+
type: 'string',
|
|
148
|
+
},
|
|
149
|
+
exemptedBy: {
|
|
150
|
+
items: {
|
|
151
|
+
type: 'string',
|
|
152
|
+
},
|
|
153
|
+
type: 'array',
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
type: 'object',
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
type: 'suggestion',
|
|
160
|
+
},
|
|
161
|
+
});
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import iterateJsdoc from '../iterateJsdoc.js';
|
|
2
|
+
import escapeStringRegexp from 'escape-string-regexp';
|
|
3
|
+
|
|
4
|
+
const otherDescriptiveTags = new Set([
|
|
5
|
+
'classdesc', 'deprecated', 'exception', 'file', 'fileoverview', 'overview',
|
|
6
|
+
// 'copyright' and 'see' might be good addition, but as the former may be
|
|
7
|
+
// sensitive text, and the latter may have just a link, they are not
|
|
8
|
+
// included by default
|
|
9
|
+
'summary', 'throws', 'todo', 'yield', 'yields',
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} text
|
|
14
|
+
* @returns {string[]}
|
|
15
|
+
*/
|
|
16
|
+
const extractParagraphs = (text) => {
|
|
17
|
+
return text.split(/(?<![;:])\n\n+/v);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {string} text
|
|
22
|
+
* @param {string|RegExp} abbreviationsRegex
|
|
23
|
+
* @returns {string[]}
|
|
24
|
+
*/
|
|
25
|
+
const extractSentences = (text, abbreviationsRegex) => {
|
|
26
|
+
const txt = text
|
|
27
|
+
// Remove all {} tags.
|
|
28
|
+
.replaceAll(/(?<!^)\{[\s\S]*?\}\s*/gv, '')
|
|
29
|
+
|
|
30
|
+
// Remove custom abbreviations
|
|
31
|
+
.replace(abbreviationsRegex, '');
|
|
32
|
+
|
|
33
|
+
const sentenceEndGrouping = /([.?!])(?:\s+|$)/gv;
|
|
34
|
+
|
|
35
|
+
const puncts = [
|
|
36
|
+
...txt.matchAll(sentenceEndGrouping),
|
|
37
|
+
].map((sentEnd) => {
|
|
38
|
+
return sentEnd[0];
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return txt
|
|
42
|
+
.split(/[.?!](?:\s+|$)/v)
|
|
43
|
+
|
|
44
|
+
// Re-add the dot.
|
|
45
|
+
.map((sentence, idx) => {
|
|
46
|
+
return !puncts[idx] && /^\s*$/v.test(sentence) ? sentence : `${sentence}${puncts[idx] || ''}`;
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @param {string} text
|
|
52
|
+
* @returns {boolean}
|
|
53
|
+
*/
|
|
54
|
+
const isNewLinePrecededByAPeriod = (text) => {
|
|
55
|
+
/** @type {boolean} */
|
|
56
|
+
let lastLineEndsSentence;
|
|
57
|
+
|
|
58
|
+
const lines = text.split('\n');
|
|
59
|
+
|
|
60
|
+
return !lines.some((line) => {
|
|
61
|
+
if (lastLineEndsSentence === false && /^[A-Z][a-z]/v.test(line)) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
lastLineEndsSentence = /[.:?!\|]$/v.test(line);
|
|
66
|
+
|
|
67
|
+
return false;
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @param {string} str
|
|
73
|
+
* @returns {boolean}
|
|
74
|
+
*/
|
|
75
|
+
const isCapitalized = (str) => {
|
|
76
|
+
return str[0] === str[0].toUpperCase();
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @param {string} str
|
|
81
|
+
* @returns {boolean}
|
|
82
|
+
*/
|
|
83
|
+
const isTable = (str) => {
|
|
84
|
+
return str.charAt(0) === '|';
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @param {string} str
|
|
89
|
+
* @returns {string}
|
|
90
|
+
*/
|
|
91
|
+
const capitalize = (str) => {
|
|
92
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @param {string} description
|
|
97
|
+
* @param {import('../iterateJsdoc.js').Report} reportOrig
|
|
98
|
+
* @param {import('eslint').Rule.Node} jsdocNode
|
|
99
|
+
* @param {string|RegExp} abbreviationsRegex
|
|
100
|
+
* @param {import('eslint').SourceCode} sourceCode
|
|
101
|
+
* @param {import('comment-parser').Spec|{
|
|
102
|
+
* line: import('../iterateJsdoc.js').Integer
|
|
103
|
+
* }} tag
|
|
104
|
+
* @param {boolean} newlineBeforeCapsAssumesBadSentenceEnd
|
|
105
|
+
* @returns {boolean}
|
|
106
|
+
*/
|
|
107
|
+
const validateDescription = (
|
|
108
|
+
description, reportOrig, jsdocNode, abbreviationsRegex,
|
|
109
|
+
sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd,
|
|
110
|
+
) => {
|
|
111
|
+
if (!description || (/^\n+$/v).test(description)) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const descriptionNoHeadings = description.replaceAll(/^\s*#[^\n]*(\n|$)/gmv, '');
|
|
116
|
+
|
|
117
|
+
const paragraphs = extractParagraphs(descriptionNoHeadings).filter(Boolean);
|
|
118
|
+
|
|
119
|
+
return paragraphs.some((paragraph, parIdx) => {
|
|
120
|
+
const sentences = extractSentences(paragraph, abbreviationsRegex);
|
|
121
|
+
|
|
122
|
+
const fix = /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {
|
|
123
|
+
let text = sourceCode.getText(jsdocNode);
|
|
124
|
+
|
|
125
|
+
if (!/[.:?!]$/v.test(paragraph)) {
|
|
126
|
+
const line = paragraph.split('\n').findLast(Boolean);
|
|
127
|
+
text = text.replace(new RegExp(`${escapeStringRegexp(
|
|
128
|
+
/** @type {string} */
|
|
129
|
+
(line),
|
|
130
|
+
)}$`, 'mv'), `${line}.`);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
for (const sentence of sentences.filter((sentence_) => {
|
|
134
|
+
return !(/^\s*$/v).test(sentence_) && !isCapitalized(sentence_) &&
|
|
135
|
+
!isTable(sentence_);
|
|
136
|
+
})) {
|
|
137
|
+
const beginning = sentence.split('\n')[0];
|
|
138
|
+
|
|
139
|
+
if ('tag' in tag && tag.tag) {
|
|
140
|
+
const reg = new RegExp(`(@${escapeStringRegexp(tag.tag)}.*)${escapeStringRegexp(beginning)}`, 'v');
|
|
141
|
+
|
|
142
|
+
text = text.replace(reg, (_$0, $1) => {
|
|
143
|
+
return $1 + capitalize(beginning);
|
|
144
|
+
});
|
|
145
|
+
} else {
|
|
146
|
+
text = text.replace(new RegExp('((?:[.?!]|\\*|\\})\\s*)' + escapeStringRegexp(beginning), 'v'), '$1' + capitalize(beginning));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return fixer.replaceText(jsdocNode, text);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @param {string} msg
|
|
155
|
+
* @param {import('eslint').Rule.ReportFixer | null | undefined} fixer
|
|
156
|
+
* @param {{
|
|
157
|
+
* line?: number | undefined;
|
|
158
|
+
* column?: number | undefined;
|
|
159
|
+
* } | (import('comment-parser').Spec & {
|
|
160
|
+
* line?: number | undefined;
|
|
161
|
+
* column?: number | undefined;
|
|
162
|
+
* })} tagObj
|
|
163
|
+
* @returns {void}
|
|
164
|
+
*/
|
|
165
|
+
const report = (msg, fixer, tagObj) => {
|
|
166
|
+
if ('line' in tagObj) {
|
|
167
|
+
/**
|
|
168
|
+
* @type {{
|
|
169
|
+
* line: number;
|
|
170
|
+
* }}
|
|
171
|
+
*/ (tagObj).line += parIdx * 2;
|
|
172
|
+
} else {
|
|
173
|
+
/** @type {import('comment-parser').Spec} */ (
|
|
174
|
+
tagObj
|
|
175
|
+
).source[0].number += parIdx * 2;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Avoid errors if old column doesn't exist here
|
|
179
|
+
tagObj.column = 0;
|
|
180
|
+
reportOrig(msg, fixer, tagObj);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
if (sentences.some((sentence) => {
|
|
184
|
+
return (/^[.?!]$/v).test(sentence);
|
|
185
|
+
})) {
|
|
186
|
+
report('Sentences must be more than punctuation.', null, tag);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (sentences.some((sentence) => {
|
|
190
|
+
return !(/^\s*$/v).test(sentence) && !isCapitalized(sentence) && !isTable(sentence);
|
|
191
|
+
})) {
|
|
192
|
+
report('Sentences should start with an uppercase character.', fix, tag);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const paragraphNoAbbreviations = paragraph.replace(abbreviationsRegex, '');
|
|
196
|
+
|
|
197
|
+
if (!/(?:[.?!\|]|```)\s*$/v.test(paragraphNoAbbreviations)) {
|
|
198
|
+
report('Sentences must end with a period.', fix, tag);
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (newlineBeforeCapsAssumesBadSentenceEnd && !isNewLinePrecededByAPeriod(paragraphNoAbbreviations)) {
|
|
203
|
+
report('A line of text is started with an uppercase character, but the preceding line does not end the sentence.', null, tag);
|
|
204
|
+
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return false;
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
export default iterateJsdoc(({
|
|
213
|
+
context,
|
|
214
|
+
jsdoc,
|
|
215
|
+
jsdocNode,
|
|
216
|
+
report,
|
|
217
|
+
sourceCode,
|
|
218
|
+
utils,
|
|
219
|
+
}) => {
|
|
220
|
+
const /** @type {{abbreviations: string[], newlineBeforeCapsAssumesBadSentenceEnd: boolean}} */ {
|
|
221
|
+
abbreviations = [],
|
|
222
|
+
newlineBeforeCapsAssumesBadSentenceEnd = false,
|
|
223
|
+
} = context.options[0] || {};
|
|
224
|
+
|
|
225
|
+
const abbreviationsRegex = abbreviations.length ?
|
|
226
|
+
new RegExp('\\b' + abbreviations.map((abbreviation) => {
|
|
227
|
+
return escapeStringRegexp(abbreviation.replaceAll(/\.$/gv, '') + '.');
|
|
228
|
+
}).join('|') + '(?:$|\\s)', 'gv') :
|
|
229
|
+
'';
|
|
230
|
+
|
|
231
|
+
let {
|
|
232
|
+
description,
|
|
233
|
+
} = utils.getDescription();
|
|
234
|
+
|
|
235
|
+
const indices = [
|
|
236
|
+
...description.matchAll(/```[\s\S]*```/gv),
|
|
237
|
+
].map((match) => {
|
|
238
|
+
const {
|
|
239
|
+
index,
|
|
240
|
+
} = match;
|
|
241
|
+
const [
|
|
242
|
+
{
|
|
243
|
+
length,
|
|
244
|
+
},
|
|
245
|
+
] = match;
|
|
246
|
+
return {
|
|
247
|
+
index,
|
|
248
|
+
length,
|
|
249
|
+
};
|
|
250
|
+
}).reverse();
|
|
251
|
+
|
|
252
|
+
for (const {
|
|
253
|
+
index,
|
|
254
|
+
length,
|
|
255
|
+
} of indices) {
|
|
256
|
+
description = description.slice(0, index) +
|
|
257
|
+
description.slice(/** @type {import('../iterateJsdoc.js').Integer} */ (
|
|
258
|
+
index
|
|
259
|
+
) + length);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (validateDescription(description, report, jsdocNode, abbreviationsRegex, sourceCode, {
|
|
263
|
+
line: jsdoc.source[0].number + 1,
|
|
264
|
+
}, newlineBeforeCapsAssumesBadSentenceEnd)) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
utils.forEachPreferredTag('description', (matchingJsdocTag) => {
|
|
269
|
+
const desc = `${matchingJsdocTag.name} ${utils.getTagDescription(matchingJsdocTag)}`.trim();
|
|
270
|
+
validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, matchingJsdocTag, newlineBeforeCapsAssumesBadSentenceEnd);
|
|
271
|
+
}, true);
|
|
272
|
+
|
|
273
|
+
const {
|
|
274
|
+
tagsWithNames,
|
|
275
|
+
} = utils.getTagsByType(jsdoc.tags);
|
|
276
|
+
const tagsWithoutNames = utils.filterTags(({
|
|
277
|
+
tag: tagName,
|
|
278
|
+
}) => {
|
|
279
|
+
return otherDescriptiveTags.has(tagName) ||
|
|
280
|
+
utils.hasOptionTag(tagName) && !tagsWithNames.some(({
|
|
281
|
+
tag,
|
|
282
|
+
}) => {
|
|
283
|
+
// If user accidentally adds tags with names (or like `returns`
|
|
284
|
+
// get parsed as having names), do not add to this list
|
|
285
|
+
return tag === tagName;
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
tagsWithNames.some((tag) => {
|
|
290
|
+
const desc = /** @type {string} */ (
|
|
291
|
+
utils.getTagDescription(tag)
|
|
292
|
+
).replace(/^- /v, '').trimEnd();
|
|
293
|
+
|
|
294
|
+
return validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd);
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
tagsWithoutNames.some((tag) => {
|
|
298
|
+
const desc = `${tag.name} ${utils.getTagDescription(tag)}`.trim();
|
|
299
|
+
|
|
300
|
+
return validateDescription(desc, report, jsdocNode, abbreviationsRegex, sourceCode, tag, newlineBeforeCapsAssumesBadSentenceEnd);
|
|
301
|
+
});
|
|
302
|
+
}, {
|
|
303
|
+
iterateAllJsdocs: true,
|
|
304
|
+
meta: {
|
|
305
|
+
docs: {
|
|
306
|
+
description: 'Requires that block description, explicit `@description`, and `@param`/`@returns` tag descriptions are written in complete sentences.',
|
|
307
|
+
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-description-complete-sentence.md#repos-sticky-header',
|
|
308
|
+
},
|
|
309
|
+
fixable: 'code',
|
|
310
|
+
schema: [
|
|
311
|
+
{
|
|
312
|
+
additionalProperties: false,
|
|
313
|
+
properties: {
|
|
314
|
+
abbreviations: {
|
|
315
|
+
items: {
|
|
316
|
+
type: 'string',
|
|
317
|
+
},
|
|
318
|
+
type: 'array',
|
|
319
|
+
},
|
|
320
|
+
newlineBeforeCapsAssumesBadSentenceEnd: {
|
|
321
|
+
type: 'boolean',
|
|
322
|
+
},
|
|
323
|
+
tags: {
|
|
324
|
+
items: {
|
|
325
|
+
type: 'string',
|
|
326
|
+
},
|
|
327
|
+
type: 'array',
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
type: 'object',
|
|
331
|
+
},
|
|
332
|
+
],
|
|
333
|
+
type: 'suggestion',
|
|
334
|
+
},
|
|
335
|
+
});
|