eslint-plugin-jsdoc 52.0.4 → 53.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/WarnSettings.cjs +18 -35
- package/dist/WarnSettings.cjs.map +1 -1
- package/dist/WarnSettings.js +20 -0
- package/dist/WarnSettings.js.map +1 -0
- package/dist/_virtual/rolldown_runtime.cjs +32 -0
- package/dist/_virtual/rolldown_runtime.js +11 -0
- package/dist/alignTransform.cjs +224 -305
- package/dist/alignTransform.cjs.map +1 -1
- package/dist/alignTransform.js +241 -0
- package/dist/alignTransform.js.map +1 -0
- package/dist/defaultTagOrder.cjs +132 -43
- package/dist/defaultTagOrder.cjs.map +1 -1
- package/dist/defaultTagOrder.js +134 -0
- package/dist/defaultTagOrder.js.map +1 -0
- package/dist/exportParser.cjs +478 -696
- package/dist/exportParser.cjs.map +1 -1
- package/dist/exportParser.js +518 -0
- package/dist/exportParser.js.map +1 -0
- package/dist/getDefaultTagStructureForMode.cjs +184 -288
- package/dist/getDefaultTagStructureForMode.cjs.map +1 -1
- package/dist/getDefaultTagStructureForMode.js +188 -0
- package/dist/getDefaultTagStructureForMode.js.map +1 -0
- package/dist/getJsdocProcessorPlugin.cjs +364 -550
- package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
- package/dist/getJsdocProcessorPlugin.d.cts +70 -0
- package/dist/getJsdocProcessorPlugin.d.cts.map +1 -0
- package/dist/getJsdocProcessorPlugin.d.ts +68 -65
- package/dist/getJsdocProcessorPlugin.d.ts.map +1 -1
- package/dist/getJsdocProcessorPlugin.js +383 -0
- package/dist/getJsdocProcessorPlugin.js.map +1 -0
- package/dist/index.cjs +2 -410
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -17
- package/dist/index.js +3 -0
- package/dist/iterateJsdoc.cjs +1528 -1988
- package/dist/iterateJsdoc.cjs.map +1 -1
- package/dist/iterateJsdoc.d.cts +471 -0
- package/dist/iterateJsdoc.d.cts.map +1 -0
- package/dist/iterateJsdoc.d.ts +358 -349
- package/dist/iterateJsdoc.d.ts.map +1 -1
- package/dist/iterateJsdoc.js +1617 -0
- package/dist/iterateJsdoc.js.map +1 -0
- package/dist/jsdocUtils.cjs +1009 -1376
- package/dist/jsdocUtils.cjs.map +1 -1
- package/dist/jsdocUtils.js +1123 -0
- package/dist/jsdocUtils.js.map +1 -0
- package/dist/plugin.cjs +427 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.js +427 -0
- package/dist/plugin.js.map +1 -0
- package/dist/rules/checkAccess.cjs +29 -36
- package/dist/rules/checkAccess.cjs.map +1 -1
- package/dist/rules/checkAccess.js +33 -0
- package/dist/rules/checkAccess.js.map +1 -0
- package/dist/rules/checkAlignment.cjs +41 -54
- package/dist/rules/checkAlignment.cjs.map +1 -1
- package/dist/rules/checkAlignment.js +47 -0
- package/dist/rules/checkAlignment.js.map +1 -0
- package/dist/rules/checkExamples.cjs +327 -484
- package/dist/rules/checkExamples.cjs.map +1 -1
- package/dist/rules/checkExamples.js +348 -0
- package/dist/rules/checkExamples.js.map +1 -0
- package/dist/rules/checkIndentation.cjs +50 -65
- package/dist/rules/checkIndentation.cjs.map +1 -1
- package/dist/rules/checkIndentation.js +59 -0
- package/dist/rules/checkIndentation.js.map +1 -0
- package/dist/rules/checkLineAlignment.cjs +220 -311
- package/dist/rules/checkLineAlignment.cjs.map +1 -1
- package/dist/rules/checkLineAlignment.js +229 -0
- package/dist/rules/checkLineAlignment.js.map +1 -0
- package/dist/rules/checkParamNames.cjs +227 -335
- package/dist/rules/checkParamNames.cjs.map +1 -1
- package/dist/rules/checkParamNames.js +237 -0
- package/dist/rules/checkParamNames.js.map +1 -0
- package/dist/rules/checkPropertyNames.cjs +78 -106
- package/dist/rules/checkPropertyNames.cjs.map +1 -1
- package/dist/rules/checkPropertyNames.js +88 -0
- package/dist/rules/checkPropertyNames.js.map +1 -0
- package/dist/rules/checkSyntax.cjs +21 -34
- package/dist/rules/checkSyntax.cjs.map +1 -1
- package/dist/rules/checkSyntax.js +25 -0
- package/dist/rules/checkSyntax.js.map +1 -0
- package/dist/rules/checkTagNames.cjs +188 -210
- package/dist/rules/checkTagNames.cjs.map +1 -1
- package/dist/rules/checkTagNames.js +191 -0
- package/dist/rules/checkTagNames.js.map +1 -0
- package/dist/rules/checkTemplateNames.cjs +121 -178
- package/dist/rules/checkTemplateNames.cjs.map +1 -1
- package/dist/rules/checkTemplateNames.js +124 -0
- package/dist/rules/checkTemplateNames.js.map +1 -0
- package/dist/rules/checkTypes.cjs +291 -385
- package/dist/rules/checkTypes.cjs.map +1 -1
- package/dist/rules/checkTypes.js +299 -0
- package/dist/rules/checkTypes.js.map +1 -0
- package/dist/rules/checkValues.cjs +100 -146
- package/dist/rules/checkValues.cjs.map +1 -1
- package/dist/rules/checkValues.js +103 -0
- package/dist/rules/checkValues.js.map +1 -0
- package/dist/rules/convertToJsdocComments.cjs +228 -306
- package/dist/rules/convertToJsdocComments.cjs.map +1 -1
- package/dist/rules/convertToJsdocComments.js +231 -0
- package/dist/rules/convertToJsdocComments.js.map +1 -0
- package/dist/rules/emptyTags.cjs +62 -72
- package/dist/rules/emptyTags.cjs.map +1 -1
- package/dist/rules/emptyTags.js +67 -0
- package/dist/rules/emptyTags.js.map +1 -0
- package/dist/rules/implementsOnClasses.cjs +36 -56
- package/dist/rules/implementsOnClasses.cjs.map +1 -1
- package/dist/rules/implementsOnClasses.js +40 -0
- package/dist/rules/implementsOnClasses.js.map +1 -0
- package/dist/rules/importsAsDependencies.cjs +62 -99
- package/dist/rules/importsAsDependencies.cjs.map +1 -1
- package/dist/rules/importsAsDependencies.js +68 -0
- package/dist/rules/importsAsDependencies.js.map +1 -0
- package/dist/rules/informativeDocs.cjs +105 -142
- package/dist/rules/informativeDocs.cjs.map +1 -1
- package/dist/rules/informativeDocs.js +110 -0
- package/dist/rules/informativeDocs.js.map +1 -0
- package/dist/rules/linesBeforeBlock.cjs +70 -105
- package/dist/rules/linesBeforeBlock.cjs.map +1 -1
- package/dist/rules/linesBeforeBlock.js +75 -0
- package/dist/rules/linesBeforeBlock.js.map +1 -0
- package/dist/rules/matchDescription.cjs +160 -222
- package/dist/rules/matchDescription.cjs.map +1 -1
- package/dist/rules/matchDescription.js +167 -0
- package/dist/rules/matchDescription.js.map +1 -0
- package/dist/rules/matchName.cjs +73 -128
- package/dist/rules/matchName.cjs.map +1 -1
- package/dist/rules/matchName.js +77 -0
- package/dist/rules/matchName.js.map +1 -0
- package/dist/rules/multilineBlocks.cjs +235 -352
- package/dist/rules/multilineBlocks.cjs.map +1 -1
- package/dist/rules/multilineBlocks.js +245 -0
- package/dist/rules/multilineBlocks.js.map +1 -0
- package/dist/rules/noBadBlocks.cjs +63 -86
- package/dist/rules/noBadBlocks.cjs.map +1 -1
- package/dist/rules/noBadBlocks.js +68 -0
- package/dist/rules/noBadBlocks.js.map +1 -0
- package/dist/rules/noBlankBlockDescriptions.cjs +35 -57
- package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -1
- package/dist/rules/noBlankBlockDescriptions.js +41 -0
- package/dist/rules/noBlankBlockDescriptions.js.map +1 -0
- package/dist/rules/noBlankBlocks.cjs +26 -48
- package/dist/rules/noBlankBlocks.cjs.map +1 -1
- package/dist/rules/noBlankBlocks.js +30 -0
- package/dist/rules/noBlankBlocks.js.map +1 -0
- package/dist/rules/noDefaults.cjs +52 -79
- package/dist/rules/noDefaults.cjs.map +1 -1
- package/dist/rules/noDefaults.js +56 -0
- package/dist/rules/noDefaults.js.map +1 -0
- package/dist/rules/noMissingSyntax.cjs +115 -165
- package/dist/rules/noMissingSyntax.cjs.map +1 -1
- package/dist/rules/noMissingSyntax.js +126 -0
- package/dist/rules/noMissingSyntax.js.map +1 -0
- package/dist/rules/noMultiAsterisks.cjs +48 -89
- package/dist/rules/noMultiAsterisks.cjs.map +1 -1
- package/dist/rules/noMultiAsterisks.js +58 -0
- package/dist/rules/noMultiAsterisks.js.map +1 -0
- package/dist/rules/noRestrictedSyntax.cjs +45 -79
- package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
- package/dist/rules/noRestrictedSyntax.js +49 -0
- package/dist/rules/noRestrictedSyntax.js.map +1 -0
- package/dist/rules/noTypes.cjs +59 -80
- package/dist/rules/noTypes.cjs.map +1 -1
- package/dist/rules/noTypes.js +65 -0
- package/dist/rules/noTypes.js.map +1 -0
- package/dist/rules/noUndefinedTypes.cjs +297 -388
- package/dist/rules/noUndefinedTypes.cjs.map +1 -1
- package/dist/rules/noUndefinedTypes.js +303 -0
- package/dist/rules/noUndefinedTypes.js.map +1 -0
- package/dist/rules/requireAsteriskPrefix.cjs +108 -159
- package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
- package/dist/rules/requireAsteriskPrefix.js +112 -0
- package/dist/rules/requireAsteriskPrefix.js.map +1 -0
- package/dist/rules/requireDescription.cjs +89 -129
- package/dist/rules/requireDescription.cjs.map +1 -1
- package/dist/rules/requireDescription.js +95 -0
- package/dist/rules/requireDescription.js.map +1 -0
- package/dist/rules/requireDescriptionCompleteSentence.cjs +201 -262
- package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
- package/dist/rules/requireDescriptionCompleteSentence.js +220 -0
- package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -0
- package/dist/rules/requireExample.cjs +73 -104
- package/dist/rules/requireExample.cjs.map +1 -1
- package/dist/rules/requireExample.js +77 -0
- package/dist/rules/requireExample.js.map +1 -0
- package/dist/rules/requireFileOverview.cjs +75 -129
- package/dist/rules/requireFileOverview.cjs.map +1 -1
- package/dist/rules/requireFileOverview.js +81 -0
- package/dist/rules/requireFileOverview.js.map +1 -0
- package/dist/rules/requireHyphenBeforeParamDescription.cjs +85 -133
- package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
- package/dist/rules/requireHyphenBeforeParamDescription.js +89 -0
- package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -0
- package/dist/rules/requireJsdoc.cjs +384 -557
- package/dist/rules/requireJsdoc.cjs.map +1 -1
- package/dist/rules/requireJsdoc.js +404 -0
- package/dist/rules/requireJsdoc.js.map +1 -0
- package/dist/rules/requireParam.cjs +336 -526
- package/dist/rules/requireParam.cjs.map +1 -1
- package/dist/rules/requireParam.js +344 -0
- package/dist/rules/requireParam.js.map +1 -0
- package/dist/rules/requireParamDescription.cjs +55 -80
- package/dist/rules/requireParamDescription.cjs.map +1 -1
- package/dist/rules/requireParamDescription.js +59 -0
- package/dist/rules/requireParamDescription.js.map +1 -0
- package/dist/rules/requireParamName.cjs +32 -50
- package/dist/rules/requireParamName.cjs.map +1 -1
- package/dist/rules/requireParamName.js +36 -0
- package/dist/rules/requireParamName.js.map +1 -0
- package/dist/rules/requireParamType.cjs +55 -80
- package/dist/rules/requireParamType.cjs.map +1 -1
- package/dist/rules/requireParamType.js +59 -0
- package/dist/rules/requireParamType.js.map +1 -0
- package/dist/rules/requireProperty.cjs +31 -42
- package/dist/rules/requireProperty.cjs.map +1 -1
- package/dist/rules/requireProperty.js +35 -0
- package/dist/rules/requireProperty.js.map +1 -0
- package/dist/rules/requirePropertyDescription.cjs +17 -25
- package/dist/rules/requirePropertyDescription.cjs.map +1 -1
- package/dist/rules/requirePropertyDescription.js +21 -0
- package/dist/rules/requirePropertyDescription.js.map +1 -0
- package/dist/rules/requirePropertyName.cjs +17 -25
- package/dist/rules/requirePropertyName.cjs.map +1 -1
- package/dist/rules/requirePropertyName.js +21 -0
- package/dist/rules/requirePropertyName.js.map +1 -0
- package/dist/rules/requirePropertyType.cjs +17 -25
- package/dist/rules/requirePropertyType.cjs.map +1 -1
- package/dist/rules/requirePropertyType.js +21 -0
- package/dist/rules/requirePropertyType.js.map +1 -0
- package/dist/rules/requireReturns.cjs +125 -203
- package/dist/rules/requireReturns.cjs.map +1 -1
- package/dist/rules/requireReturns.js +131 -0
- package/dist/rules/requireReturns.js.map +1 -0
- package/dist/rules/requireReturnsCheck.cjs +60 -103
- package/dist/rules/requireReturnsCheck.cjs.map +1 -1
- package/dist/rules/requireReturnsCheck.js +66 -0
- package/dist/rules/requireReturnsCheck.js.map +1 -0
- package/dist/rules/requireReturnsDescription.cjs +39 -54
- package/dist/rules/requireReturnsDescription.cjs.map +1 -1
- package/dist/rules/requireReturnsDescription.js +43 -0
- package/dist/rules/requireReturnsDescription.js.map +1 -0
- package/dist/rules/requireReturnsType.cjs +32 -50
- package/dist/rules/requireReturnsType.cjs.map +1 -1
- package/dist/rules/requireReturnsType.js +36 -0
- package/dist/rules/requireReturnsType.js.map +1 -0
- package/dist/rules/requireTemplate.cjs +119 -178
- package/dist/rules/requireTemplate.cjs.map +1 -1
- package/dist/rules/requireTemplate.js +122 -0
- package/dist/rules/requireTemplate.js.map +1 -0
- package/dist/rules/requireThrows.cjs +61 -95
- package/dist/rules/requireThrows.cjs.map +1 -1
- package/dist/rules/requireThrows.js +67 -0
- package/dist/rules/requireThrows.js.map +1 -0
- package/dist/rules/requireYields.cjs +106 -166
- package/dist/rules/requireYields.cjs.map +1 -1
- package/dist/rules/requireYields.js +115 -0
- package/dist/rules/requireYields.js.map +1 -0
- package/dist/rules/requireYieldsCheck.cjs +96 -152
- package/dist/rules/requireYieldsCheck.cjs.map +1 -1
- package/dist/rules/requireYieldsCheck.js +105 -0
- package/dist/rules/requireYieldsCheck.js.map +1 -0
- package/dist/rules/sortTags.cjs +258 -444
- package/dist/rules/sortTags.cjs.map +1 -1
- package/dist/rules/sortTags.js +262 -0
- package/dist/rules/sortTags.js.map +1 -0
- package/dist/rules/tagLines.cjs +179 -266
- package/dist/rules/tagLines.cjs.map +1 -1
- package/dist/rules/tagLines.js +183 -0
- package/dist/rules/tagLines.js.map +1 -0
- package/dist/rules/textEscaping.cjs +92 -127
- package/dist/rules/textEscaping.cjs.map +1 -1
- package/dist/rules/textEscaping.js +102 -0
- package/dist/rules/textEscaping.js.map +1 -0
- package/dist/rules/validTypes.cjs +252 -265
- package/dist/rules/validTypes.cjs.map +1 -1
- package/dist/rules/validTypes.js +259 -0
- package/dist/rules/validTypes.js.map +1 -0
- package/dist/tagNames.cjs +134 -170
- package/dist/tagNames.cjs.map +1 -1
- package/dist/tagNames.js +144 -0
- package/dist/tagNames.js.map +1 -0
- package/dist/utils/hasReturnValue.cjs +246 -474
- package/dist/utils/hasReturnValue.cjs.map +1 -1
- package/dist/utils/hasReturnValue.js +265 -0
- package/dist/utils/hasReturnValue.js.map +1 -0
- package/package.json +40 -24
- package/dist/generateRule.cjs +0 -242
- package/dist/generateRule.cjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/src/WarnSettings.js +0 -34
- package/src/alignTransform.js +0 -358
- package/src/defaultTagOrder.js +0 -169
- package/src/exportParser.js +0 -978
- package/src/getDefaultTagStructureForMode.js +0 -969
- package/src/getJsdocProcessorPlugin.js +0 -672
- package/src/index.js +0 -530
- package/src/iterateJsdoc.js +0 -2518
- package/src/jsdocUtils.js +0 -1896
- package/src/rules/checkAccess.js +0 -45
- package/src/rules/checkAlignment.js +0 -63
- package/src/rules/checkExamples.js +0 -589
- package/src/rules/checkIndentation.js +0 -75
- package/src/rules/checkLineAlignment.js +0 -372
- package/src/rules/checkParamNames.js +0 -474
- package/src/rules/checkPropertyNames.js +0 -152
- package/src/rules/checkSyntax.js +0 -30
- package/src/rules/checkTagNames.js +0 -314
- package/src/rules/checkTemplateNames.js +0 -204
- package/src/rules/checkTypes.js +0 -535
- package/src/rules/checkValues.js +0 -248
- package/src/rules/convertToJsdocComments.js +0 -398
- package/src/rules/emptyTags.js +0 -98
- package/src/rules/implementsOnClasses.js +0 -64
- package/src/rules/importsAsDependencies.js +0 -133
- package/src/rules/informativeDocs.js +0 -189
- package/src/rules/linesBeforeBlock.js +0 -134
- package/src/rules/matchDescription.js +0 -286
- package/src/rules/matchName.js +0 -151
- package/src/rules/multilineBlocks.js +0 -493
- package/src/rules/noBadBlocks.js +0 -119
- package/src/rules/noBlankBlockDescriptions.js +0 -69
- package/src/rules/noBlankBlocks.js +0 -53
- package/src/rules/noDefaults.js +0 -85
- package/src/rules/noMissingSyntax.js +0 -195
- package/src/rules/noMultiAsterisks.js +0 -134
- package/src/rules/noRestrictedSyntax.js +0 -91
- package/src/rules/noTypes.js +0 -93
- package/src/rules/noUndefinedTypes.js +0 -543
- package/src/rules/requireAsteriskPrefix.js +0 -190
- package/src/rules/requireDescription.js +0 -161
- package/src/rules/requireDescriptionCompleteSentence.js +0 -335
- package/src/rules/requireExample.js +0 -118
- package/src/rules/requireFileOverview.js +0 -154
- package/src/rules/requireHyphenBeforeParamDescription.js +0 -176
- package/src/rules/requireJsdoc.js +0 -743
- package/src/rules/requireParam.js +0 -602
- package/src/rules/requireParamDescription.js +0 -89
- package/src/rules/requireParamName.js +0 -55
- package/src/rules/requireParamType.js +0 -89
- package/src/rules/requireProperty.js +0 -48
- package/src/rules/requirePropertyDescription.js +0 -25
- package/src/rules/requirePropertyName.js +0 -25
- package/src/rules/requirePropertyType.js +0 -25
- package/src/rules/requireReturns.js +0 -238
- package/src/rules/requireReturnsCheck.js +0 -145
- package/src/rules/requireReturnsDescription.js +0 -59
- package/src/rules/requireReturnsType.js +0 -51
- package/src/rules/requireTemplate.js +0 -201
- package/src/rules/requireThrows.js +0 -111
- package/src/rules/requireYields.js +0 -216
- package/src/rules/requireYieldsCheck.js +0 -208
- package/src/rules/sortTags.js +0 -558
- package/src/rules/tagLines.js +0 -359
- package/src/rules/textEscaping.js +0 -154
- package/src/rules/validTypes.js +0 -401
- package/src/tagNames.js +0 -238
- package/src/utils/hasReturnValue.js +0 -572
|
@@ -1,321 +1,230 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _alignTransform = _interopRequireDefault(require("../alignTransform.cjs"));
|
|
8
|
-
var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
|
|
9
|
-
var _commentParser = require("comment-parser");
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
const {
|
|
12
|
-
flow: commentFlow
|
|
13
|
-
} = _commentParser.transforms;
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_iterateJsdoc = require('../iterateJsdoc.cjs');
|
|
3
|
+
const require_alignTransform = require('../alignTransform.cjs');
|
|
4
|
+
const comment_parser = require_rolldown_runtime.__toESM(require("comment-parser"));
|
|
14
5
|
|
|
6
|
+
//#region src/rules/checkLineAlignment.js
|
|
7
|
+
const { flow: commentFlow } = comment_parser.transforms;
|
|
15
8
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
9
|
+
* @typedef {{
|
|
10
|
+
* postDelimiter: import('../iterateJsdoc.js').Integer,
|
|
11
|
+
* postHyphen: import('../iterateJsdoc.js').Integer,
|
|
12
|
+
* postName: import('../iterateJsdoc.js').Integer,
|
|
13
|
+
* postTag: import('../iterateJsdoc.js').Integer,
|
|
14
|
+
* postType: import('../iterateJsdoc.js').Integer,
|
|
15
|
+
* }} CustomSpacings
|
|
16
|
+
*/
|
|
25
17
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
* @param {import('../iterateJsdoc.js').Utils} utils
|
|
19
|
+
* @param {import('comment-parser').Spec & {
|
|
20
|
+
* line: import('../iterateJsdoc.js').Integer
|
|
21
|
+
* }} tag
|
|
22
|
+
* @param {CustomSpacings} customSpacings
|
|
23
|
+
*/
|
|
32
24
|
const checkNotAlignedPerTag = (utils, tag, customSpacings) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const contentProp = contentProps[idx];
|
|
113
|
-
const contentPropVal = tokens[contentProp];
|
|
114
|
-
if (contentPropVal) {
|
|
115
|
-
const spacing = customSpacings?.[spacerProp] || 1;
|
|
116
|
-
tokens[spacerProp] = ''.padStart(spacing, ' ');
|
|
117
|
-
followedBySpace(idx, (hasSpace, contentPrp) => {
|
|
118
|
-
if (hasSpace) {
|
|
119
|
-
tokens[contentPrp] = '';
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
} else {
|
|
123
|
-
tokens[spacerProp] = '';
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (!hasExactHyphenSpacing) {
|
|
127
|
-
const hyphenSpacing = /^\s*-\s+/v;
|
|
128
|
-
tokens.description = tokens.description.replace(hyphenSpacing, '-' + ''.padStart(postHyphenSpacing, ' '));
|
|
129
|
-
}
|
|
130
|
-
utils.setTag(tag, tokens);
|
|
131
|
-
};
|
|
132
|
-
utils.reportJSDoc('Expected JSDoc block lines to not be aligned.', tag, fix, true);
|
|
25
|
+
/**
|
|
26
|
+
* @typedef {"tag"|"type"|"name"|"description"} ContentProp
|
|
27
|
+
*/
|
|
28
|
+
/** @type {("postDelimiter"|"postTag"|"postType"|"postName")[]} */
|
|
29
|
+
let spacerProps;
|
|
30
|
+
/** @type {ContentProp[]} */
|
|
31
|
+
let contentProps;
|
|
32
|
+
const mightHaveNamepath = utils.tagMightHaveNamepath(tag.tag);
|
|
33
|
+
if (mightHaveNamepath) {
|
|
34
|
+
spacerProps = [
|
|
35
|
+
"postDelimiter",
|
|
36
|
+
"postTag",
|
|
37
|
+
"postType",
|
|
38
|
+
"postName"
|
|
39
|
+
];
|
|
40
|
+
contentProps = [
|
|
41
|
+
"tag",
|
|
42
|
+
"type",
|
|
43
|
+
"name",
|
|
44
|
+
"description"
|
|
45
|
+
];
|
|
46
|
+
} else {
|
|
47
|
+
spacerProps = [
|
|
48
|
+
"postDelimiter",
|
|
49
|
+
"postTag",
|
|
50
|
+
"postType"
|
|
51
|
+
];
|
|
52
|
+
contentProps = [
|
|
53
|
+
"tag",
|
|
54
|
+
"type",
|
|
55
|
+
"description"
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
const { tokens } = tag.source[0];
|
|
59
|
+
/**
|
|
60
|
+
* @param {import('../iterateJsdoc.js').Integer} idx
|
|
61
|
+
* @param {(notRet: boolean, contentProp: ContentProp) => void} [callbck]
|
|
62
|
+
*/
|
|
63
|
+
const followedBySpace = (idx, callbck) => {
|
|
64
|
+
const nextIndex = idx + 1;
|
|
65
|
+
return spacerProps.slice(nextIndex).some((spacerProp, innerIdx) => {
|
|
66
|
+
const contentProp = contentProps[nextIndex + innerIdx];
|
|
67
|
+
const spacePropVal = tokens[spacerProp];
|
|
68
|
+
const ret = spacePropVal;
|
|
69
|
+
if (callbck) callbck(!ret, contentProp);
|
|
70
|
+
return ret && (callbck || !contentProp);
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
const postHyphenSpacing = customSpacings?.postHyphen ?? 1;
|
|
74
|
+
const exactHyphenSpacing = new RegExp(`^\\s*-\\s{${postHyphenSpacing},${postHyphenSpacing}}(?!\\s)`, "v");
|
|
75
|
+
const hasNoHyphen = !/^\s*-(?!$)(?=\s)/v.test(tokens.description);
|
|
76
|
+
const hasExactHyphenSpacing = exactHyphenSpacing.test(tokens.description);
|
|
77
|
+
const ok = !spacerProps.some((spacerProp, idx) => {
|
|
78
|
+
const contentProp = contentProps[idx];
|
|
79
|
+
const contentPropVal = tokens[contentProp];
|
|
80
|
+
const spacerPropVal = tokens[spacerProp];
|
|
81
|
+
const spacing = customSpacings?.[spacerProp] || 1;
|
|
82
|
+
return spacerPropVal.length !== spacing && spacerPropVal.length !== 0 || spacerPropVal && !contentPropVal && followedBySpace(idx);
|
|
83
|
+
}) && (hasNoHyphen || hasExactHyphenSpacing);
|
|
84
|
+
if (ok) return;
|
|
85
|
+
const fix = () => {
|
|
86
|
+
for (const [idx, spacerProp] of spacerProps.entries()) {
|
|
87
|
+
const contentProp = contentProps[idx];
|
|
88
|
+
const contentPropVal = tokens[contentProp];
|
|
89
|
+
if (contentPropVal) {
|
|
90
|
+
const spacing = customSpacings?.[spacerProp] || 1;
|
|
91
|
+
tokens[spacerProp] = "".padStart(spacing, " ");
|
|
92
|
+
followedBySpace(idx, (hasSpace, contentPrp) => {
|
|
93
|
+
if (hasSpace) tokens[contentPrp] = "";
|
|
94
|
+
});
|
|
95
|
+
} else tokens[spacerProp] = "";
|
|
96
|
+
}
|
|
97
|
+
if (!hasExactHyphenSpacing) {
|
|
98
|
+
const hyphenSpacing = /^\s*-\s+/v;
|
|
99
|
+
tokens.description = tokens.description.replace(hyphenSpacing, "-" + "".padStart(postHyphenSpacing, " "));
|
|
100
|
+
}
|
|
101
|
+
utils.setTag(tag, tokens);
|
|
102
|
+
};
|
|
103
|
+
utils.reportJSDoc("Expected JSDoc block lines to not be aligned.", tag, fix, true);
|
|
133
104
|
};
|
|
134
|
-
|
|
135
105
|
/**
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const checkAlignment = ({
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}));
|
|
171
|
-
const transformedJsdoc = transform(jsdoc);
|
|
172
|
-
const comment = '/*' +
|
|
173
|
-
/**
|
|
174
|
-
* @type {import('eslint').Rule.Node & {
|
|
175
|
-
* range: [number, number], value: string
|
|
176
|
-
* }}
|
|
177
|
-
*/
|
|
178
|
-
jsdocNode.value + '*/';
|
|
179
|
-
const formatted = utils.stringify(transformedJsdoc).trimStart();
|
|
180
|
-
if (comment !== formatted) {
|
|
181
|
-
report('Expected JSDoc block lines to be aligned.', /** @type {import('eslint').Rule.ReportFixer} */fixer => {
|
|
182
|
-
return fixer.replaceText(jsdocNode, formatted);
|
|
183
|
-
});
|
|
184
|
-
}
|
|
106
|
+
* @param {object} cfg
|
|
107
|
+
* @param {CustomSpacings} cfg.customSpacings
|
|
108
|
+
* @param {string} cfg.indent
|
|
109
|
+
* @param {import('comment-parser').Block} cfg.jsdoc
|
|
110
|
+
* @param {import('eslint').Rule.Node & {
|
|
111
|
+
* range: [number, number]
|
|
112
|
+
* }} cfg.jsdocNode
|
|
113
|
+
* @param {boolean} cfg.preserveMainDescriptionPostDelimiter
|
|
114
|
+
* @param {import('../iterateJsdoc.js').Report} cfg.report
|
|
115
|
+
* @param {string[]} cfg.tags
|
|
116
|
+
* @param {import('../iterateJsdoc.js').Utils} cfg.utils
|
|
117
|
+
* @param {string} cfg.wrapIndent
|
|
118
|
+
* @param {boolean} cfg.disableWrapIndent
|
|
119
|
+
* @returns {void}
|
|
120
|
+
*/
|
|
121
|
+
const checkAlignment = ({ customSpacings, disableWrapIndent, indent, jsdoc, jsdocNode, preserveMainDescriptionPostDelimiter, report, tags, utils, wrapIndent }) => {
|
|
122
|
+
const transform = commentFlow(require_alignTransform.default({
|
|
123
|
+
customSpacings,
|
|
124
|
+
disableWrapIndent,
|
|
125
|
+
indent,
|
|
126
|
+
preserveMainDescriptionPostDelimiter,
|
|
127
|
+
tags,
|
|
128
|
+
wrapIndent
|
|
129
|
+
}));
|
|
130
|
+
const transformedJsdoc = transform(jsdoc);
|
|
131
|
+
const comment = "/*" + jsdocNode.value + "*/";
|
|
132
|
+
const formatted = utils.stringify(transformedJsdoc).trimStart();
|
|
133
|
+
if (comment !== formatted) report(
|
|
134
|
+
"Expected JSDoc block lines to be aligned.",
|
|
135
|
+
/** @type {import('eslint').Rule.ReportFixer} */
|
|
136
|
+
(fixer) => {
|
|
137
|
+
return fixer.replaceText(jsdocNode, formatted);
|
|
138
|
+
}
|
|
139
|
+
);
|
|
185
140
|
};
|
|
186
|
-
var
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
for (const tag of foundTags) {
|
|
229
|
-
checkNotAlignedPerTag(utils,
|
|
230
|
-
/**
|
|
231
|
-
* @type {import('comment-parser').Spec & {
|
|
232
|
-
* line: import('../iterateJsdoc.js').Integer
|
|
233
|
-
* }}
|
|
234
|
-
*/
|
|
235
|
-
tag, customSpacings);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
for (const tag of foundTags) {
|
|
239
|
-
if (tag.source.length > 1) {
|
|
240
|
-
let idx = 0;
|
|
241
|
-
for (const {
|
|
242
|
-
tokens
|
|
243
|
-
// Avoid the tag line
|
|
244
|
-
} of tag.source.slice(1)) {
|
|
245
|
-
idx++;
|
|
246
|
-
if (!tokens.description ||
|
|
247
|
-
// Avoid first lines after multiline type
|
|
248
|
-
tokens.type || tokens.name) {
|
|
249
|
-
continue;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// Don't include a single separating space/tab
|
|
253
|
-
if (!disableWrapIndent && tokens.postDelimiter.slice(1) !== wrapIndent) {
|
|
254
|
-
utils.reportJSDoc('Expected wrap indent', {
|
|
255
|
-
line: tag.source[0].number + idx
|
|
256
|
-
}, () => {
|
|
257
|
-
tokens.postDelimiter = tokens.postDelimiter.charAt(0) + wrapIndent;
|
|
258
|
-
});
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
141
|
+
var checkLineAlignment_default = require_iterateJsdoc.default(({ context, indent, jsdoc, jsdocNode, report, utils }) => {
|
|
142
|
+
const { customSpacings, disableWrapIndent = false, preserveMainDescriptionPostDelimiter, tags: applicableTags = [
|
|
143
|
+
"param",
|
|
144
|
+
"arg",
|
|
145
|
+
"argument",
|
|
146
|
+
"property",
|
|
147
|
+
"prop",
|
|
148
|
+
"returns",
|
|
149
|
+
"return",
|
|
150
|
+
"template"
|
|
151
|
+
], wrapIndent = "" } = context.options[1] || {};
|
|
152
|
+
if (context.options[0] === "always") {
|
|
153
|
+
if (!jsdocNode.value.includes("\n")) return;
|
|
154
|
+
checkAlignment({
|
|
155
|
+
customSpacings,
|
|
156
|
+
disableWrapIndent,
|
|
157
|
+
indent,
|
|
158
|
+
jsdoc,
|
|
159
|
+
jsdocNode,
|
|
160
|
+
preserveMainDescriptionPostDelimiter,
|
|
161
|
+
report,
|
|
162
|
+
tags: applicableTags,
|
|
163
|
+
utils,
|
|
164
|
+
wrapIndent
|
|
165
|
+
});
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const foundTags = utils.getPresentTags(applicableTags);
|
|
169
|
+
if (context.options[0] !== "any") for (const tag of foundTags) checkNotAlignedPerTag(utils, tag, customSpacings);
|
|
170
|
+
for (const tag of foundTags) if (tag.source.length > 1) {
|
|
171
|
+
let idx = 0;
|
|
172
|
+
for (const { tokens } of tag.source.slice(1)) {
|
|
173
|
+
idx++;
|
|
174
|
+
if (!tokens.description || tokens.type || tokens.name) continue;
|
|
175
|
+
if (!disableWrapIndent && tokens.postDelimiter.slice(1) !== wrapIndent) {
|
|
176
|
+
utils.reportJSDoc("Expected wrap indent", { line: tag.source[0].number + idx }, () => {
|
|
177
|
+
tokens.postDelimiter = tokens.postDelimiter.charAt(0) + wrapIndent;
|
|
178
|
+
});
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
264
183
|
}, {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
type: 'string'
|
|
308
|
-
},
|
|
309
|
-
type: 'array'
|
|
310
|
-
},
|
|
311
|
-
wrapIndent: {
|
|
312
|
-
type: 'string'
|
|
313
|
-
}
|
|
314
|
-
},
|
|
315
|
-
type: 'object'
|
|
316
|
-
}],
|
|
317
|
-
type: 'layout'
|
|
318
|
-
}
|
|
184
|
+
iterateAllJsdocs: true,
|
|
185
|
+
meta: {
|
|
186
|
+
docs: {
|
|
187
|
+
description: "Reports invalid alignment of JSDoc block lines.",
|
|
188
|
+
url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-line-alignment.md#repos-sticky-header"
|
|
189
|
+
},
|
|
190
|
+
fixable: "whitespace",
|
|
191
|
+
schema: [{
|
|
192
|
+
enum: [
|
|
193
|
+
"always",
|
|
194
|
+
"never",
|
|
195
|
+
"any"
|
|
196
|
+
],
|
|
197
|
+
type: "string"
|
|
198
|
+
}, {
|
|
199
|
+
additionalProperties: false,
|
|
200
|
+
properties: {
|
|
201
|
+
customSpacings: {
|
|
202
|
+
additionalProperties: false,
|
|
203
|
+
properties: {
|
|
204
|
+
postDelimiter: { type: "integer" },
|
|
205
|
+
postHyphen: { type: "integer" },
|
|
206
|
+
postName: { type: "integer" },
|
|
207
|
+
postTag: { type: "integer" },
|
|
208
|
+
postType: { type: "integer" }
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
disableWrapIndent: { type: "boolean" },
|
|
212
|
+
preserveMainDescriptionPostDelimiter: {
|
|
213
|
+
default: false,
|
|
214
|
+
type: "boolean"
|
|
215
|
+
},
|
|
216
|
+
tags: {
|
|
217
|
+
items: { type: "string" },
|
|
218
|
+
type: "array"
|
|
219
|
+
},
|
|
220
|
+
wrapIndent: { type: "string" }
|
|
221
|
+
},
|
|
222
|
+
type: "object"
|
|
223
|
+
}],
|
|
224
|
+
type: "layout"
|
|
225
|
+
}
|
|
319
226
|
});
|
|
320
|
-
|
|
227
|
+
|
|
228
|
+
//#endregion
|
|
229
|
+
exports.default = checkLineAlignment_default;
|
|
321
230
|
//# sourceMappingURL=checkLineAlignment.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkLineAlignment.cjs","names":["_alignTransform","_interopRequireDefault","require","_iterateJsdoc","_commentParser","e","__esModule","default","flow","commentFlow","transforms","checkNotAlignedPerTag","utils","tag","customSpacings","spacerProps","contentProps","mightHaveNamepath","tagMightHaveNamepath","tokens","source","followedBySpace","idx","callbck","nextIndex","slice","some","spacerProp","innerIdx","contentProp","spacePropVal","ret","postHyphenSpacing","postHyphen","exactHyphenSpacing","RegExp","hasNoHyphen","test","description","hasExactHyphenSpacing","ok","contentPropVal","spacerPropVal","spacing","length","fix","entries","padStart","hasSpace","contentPrp","hyphenSpacing","replace","setTag","reportJSDoc","checkAlignment","disableWrapIndent","indent","jsdoc","jsdocNode","preserveMainDescriptionPostDelimiter","report","tags","wrapIndent","transform","alignTransform","transformedJsdoc","comment","value","formatted","stringify","trimStart","fixer","replaceText","_default","exports","iterateJsdoc","context","applicableTags","options","includes","foundTags","getPresentTags","type","name","postDelimiter","line","number","charAt","iterateAllJsdocs","meta","docs","url","fixable","schema","enum","additionalProperties","properties","postName","postTag","postType","items","module"],"sources":["../../src/rules/checkLineAlignment.js"],"sourcesContent":["import alignTransform from '../alignTransform.js';\nimport iterateJsdoc from '../iterateJsdoc.js';\nimport {\n transforms,\n} from 'comment-parser';\n\nconst {\n flow: commentFlow,\n} = transforms;\n\n/**\n * @typedef {{\n * postDelimiter: import('../iterateJsdoc.js').Integer,\n * postHyphen: import('../iterateJsdoc.js').Integer,\n * postName: import('../iterateJsdoc.js').Integer,\n * postTag: import('../iterateJsdoc.js').Integer,\n * postType: import('../iterateJsdoc.js').Integer,\n * }} CustomSpacings\n */\n\n/**\n * @param {import('../iterateJsdoc.js').Utils} utils\n * @param {import('comment-parser').Spec & {\n * line: import('../iterateJsdoc.js').Integer\n * }} tag\n * @param {CustomSpacings} customSpacings\n */\nconst checkNotAlignedPerTag = (utils, tag, customSpacings) => {\n /*\n start +\n delimiter +\n postDelimiter +\n tag +\n postTag +\n type +\n postType +\n name +\n postName +\n description +\n end +\n lineEnd\n */\n\n /**\n * @typedef {\"tag\"|\"type\"|\"name\"|\"description\"} ContentProp\n */\n\n /** @type {(\"postDelimiter\"|\"postTag\"|\"postType\"|\"postName\")[]} */\n let spacerProps;\n /** @type {ContentProp[]} */\n let contentProps;\n const mightHaveNamepath = utils.tagMightHaveNamepath(tag.tag);\n if (mightHaveNamepath) {\n spacerProps = [\n 'postDelimiter', 'postTag', 'postType', 'postName',\n ];\n contentProps = [\n 'tag', 'type', 'name', 'description',\n ];\n } else {\n spacerProps = [\n 'postDelimiter', 'postTag', 'postType',\n ];\n contentProps = [\n 'tag', 'type', 'description',\n ];\n }\n\n const {\n tokens,\n } = tag.source[0];\n\n /**\n * @param {import('../iterateJsdoc.js').Integer} idx\n * @param {(notRet: boolean, contentProp: ContentProp) => void} [callbck]\n */\n const followedBySpace = (idx, callbck) => {\n const nextIndex = idx + 1;\n\n return spacerProps.slice(nextIndex).some((spacerProp, innerIdx) => {\n const contentProp = contentProps[nextIndex + innerIdx];\n\n const spacePropVal = tokens[spacerProp];\n\n const ret = spacePropVal;\n\n if (callbck) {\n callbck(!ret, contentProp);\n }\n\n return ret && (callbck || !contentProp);\n });\n };\n\n const postHyphenSpacing = customSpacings?.postHyphen ?? 1;\n const exactHyphenSpacing = new RegExp(`^\\\\s*-\\\\s{${postHyphenSpacing},${postHyphenSpacing}}(?!\\\\s)`, 'v');\n const hasNoHyphen = !(/^\\s*-(?!$)(?=\\s)/v).test(tokens.description);\n const hasExactHyphenSpacing = exactHyphenSpacing.test(\n tokens.description,\n );\n\n // If checking alignment on multiple lines, need to check other `source`\n // items\n // Go through `post*` spacing properties and exit to indicate problem if\n // extra spacing detected\n const ok = !spacerProps.some((spacerProp, idx) => {\n const contentProp = contentProps[idx];\n const contentPropVal = tokens[contentProp];\n const spacerPropVal = tokens[spacerProp];\n const spacing = customSpacings?.[spacerProp] || 1;\n\n // There will be extra alignment if...\n\n // 1. The spaces don't match the space it should have (1 or custom spacing) OR\n return spacerPropVal.length !== spacing && spacerPropVal.length !== 0 ||\n\n // 2. There is a (single) space, no immediate content, and yet another\n // space is found subsequently (not separated by intervening content)\n spacerPropVal && !contentPropVal && followedBySpace(idx);\n }) && (hasNoHyphen || hasExactHyphenSpacing);\n if (ok) {\n return;\n }\n\n const fix = () => {\n for (const [\n idx,\n spacerProp,\n ] of spacerProps.entries()) {\n const contentProp = contentProps[idx];\n const contentPropVal = tokens[contentProp];\n\n if (contentPropVal) {\n const spacing = customSpacings?.[spacerProp] || 1;\n tokens[spacerProp] = ''.padStart(spacing, ' ');\n followedBySpace(idx, (hasSpace, contentPrp) => {\n if (hasSpace) {\n tokens[contentPrp] = '';\n }\n });\n } else {\n tokens[spacerProp] = '';\n }\n }\n\n if (!hasExactHyphenSpacing) {\n const hyphenSpacing = /^\\s*-\\s+/v;\n tokens.description = tokens.description.replace(\n hyphenSpacing, '-' + ''.padStart(postHyphenSpacing, ' '),\n );\n }\n\n utils.setTag(tag, tokens);\n };\n\n utils.reportJSDoc('Expected JSDoc block lines to not be aligned.', tag, fix, true);\n};\n\n/**\n * @param {object} cfg\n * @param {CustomSpacings} cfg.customSpacings\n * @param {string} cfg.indent\n * @param {import('comment-parser').Block} cfg.jsdoc\n * @param {import('eslint').Rule.Node & {\n * range: [number, number]\n * }} cfg.jsdocNode\n * @param {boolean} cfg.preserveMainDescriptionPostDelimiter\n * @param {import('../iterateJsdoc.js').Report} cfg.report\n * @param {string[]} cfg.tags\n * @param {import('../iterateJsdoc.js').Utils} cfg.utils\n * @param {string} cfg.wrapIndent\n * @param {boolean} cfg.disableWrapIndent\n * @returns {void}\n */\nconst checkAlignment = ({\n customSpacings,\n disableWrapIndent,\n indent,\n jsdoc,\n jsdocNode,\n preserveMainDescriptionPostDelimiter,\n report,\n tags,\n utils,\n wrapIndent,\n}) => {\n const transform = commentFlow(\n alignTransform({\n customSpacings,\n disableWrapIndent,\n indent,\n preserveMainDescriptionPostDelimiter,\n tags,\n wrapIndent,\n }),\n );\n const transformedJsdoc = transform(jsdoc);\n\n const comment = '/*' +\n /**\n * @type {import('eslint').Rule.Node & {\n * range: [number, number], value: string\n * }}\n */ (jsdocNode).value + '*/';\n\n const formatted = utils.stringify(transformedJsdoc)\n .trimStart();\n\n if (comment !== formatted) {\n report(\n 'Expected JSDoc block lines to be aligned.',\n /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {\n return fixer.replaceText(jsdocNode, formatted);\n },\n );\n }\n};\n\nexport default iterateJsdoc(({\n context,\n indent,\n jsdoc,\n jsdocNode,\n report,\n utils,\n}) => {\n const {\n customSpacings,\n disableWrapIndent = false,\n preserveMainDescriptionPostDelimiter,\n tags: applicableTags = [\n 'param', 'arg', 'argument', 'property', 'prop', 'returns', 'return', 'template',\n ],\n wrapIndent = '',\n } = context.options[1] || {};\n\n if (context.options[0] === 'always') {\n // Skip if it contains only a single line.\n if (!(\n /**\n * @type {import('eslint').Rule.Node & {\n * range: [number, number], value: string\n * }}\n */\n (jsdocNode).value.includes('\\n')\n )) {\n return;\n }\n\n checkAlignment({\n customSpacings,\n disableWrapIndent,\n indent,\n jsdoc,\n jsdocNode,\n preserveMainDescriptionPostDelimiter,\n report,\n tags: applicableTags,\n utils,\n wrapIndent,\n });\n\n return;\n }\n\n const foundTags = utils.getPresentTags(applicableTags);\n if (context.options[0] !== 'any') {\n for (const tag of foundTags) {\n checkNotAlignedPerTag(\n utils,\n /**\n * @type {import('comment-parser').Spec & {\n * line: import('../iterateJsdoc.js').Integer\n * }}\n */\n (tag),\n customSpacings,\n );\n }\n }\n\n for (const tag of foundTags) {\n if (tag.source.length > 1) {\n let idx = 0;\n for (const {\n tokens,\n // Avoid the tag line\n } of tag.source.slice(1)) {\n idx++;\n\n if (\n !tokens.description ||\n // Avoid first lines after multiline type\n tokens.type ||\n tokens.name\n ) {\n continue;\n }\n\n // Don't include a single separating space/tab\n if (!disableWrapIndent && tokens.postDelimiter.slice(1) !== wrapIndent) {\n utils.reportJSDoc('Expected wrap indent', {\n line: tag.source[0].number + idx,\n }, () => {\n tokens.postDelimiter = tokens.postDelimiter.charAt(0) + wrapIndent;\n });\n return;\n }\n }\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Reports invalid alignment of JSDoc block lines.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-line-alignment.md#repos-sticky-header',\n },\n fixable: 'whitespace',\n schema: [\n {\n enum: [\n 'always', 'never', 'any',\n ],\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n customSpacings: {\n additionalProperties: false,\n properties: {\n postDelimiter: {\n type: 'integer',\n },\n postHyphen: {\n type: 'integer',\n },\n postName: {\n type: 'integer',\n },\n postTag: {\n type: 'integer',\n },\n postType: {\n type: 'integer',\n },\n },\n },\n disableWrapIndent: {\n type: 'boolean',\n },\n preserveMainDescriptionPostDelimiter: {\n default: false,\n type: 'boolean',\n },\n tags: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n wrapIndent: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;A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QACF;MACF;IACF;EACF;AACF,CAAC,EAAE;EACD0B,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJpD,WAAW,EAAE,iDAAiD;MAC9DqD,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,YAAY;IACrBC,MAAM,EAAE,CACN;MACEC,IAAI,EAAE,CACJ,QAAQ,EAAE,OAAO,EAAE,KAAK,CACzB;MACDZ,IAAI,EAAE;IACR,CAAC,EACD;MACEa,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVlF,cAAc,EAAE;UACdiF,oBAAoB,EAAE,KAAK;UAC3BC,UAAU,EAAE;YACVZ,aAAa,EAAE;cACbF,IAAI,EAAE;YACR,CAAC;YACDjD,UAAU,EAAE;cACViD,IAAI,EAAE;YACR,CAAC;YACDe,QAAQ,EAAE;cACRf,IAAI,EAAE;YACR,CAAC;YACDgB,OAAO,EAAE;cACPhB,IAAI,EAAE;YACR,CAAC;YACDiB,QAAQ,EAAE;cACRjB,IAAI,EAAE;YACR;UACF;QACF,CAAC;QACD3B,iBAAiB,EAAE;UACjB2B,IAAI,EAAE;QACR,CAAC;QACDvB,oCAAoC,EAAE;UACpCpD,OAAO,EAAE,KAAK;UACd2E,IAAI,EAAE;QACR,CAAC;QACDrB,IAAI,EAAE;UACJuC,KAAK,EAAE;YACLlB,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDpB,UAAU,EAAE;UACVoB,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAmB,MAAA,CAAA3B,OAAA,GAAAA,OAAA,CAAAnE,OAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"checkLineAlignment.cjs","names":["transforms","alignTransform","iterateJsdoc"],"sources":["../../src/rules/checkLineAlignment.js"],"sourcesContent":["import alignTransform from '../alignTransform.js';\nimport iterateJsdoc from '../iterateJsdoc.js';\nimport {\n transforms,\n} from 'comment-parser';\n\nconst {\n flow: commentFlow,\n} = transforms;\n\n/**\n * @typedef {{\n * postDelimiter: import('../iterateJsdoc.js').Integer,\n * postHyphen: import('../iterateJsdoc.js').Integer,\n * postName: import('../iterateJsdoc.js').Integer,\n * postTag: import('../iterateJsdoc.js').Integer,\n * postType: import('../iterateJsdoc.js').Integer,\n * }} CustomSpacings\n */\n\n/**\n * @param {import('../iterateJsdoc.js').Utils} utils\n * @param {import('comment-parser').Spec & {\n * line: import('../iterateJsdoc.js').Integer\n * }} tag\n * @param {CustomSpacings} customSpacings\n */\nconst checkNotAlignedPerTag = (utils, tag, customSpacings) => {\n /*\n start +\n delimiter +\n postDelimiter +\n tag +\n postTag +\n type +\n postType +\n name +\n postName +\n description +\n end +\n lineEnd\n */\n\n /**\n * @typedef {\"tag\"|\"type\"|\"name\"|\"description\"} ContentProp\n */\n\n /** @type {(\"postDelimiter\"|\"postTag\"|\"postType\"|\"postName\")[]} */\n let spacerProps;\n /** @type {ContentProp[]} */\n let contentProps;\n const mightHaveNamepath = utils.tagMightHaveNamepath(tag.tag);\n if (mightHaveNamepath) {\n spacerProps = [\n 'postDelimiter', 'postTag', 'postType', 'postName',\n ];\n contentProps = [\n 'tag', 'type', 'name', 'description',\n ];\n } else {\n spacerProps = [\n 'postDelimiter', 'postTag', 'postType',\n ];\n contentProps = [\n 'tag', 'type', 'description',\n ];\n }\n\n const {\n tokens,\n } = tag.source[0];\n\n /**\n * @param {import('../iterateJsdoc.js').Integer} idx\n * @param {(notRet: boolean, contentProp: ContentProp) => void} [callbck]\n */\n const followedBySpace = (idx, callbck) => {\n const nextIndex = idx + 1;\n\n return spacerProps.slice(nextIndex).some((spacerProp, innerIdx) => {\n const contentProp = contentProps[nextIndex + innerIdx];\n\n const spacePropVal = tokens[spacerProp];\n\n const ret = spacePropVal;\n\n if (callbck) {\n callbck(!ret, contentProp);\n }\n\n return ret && (callbck || !contentProp);\n });\n };\n\n const postHyphenSpacing = customSpacings?.postHyphen ?? 1;\n const exactHyphenSpacing = new RegExp(`^\\\\s*-\\\\s{${postHyphenSpacing},${postHyphenSpacing}}(?!\\\\s)`, 'v');\n const hasNoHyphen = !(/^\\s*-(?!$)(?=\\s)/v).test(tokens.description);\n const hasExactHyphenSpacing = exactHyphenSpacing.test(\n tokens.description,\n );\n\n // If checking alignment on multiple lines, need to check other `source`\n // items\n // Go through `post*` spacing properties and exit to indicate problem if\n // extra spacing detected\n const ok = !spacerProps.some((spacerProp, idx) => {\n const contentProp = contentProps[idx];\n const contentPropVal = tokens[contentProp];\n const spacerPropVal = tokens[spacerProp];\n const spacing = customSpacings?.[spacerProp] || 1;\n\n // There will be extra alignment if...\n\n // 1. The spaces don't match the space it should have (1 or custom spacing) OR\n return spacerPropVal.length !== spacing && spacerPropVal.length !== 0 ||\n\n // 2. There is a (single) space, no immediate content, and yet another\n // space is found subsequently (not separated by intervening content)\n spacerPropVal && !contentPropVal && followedBySpace(idx);\n }) && (hasNoHyphen || hasExactHyphenSpacing);\n if (ok) {\n return;\n }\n\n const fix = () => {\n for (const [\n idx,\n spacerProp,\n ] of spacerProps.entries()) {\n const contentProp = contentProps[idx];\n const contentPropVal = tokens[contentProp];\n\n if (contentPropVal) {\n const spacing = customSpacings?.[spacerProp] || 1;\n tokens[spacerProp] = ''.padStart(spacing, ' ');\n followedBySpace(idx, (hasSpace, contentPrp) => {\n if (hasSpace) {\n tokens[contentPrp] = '';\n }\n });\n } else {\n tokens[spacerProp] = '';\n }\n }\n\n if (!hasExactHyphenSpacing) {\n const hyphenSpacing = /^\\s*-\\s+/v;\n tokens.description = tokens.description.replace(\n hyphenSpacing, '-' + ''.padStart(postHyphenSpacing, ' '),\n );\n }\n\n utils.setTag(tag, tokens);\n };\n\n utils.reportJSDoc('Expected JSDoc block lines to not be aligned.', tag, fix, true);\n};\n\n/**\n * @param {object} cfg\n * @param {CustomSpacings} cfg.customSpacings\n * @param {string} cfg.indent\n * @param {import('comment-parser').Block} cfg.jsdoc\n * @param {import('eslint').Rule.Node & {\n * range: [number, number]\n * }} cfg.jsdocNode\n * @param {boolean} cfg.preserveMainDescriptionPostDelimiter\n * @param {import('../iterateJsdoc.js').Report} cfg.report\n * @param {string[]} cfg.tags\n * @param {import('../iterateJsdoc.js').Utils} cfg.utils\n * @param {string} cfg.wrapIndent\n * @param {boolean} cfg.disableWrapIndent\n * @returns {void}\n */\nconst checkAlignment = ({\n customSpacings,\n disableWrapIndent,\n indent,\n jsdoc,\n jsdocNode,\n preserveMainDescriptionPostDelimiter,\n report,\n tags,\n utils,\n wrapIndent,\n}) => {\n const transform = commentFlow(\n alignTransform({\n customSpacings,\n disableWrapIndent,\n indent,\n preserveMainDescriptionPostDelimiter,\n tags,\n wrapIndent,\n }),\n );\n const transformedJsdoc = transform(jsdoc);\n\n const comment = '/*' +\n /**\n * @type {import('eslint').Rule.Node & {\n * range: [number, number], value: string\n * }}\n */ (jsdocNode).value + '*/';\n\n const formatted = utils.stringify(transformedJsdoc)\n .trimStart();\n\n if (comment !== formatted) {\n report(\n 'Expected JSDoc block lines to be aligned.',\n /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {\n return fixer.replaceText(jsdocNode, formatted);\n },\n );\n }\n};\n\nexport default iterateJsdoc(({\n context,\n indent,\n jsdoc,\n jsdocNode,\n report,\n utils,\n}) => {\n const {\n customSpacings,\n disableWrapIndent = false,\n preserveMainDescriptionPostDelimiter,\n tags: applicableTags = [\n 'param', 'arg', 'argument', 'property', 'prop', 'returns', 'return', 'template',\n ],\n wrapIndent = '',\n } = context.options[1] || {};\n\n if (context.options[0] === 'always') {\n // Skip if it contains only a single line.\n if (!(\n /**\n * @type {import('eslint').Rule.Node & {\n * range: [number, number], value: string\n * }}\n */\n (jsdocNode).value.includes('\\n')\n )) {\n return;\n }\n\n checkAlignment({\n customSpacings,\n disableWrapIndent,\n indent,\n jsdoc,\n jsdocNode,\n preserveMainDescriptionPostDelimiter,\n report,\n tags: applicableTags,\n utils,\n wrapIndent,\n });\n\n return;\n }\n\n const foundTags = utils.getPresentTags(applicableTags);\n if (context.options[0] !== 'any') {\n for (const tag of foundTags) {\n checkNotAlignedPerTag(\n utils,\n /**\n * @type {import('comment-parser').Spec & {\n * line: import('../iterateJsdoc.js').Integer\n * }}\n */\n (tag),\n customSpacings,\n );\n }\n }\n\n for (const tag of foundTags) {\n if (tag.source.length > 1) {\n let idx = 0;\n for (const {\n tokens,\n // Avoid the tag line\n } of tag.source.slice(1)) {\n idx++;\n\n if (\n !tokens.description ||\n // Avoid first lines after multiline type\n tokens.type ||\n tokens.name\n ) {\n continue;\n }\n\n // Don't include a single separating space/tab\n if (!disableWrapIndent && tokens.postDelimiter.slice(1) !== wrapIndent) {\n utils.reportJSDoc('Expected wrap indent', {\n line: tag.source[0].number + idx,\n }, () => {\n tokens.postDelimiter = tokens.postDelimiter.charAt(0) + wrapIndent;\n });\n return;\n }\n }\n }\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Reports invalid alignment of JSDoc block lines.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-line-alignment.md#repos-sticky-header',\n },\n fixable: 'whitespace',\n schema: [\n {\n enum: [\n 'always', 'never', 'any',\n ],\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n customSpacings: {\n additionalProperties: false,\n properties: {\n postDelimiter: {\n type: 'integer',\n },\n postHyphen: {\n type: 'integer',\n },\n postName: {\n type: 'integer',\n },\n postTag: {\n type: 'integer',\n },\n postType: {\n type: 'integer',\n },\n },\n },\n disableWrapIndent: {\n type: 'boolean',\n },\n preserveMainDescriptionPostDelimiter: {\n default: false,\n type: 'boolean',\n },\n tags: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n wrapIndent: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n type: 'layout',\n },\n});\n"],"mappings":";;;;;;AAMA,MAAM,EACJ,MAAM,aACP,GAAGA;;;;;;;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