eslint-plugin-jsdoc 63.3.2 → 64.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/index.d.ts +7 -4
- package/package.json +27 -52
- package/src/index.js +7 -8
- package/dist/WarnSettings.cjs +0 -38
- package/dist/WarnSettings.cjs.map +0 -1
- package/dist/alignTransform.cjs +0 -402
- package/dist/alignTransform.cjs.map +0 -1
- package/dist/buildForbidRuleDefinition.cjs +0 -101
- package/dist/buildForbidRuleDefinition.cjs.map +0 -1
- package/dist/buildRejectOrPreferRuleDefinition.cjs +0 -352
- package/dist/buildRejectOrPreferRuleDefinition.cjs.map +0 -1
- package/dist/cjs/WarnSettings.d.ts +0 -16
- package/dist/cjs/alignTransform.d.ts +0 -33
- package/dist/cjs/buildForbidRuleDefinition.d.ts +0 -14
- package/dist/cjs/buildRejectOrPreferRuleDefinition.d.ts +0 -8
- package/dist/cjs/defaultTagOrder.d.ts +0 -4
- package/dist/cjs/exportParser.d.ts +0 -40
- package/dist/cjs/getDefaultTagStructureForMode.d.ts +0 -10
- package/dist/cjs/getJsdocProcessorPlugin.d.cts +0 -5
- package/dist/cjs/getJsdocProcessorPlugin.d.ts +0 -66
- package/dist/cjs/index-cjs.d.ts +0 -23
- package/dist/cjs/index.cjs.d.cts +0 -2
- package/dist/cjs/iterateJsdoc.d.cts +0 -7
- package/dist/cjs/iterateJsdoc.d.ts +0 -495
- package/dist/cjs/jsdocUtils.d.ts +0 -500
- package/dist/cjs/rules/checkAccess.d.ts +0 -2
- package/dist/cjs/rules/checkAlignment.d.ts +0 -2
- package/dist/cjs/rules/checkExamples.d.ts +0 -3
- package/dist/cjs/rules/checkIndentation.d.ts +0 -2
- package/dist/cjs/rules/checkLineAlignment.d.ts +0 -9
- package/dist/cjs/rules/checkParamNames.d.ts +0 -2
- package/dist/cjs/rules/checkPropertyNames.d.ts +0 -2
- package/dist/cjs/rules/checkSyntax.d.ts +0 -2
- package/dist/cjs/rules/checkTagNames.d.ts +0 -2
- package/dist/cjs/rules/checkTemplateNames.d.ts +0 -2
- package/dist/cjs/rules/checkTypes.d.ts +0 -7
- package/dist/cjs/rules/checkValues.d.ts +0 -2
- package/dist/cjs/rules/convertToJsdocComments.d.ts +0 -266
- package/dist/cjs/rules/emptyTags.d.ts +0 -2
- package/dist/cjs/rules/escapeInlineTags.d.ts +0 -2
- package/dist/cjs/rules/implementsOnClasses.d.ts +0 -2
- package/dist/cjs/rules/importsAsDependencies.d.ts +0 -2
- package/dist/cjs/rules/informativeDocs.d.ts +0 -2
- package/dist/cjs/rules/linesBeforeBlock.d.ts +0 -2
- package/dist/cjs/rules/matchDescription.d.ts +0 -2
- package/dist/cjs/rules/matchName.d.ts +0 -2
- package/dist/cjs/rules/multilineBlocks.d.ts +0 -2
- package/dist/cjs/rules/noBadBlocks.d.ts +0 -2
- package/dist/cjs/rules/noBlankBlockDescriptions.d.ts +0 -2
- package/dist/cjs/rules/noBlankBlocks.d.ts +0 -2
- package/dist/cjs/rules/noDefaults.d.ts +0 -2
- package/dist/cjs/rules/noMissingSyntax.d.ts +0 -9
- package/dist/cjs/rules/noMultiAsterisks.d.ts +0 -2
- package/dist/cjs/rules/noRestrictedSyntax.d.ts +0 -2
- package/dist/cjs/rules/noTypes.d.ts +0 -2
- package/dist/cjs/rules/noUndefinedTypes.d.ts +0 -2
- package/dist/cjs/rules/normalizeSeeLinks.d.ts +0 -2
- package/dist/cjs/rules/preferImportTag.d.ts +0 -2
- package/dist/cjs/rules/requireAsteriskPrefix.d.ts +0 -2
- package/dist/cjs/rules/requireDescription.d.ts +0 -2
- package/dist/cjs/rules/requireDescriptionCompleteSentence.d.ts +0 -2
- package/dist/cjs/rules/requireExample.d.ts +0 -2
- package/dist/cjs/rules/requireFileOverview.d.ts +0 -2
- package/dist/cjs/rules/requireHyphenBeforeParamDescription.d.ts +0 -2
- package/dist/cjs/rules/requireJsdoc.d.ts +0 -24
- package/dist/cjs/rules/requireParam.d.ts +0 -3
- package/dist/cjs/rules/requireParamDescription.d.ts +0 -2
- package/dist/cjs/rules/requireParamName.d.ts +0 -2
- package/dist/cjs/rules/requireParamType.d.ts +0 -2
- package/dist/cjs/rules/requireProperty.d.ts +0 -2
- package/dist/cjs/rules/requirePropertyDescription.d.ts +0 -2
- package/dist/cjs/rules/requirePropertyName.d.ts +0 -2
- package/dist/cjs/rules/requirePropertyType.d.ts +0 -2
- package/dist/cjs/rules/requireRejects.d.ts +0 -2
- package/dist/cjs/rules/requireReturns.d.ts +0 -2
- package/dist/cjs/rules/requireReturnsCheck.d.ts +0 -2
- package/dist/cjs/rules/requireReturnsDescription.d.ts +0 -2
- package/dist/cjs/rules/requireReturnsType.d.ts +0 -2
- package/dist/cjs/rules/requireTags.d.ts +0 -2
- package/dist/cjs/rules/requireTemplate.d.ts +0 -2
- package/dist/cjs/rules/requireThrows.d.ts +0 -2
- package/dist/cjs/rules/requireYields.d.ts +0 -2
- package/dist/cjs/rules/requireYieldsCheck.d.ts +0 -2
- package/dist/cjs/rules/sortTags.d.ts +0 -2
- package/dist/cjs/rules/tagLines.d.ts +0 -2
- package/dist/cjs/rules/textEscaping.d.ts +0 -2
- package/dist/cjs/rules/tsMethodSignatureStyle.d.ts +0 -2
- package/dist/cjs/rules/tsNoEmptyObjectType.d.ts +0 -2
- package/dist/cjs/rules/tsNoUnnecessaryTemplateExpression.d.ts +0 -2
- package/dist/cjs/rules/tsPreferFunctionType.d.ts +0 -2
- package/dist/cjs/rules/typeFormatting.d.ts +0 -2
- package/dist/cjs/rules/validTypes.d.ts +0 -2
- package/dist/cjs/tagNames.d.ts +0 -15
- package/dist/cjs/utils/hasReturnValue.d.ts +0 -19
- package/dist/defaultTagOrder.cjs +0 -46
- package/dist/defaultTagOrder.cjs.map +0 -1
- package/dist/exportParser.cjs +0 -732
- package/dist/exportParser.cjs.map +0 -1
- package/dist/generateDocs.cjs +0 -342
- package/dist/generateDocs.cjs.map +0 -1
- package/dist/generateOptions.cjs +0 -62
- package/dist/generateOptions.cjs.map +0 -1
- package/dist/generateRule.cjs +0 -248
- package/dist/generateRule.cjs.map +0 -1
- package/dist/generateRuleTypes.cjs +0 -24
- package/dist/generateRuleTypes.cjs.map +0 -1
- package/dist/getDefaultTagStructureForMode.cjs +0 -289
- package/dist/getDefaultTagStructureForMode.cjs.map +0 -1
- package/dist/getJsdocProcessorPlugin.cjs +0 -587
- package/dist/getJsdocProcessorPlugin.cjs.map +0 -1
- package/dist/getJsdocProcessorPlugin.cts +0 -5
- package/dist/index-cjs.cjs +0 -598
- package/dist/index-cjs.cjs.map +0 -1
- package/dist/index-cjs.d.ts +0 -24
- package/dist/index-esm.cjs +0 -162
- package/dist/index-esm.cjs.map +0 -1
- package/dist/index-esm.d.ts +0 -72
- package/dist/index.cjs +0 -746
- package/dist/index.cjs.cts +0 -3
- package/dist/index.cjs.map +0 -1
- package/dist/iterateJsdoc.cjs +0 -2150
- package/dist/iterateJsdoc.cjs.map +0 -1
- package/dist/iterateJsdoc.cts +0 -7
- package/dist/jsdocUtils.cjs +0 -1786
- package/dist/jsdocUtils.cjs.map +0 -1
- package/dist/rules/checkAccess.cjs +0 -40
- package/dist/rules/checkAccess.cjs.map +0 -1
- package/dist/rules/checkAlignment.cjs +0 -78
- package/dist/rules/checkAlignment.cjs.map +0 -1
- package/dist/rules/checkExamples.cjs +0 -521
- package/dist/rules/checkExamples.cjs.map +0 -1
- package/dist/rules/checkIndentation.cjs +0 -170
- package/dist/rules/checkIndentation.cjs.map +0 -1
- package/dist/rules/checkLineAlignment.cjs +0 -398
- package/dist/rules/checkLineAlignment.cjs.map +0 -1
- package/dist/rules/checkParamNames.cjs +0 -407
- package/dist/rules/checkParamNames.cjs.map +0 -1
- package/dist/rules/checkPropertyNames.cjs +0 -135
- package/dist/rules/checkPropertyNames.cjs.map +0 -1
- package/dist/rules/checkSyntax.cjs +0 -38
- package/dist/rules/checkSyntax.cjs.map +0 -1
- package/dist/rules/checkTagNames.cjs +0 -312
- package/dist/rules/checkTagNames.cjs.map +0 -1
- package/dist/rules/checkTemplateNames.cjs +0 -192
- package/dist/rules/checkTemplateNames.cjs.map +0 -1
- package/dist/rules/checkTypes.cjs +0 -111
- package/dist/rules/checkTypes.cjs.map +0 -1
- package/dist/rules/checkValues.cjs +0 -166
- package/dist/rules/checkValues.cjs.map +0 -1
- package/dist/rules/convertToJsdocComments.cjs +0 -356
- package/dist/rules/convertToJsdocComments.cjs.map +0 -1
- package/dist/rules/emptyTags.cjs +0 -98
- package/dist/rules/emptyTags.cjs.map +0 -1
- package/dist/rules/escapeInlineTags.cjs +0 -234
- package/dist/rules/escapeInlineTags.cjs.map +0 -1
- package/dist/rules/implementsOnClasses.cjs +0 -74
- package/dist/rules/implementsOnClasses.cjs.map +0 -1
- package/dist/rules/importsAsDependencies.cjs +0 -104
- package/dist/rules/importsAsDependencies.cjs.map +0 -1
- package/dist/rules/informativeDocs.cjs +0 -187
- package/dist/rules/informativeDocs.cjs.map +0 -1
- package/dist/rules/linesBeforeBlock.cjs +0 -120
- package/dist/rules/linesBeforeBlock.cjs.map +0 -1
- package/dist/rules/matchDescription.cjs +0 -356
- package/dist/rules/matchDescription.cjs.map +0 -1
- package/dist/rules/matchName.cjs +0 -160
- package/dist/rules/matchName.cjs.map +0 -1
- package/dist/rules/multilineBlocks.cjs +0 -431
- package/dist/rules/multilineBlocks.cjs.map +0 -1
- package/dist/rules/noBadBlocks.cjs +0 -100
- package/dist/rules/noBadBlocks.cjs.map +0 -1
- package/dist/rules/noBlankBlockDescriptions.cjs +0 -63
- package/dist/rules/noBlankBlockDescriptions.cjs.map +0 -1
- package/dist/rules/noBlankBlocks.cjs +0 -54
- package/dist/rules/noBlankBlocks.cjs.map +0 -1
- package/dist/rules/noDefaults.cjs +0 -102
- package/dist/rules/noDefaults.cjs.map +0 -1
- package/dist/rules/noMissingSyntax.cjs +0 -196
- package/dist/rules/noMissingSyntax.cjs.map +0 -1
- package/dist/rules/noMultiAsterisks.cjs +0 -126
- package/dist/rules/noMultiAsterisks.cjs.map +0 -1
- package/dist/rules/noRestrictedSyntax.cjs +0 -68
- package/dist/rules/noRestrictedSyntax.cjs.map +0 -1
- package/dist/rules/noTypes.cjs +0 -101
- package/dist/rules/noTypes.cjs.map +0 -1
- package/dist/rules/noUndefinedTypes.cjs +0 -616
- package/dist/rules/noUndefinedTypes.cjs.map +0 -1
- package/dist/rules/normalizeSeeLinks.cjs +0 -271
- package/dist/rules/normalizeSeeLinks.cjs.map +0 -1
- package/dist/rules/preferImportTag.cjs +0 -362
- package/dist/rules/preferImportTag.cjs.map +0 -1
- package/dist/rules/requireAsteriskPrefix.cjs +0 -190
- package/dist/rules/requireAsteriskPrefix.cjs.map +0 -1
- package/dist/rules/requireDescription.cjs +0 -164
- package/dist/rules/requireDescription.cjs.map +0 -1
- package/dist/rules/requireDescriptionCompleteSentence.cjs +0 -321
- package/dist/rules/requireDescriptionCompleteSentence.cjs.map +0 -1
- package/dist/rules/requireExample.cjs +0 -136
- package/dist/rules/requireExample.cjs.map +0 -1
- package/dist/rules/requireFileOverview.cjs +0 -194
- package/dist/rules/requireFileOverview.cjs.map +0 -1
- package/dist/rules/requireHyphenBeforeParamDescription.cjs +0 -166
- package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +0 -1
- package/dist/rules/requireJsdoc.cjs +0 -721
- package/dist/rules/requireJsdoc.cjs.map +0 -1
- package/dist/rules/requireParam.cjs +0 -772
- package/dist/rules/requireParam.cjs.map +0 -1
- package/dist/rules/requireParamDescription.cjs +0 -105
- package/dist/rules/requireParamDescription.cjs.map +0 -1
- package/dist/rules/requireParamName.cjs +0 -68
- package/dist/rules/requireParamName.cjs.map +0 -1
- package/dist/rules/requireParamType.cjs +0 -104
- package/dist/rules/requireParamType.cjs.map +0 -1
- package/dist/rules/requireProperty.cjs +0 -63
- package/dist/rules/requireProperty.cjs.map +0 -1
- package/dist/rules/requirePropertyDescription.cjs +0 -29
- package/dist/rules/requirePropertyDescription.cjs.map +0 -1
- package/dist/rules/requirePropertyName.cjs +0 -29
- package/dist/rules/requirePropertyName.cjs.map +0 -1
- package/dist/rules/requirePropertyType.cjs +0 -29
- package/dist/rules/requirePropertyType.cjs.map +0 -1
- package/dist/rules/requireRejects.cjs +0 -226
- package/dist/rules/requireRejects.cjs.map +0 -1
- package/dist/rules/requireReturns.cjs +0 -262
- package/dist/rules/requireReturns.cjs.map +0 -1
- package/dist/rules/requireReturnsCheck.cjs +0 -225
- package/dist/rules/requireReturnsCheck.cjs.map +0 -1
- package/dist/rules/requireReturnsDescription.cjs +0 -72
- package/dist/rules/requireReturnsDescription.cjs.map +0 -1
- package/dist/rules/requireReturnsType.cjs +0 -68
- package/dist/rules/requireReturnsType.cjs.map +0 -1
- package/dist/rules/requireTags.cjs +0 -74
- package/dist/rules/requireTags.cjs.map +0 -1
- package/dist/rules/requireTemplate.cjs +0 -220
- package/dist/rules/requireTemplate.cjs.map +0 -1
- package/dist/rules/requireThrows.cjs +0 -118
- package/dist/rules/requireThrows.cjs.map +0 -1
- package/dist/rules/requireYields.cjs +0 -224
- package/dist/rules/requireYields.cjs.map +0 -1
- package/dist/rules/requireYieldsCheck.cjs +0 -179
- package/dist/rules/requireYieldsCheck.cjs.map +0 -1
- package/dist/rules/sortTags.cjs +0 -656
- package/dist/rules/sortTags.cjs.map +0 -1
- package/dist/rules/tagLines.cjs +0 -374
- package/dist/rules/tagLines.cjs.map +0 -1
- package/dist/rules/textEscaping.cjs +0 -141
- package/dist/rules/textEscaping.cjs.map +0 -1
- package/dist/rules/tsMethodSignatureStyle.cjs +0 -240
- package/dist/rules/tsMethodSignatureStyle.cjs.map +0 -1
- package/dist/rules/tsNoEmptyObjectType.cjs +0 -62
- package/dist/rules/tsNoEmptyObjectType.cjs.map +0 -1
- package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs +0 -104
- package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs.map +0 -1
- package/dist/rules/tsPreferFunctionType.cjs +0 -110
- package/dist/rules/tsPreferFunctionType.cjs.map +0 -1
- package/dist/rules/typeFormatting.cjs +0 -607
- package/dist/rules/typeFormatting.cjs.map +0 -1
- package/dist/rules/validTypes.cjs +0 -324
- package/dist/rules/validTypes.cjs.map +0 -1
- package/dist/tagNames.cjs +0 -244
- package/dist/tagNames.cjs.map +0 -1
- package/dist/to-valid-identifier.cjs +0 -263
- package/dist/utils/hasReturnValue.cjs +0 -495
- package/dist/utils/hasReturnValue.cjs.map +0 -1
- package/rollup.config.js +0 -16
- package/src/getJsdocProcessorPlugin.cts +0 -5
- package/src/index-cjs.js +0 -758
- package/src/index-esm.js +0 -196
- package/src/index.cjs.cts +0 -3
- package/src/iterateJsdoc.cts +0 -7
package/dist/alignTransform.cjs
DELETED
|
@@ -1,402 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _commentParser = require("comment-parser");
|
|
8
|
-
/**
|
|
9
|
-
* Transform based on https://github.com/syavorsky/comment-parser/blob/master/src/transforms/align.ts
|
|
10
|
-
*
|
|
11
|
-
* It contains some customizations to align based on the tags, and some custom options.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Detects if a line starts with a markdown list marker
|
|
16
|
-
* Supports: -, *, numbered lists (1., 2., etc.)
|
|
17
|
-
* This explicitly excludes hyphens that are part of JSDoc tag syntax
|
|
18
|
-
* @param {string} text - The text to check
|
|
19
|
-
* @param {boolean} isFirstLineOfTag - True if this is the first line (tag line)
|
|
20
|
-
* @returns {boolean} - True if the text starts with a list marker
|
|
21
|
-
*/
|
|
22
|
-
const startsWithListMarker = (text, isFirstLineOfTag = false) => {
|
|
23
|
-
// On the first line of a tag, the hyphen is typically the JSDoc separator,
|
|
24
|
-
// not a list marker
|
|
25
|
-
if (isFirstLineOfTag) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Match lines that start with optional whitespace, then a list marker
|
|
30
|
-
// - or * followed by a space
|
|
31
|
-
// or a number followed by . or ) and a space
|
|
32
|
-
return /^\s*(?:[\-*]|\d+(?:\.|\)))\s+/v.test(text);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @typedef {{
|
|
37
|
-
* hasNoTypes: boolean,
|
|
38
|
-
* maxNamedTagLength: import('./iterateJsdoc.js').Integer,
|
|
39
|
-
* maxUnnamedTagLength: import('./iterateJsdoc.js').Integer
|
|
40
|
-
* }} TypelessInfo
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
const {
|
|
44
|
-
rewireSource
|
|
45
|
-
} = _commentParser.util;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @typedef {{
|
|
49
|
-
* name: import('./iterateJsdoc.js').Integer,
|
|
50
|
-
* start: import('./iterateJsdoc.js').Integer,
|
|
51
|
-
* tag: import('./iterateJsdoc.js').Integer,
|
|
52
|
-
* type: import('./iterateJsdoc.js').Integer
|
|
53
|
-
* }} Width
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
/** @type {Width} */
|
|
57
|
-
const zeroWidth = {
|
|
58
|
-
name: 0,
|
|
59
|
-
start: 0,
|
|
60
|
-
tag: 0,
|
|
61
|
-
type: 0
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @param {string[]} tags
|
|
66
|
-
* @param {import('./iterateJsdoc.js').Integer} index
|
|
67
|
-
* @param {import('comment-parser').Line[]} source
|
|
68
|
-
* @returns {boolean}
|
|
69
|
-
*/
|
|
70
|
-
const shouldAlign = (tags, index, source) => {
|
|
71
|
-
const tag = source[index].tokens.tag.replace('@', '');
|
|
72
|
-
const includesTag = tags.includes(tag);
|
|
73
|
-
if (includesTag) {
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
if (tag !== '') {
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
for (let iterator = index; iterator >= 0; iterator--) {
|
|
80
|
-
const previousTag = source[iterator].tokens.tag.replace('@', '');
|
|
81
|
-
if (previousTag !== '') {
|
|
82
|
-
if (tags.includes(previousTag)) {
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return true;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* @param {string[]} tags
|
|
93
|
-
* @returns {(
|
|
94
|
-
* width: Width,
|
|
95
|
-
* line: {
|
|
96
|
-
* tokens: import('comment-parser').Tokens
|
|
97
|
-
* },
|
|
98
|
-
* index: import('./iterateJsdoc.js').Integer,
|
|
99
|
-
* source: import('comment-parser').Line[]
|
|
100
|
-
* ) => Width}
|
|
101
|
-
*/
|
|
102
|
-
const getWidth = tags => {
|
|
103
|
-
return (width, {
|
|
104
|
-
tokens
|
|
105
|
-
}, index, source) => {
|
|
106
|
-
if (!shouldAlign(tags, index, source)) {
|
|
107
|
-
return width;
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
name: Math.max(width.name, tokens.name.length),
|
|
111
|
-
start: tokens.delimiter === '/**' ? tokens.start.length : width.start,
|
|
112
|
-
tag: Math.max(width.tag, tokens.tag.length),
|
|
113
|
-
type: Math.max(width.type, tokens.type.length)
|
|
114
|
-
};
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* @param {{
|
|
120
|
-
* description: string;
|
|
121
|
-
* tags: import('comment-parser').Spec[];
|
|
122
|
-
* problems: import('comment-parser').Problem[];
|
|
123
|
-
* }} fields
|
|
124
|
-
* @returns {TypelessInfo}
|
|
125
|
-
*/
|
|
126
|
-
const getTypelessInfo = fields => {
|
|
127
|
-
const hasNoTypes = fields.tags.every(({
|
|
128
|
-
type
|
|
129
|
-
}) => {
|
|
130
|
-
return !type;
|
|
131
|
-
});
|
|
132
|
-
const maxNamedTagLength = Math.max(...fields.tags.map(({
|
|
133
|
-
name,
|
|
134
|
-
tag
|
|
135
|
-
}) => {
|
|
136
|
-
return name.length === 0 ? -1 : tag.length;
|
|
137
|
-
}).filter(length => {
|
|
138
|
-
return length !== -1;
|
|
139
|
-
})) + 1;
|
|
140
|
-
const maxUnnamedTagLength = Math.max(...fields.tags.map(({
|
|
141
|
-
name,
|
|
142
|
-
tag
|
|
143
|
-
}) => {
|
|
144
|
-
return name.length === 0 ? tag.length : -1;
|
|
145
|
-
}).filter(length => {
|
|
146
|
-
return length !== -1;
|
|
147
|
-
})) + 1;
|
|
148
|
-
return {
|
|
149
|
-
hasNoTypes,
|
|
150
|
-
maxNamedTagLength,
|
|
151
|
-
maxUnnamedTagLength
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* @param {import('./iterateJsdoc.js').Integer} len
|
|
157
|
-
* @returns {string}
|
|
158
|
-
*/
|
|
159
|
-
const space = len => {
|
|
160
|
-
return ''.padStart(len, ' ');
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Check if a tag or any of its lines contain list markers
|
|
165
|
-
* @param {import('./iterateJsdoc.js').Integer} index - Current line index
|
|
166
|
-
* @param {import('comment-parser').Line[]} source - All source lines
|
|
167
|
-
* @returns {{hasListMarker: boolean, tagStartIndex: import('./iterateJsdoc.js').Integer}}
|
|
168
|
-
*/
|
|
169
|
-
const checkForListMarkers = (index, source) => {
|
|
170
|
-
let hasListMarker = false;
|
|
171
|
-
let tagStartIndex = index;
|
|
172
|
-
while (tagStartIndex > 0 && source[tagStartIndex].tokens.tag === '') {
|
|
173
|
-
tagStartIndex--;
|
|
174
|
-
}
|
|
175
|
-
for (let idx = tagStartIndex; idx <= index; idx++) {
|
|
176
|
-
const isFirstLine = idx === tagStartIndex;
|
|
177
|
-
if (source[idx]?.tokens?.description && startsWithListMarker(source[idx].tokens.description, isFirstLine)) {
|
|
178
|
-
hasListMarker = true;
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return {
|
|
183
|
-
hasListMarker,
|
|
184
|
-
tagStartIndex
|
|
185
|
-
};
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Calculate extra indentation for list items relative to the first continuation line
|
|
190
|
-
* @param {import('./iterateJsdoc.js').Integer} index - Current line index
|
|
191
|
-
* @param {import('./iterateJsdoc.js').Integer} tagStartIndex - Index of the tag line
|
|
192
|
-
* @param {import('comment-parser').Line[]} source - All source lines
|
|
193
|
-
* @returns {string} - Extra indentation spaces
|
|
194
|
-
*/
|
|
195
|
-
const calculateListExtraIndent = (index, tagStartIndex, source) => {
|
|
196
|
-
// Find the first continuation line to use as baseline
|
|
197
|
-
let firstContinuationIndent = null;
|
|
198
|
-
for (let idx = tagStartIndex + 1; idx < source.length; idx++) {
|
|
199
|
-
if (source[idx].tokens.description && !source[idx].tokens.tag) {
|
|
200
|
-
firstContinuationIndent = source[idx].tokens.postDelimiter.length;
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// Calculate the extra indentation of current line relative to the first continuation line
|
|
206
|
-
const currentOriginalIndent = source[index].tokens.postDelimiter.length;
|
|
207
|
-
const extraIndent = firstContinuationIndent !== null && currentOriginalIndent > firstContinuationIndent ? ' '.repeat(currentOriginalIndent - firstContinuationIndent) : '';
|
|
208
|
-
return extraIndent;
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* @param {{
|
|
213
|
-
* customSpacings: import('../src/rules/checkLineAlignment.js').CustomSpacings,
|
|
214
|
-
* tags: string[],
|
|
215
|
-
* indent: string,
|
|
216
|
-
* preserveMainDescriptionPostDelimiter: boolean,
|
|
217
|
-
* wrapIndent: string,
|
|
218
|
-
* disableWrapIndent: boolean,
|
|
219
|
-
* }} cfg
|
|
220
|
-
* @returns {(
|
|
221
|
-
* block: import('comment-parser').Block
|
|
222
|
-
* ) => import('comment-parser').Block}
|
|
223
|
-
*/
|
|
224
|
-
const alignTransform = ({
|
|
225
|
-
customSpacings,
|
|
226
|
-
disableWrapIndent,
|
|
227
|
-
indent,
|
|
228
|
-
preserveMainDescriptionPostDelimiter,
|
|
229
|
-
tags,
|
|
230
|
-
wrapIndent
|
|
231
|
-
}) => {
|
|
232
|
-
let intoTags = false;
|
|
233
|
-
/** @type {Width} */
|
|
234
|
-
let width;
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* @param {import('comment-parser').Tokens} tokens
|
|
238
|
-
* @param {TypelessInfo} typelessInfo
|
|
239
|
-
* @returns {import('comment-parser').Tokens}
|
|
240
|
-
*/
|
|
241
|
-
const alignTokens = (tokens, typelessInfo) => {
|
|
242
|
-
const nothingAfter = {
|
|
243
|
-
delim: false,
|
|
244
|
-
name: false,
|
|
245
|
-
tag: false,
|
|
246
|
-
type: false
|
|
247
|
-
};
|
|
248
|
-
if (tokens.description === '') {
|
|
249
|
-
nothingAfter.name = true;
|
|
250
|
-
tokens.postName = '';
|
|
251
|
-
if (tokens.name === '') {
|
|
252
|
-
nothingAfter.type = true;
|
|
253
|
-
tokens.postType = '';
|
|
254
|
-
if (tokens.type === '') {
|
|
255
|
-
nothingAfter.tag = true;
|
|
256
|
-
tokens.postTag = '';
|
|
257
|
-
|
|
258
|
-
/* c8 ignore next: Never happens because the !intoTags return. But it's here for consistency with the original align transform */
|
|
259
|
-
if (tokens.tag === '') {
|
|
260
|
-
nothingAfter.delim = true;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
let untypedNameAdjustment = 0;
|
|
266
|
-
let untypedTypeAdjustment = 0;
|
|
267
|
-
if (typelessInfo.hasNoTypes) {
|
|
268
|
-
nothingAfter.tag = true;
|
|
269
|
-
tokens.postTag = '';
|
|
270
|
-
if (tokens.name === '') {
|
|
271
|
-
untypedNameAdjustment = typelessInfo.maxNamedTagLength - tokens.tag.length;
|
|
272
|
-
} else {
|
|
273
|
-
untypedNameAdjustment = typelessInfo.maxNamedTagLength > typelessInfo.maxUnnamedTagLength ? 0 : Math.max(0, typelessInfo.maxUnnamedTagLength - (tokens.tag.length + tokens.name.length + 1));
|
|
274
|
-
untypedTypeAdjustment = typelessInfo.maxNamedTagLength - tokens.tag.length;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// Todo: Avoid fixing alignment of blocks with multiline wrapping of type
|
|
279
|
-
if (tokens.tag === '' && tokens.type) {
|
|
280
|
-
return tokens;
|
|
281
|
-
}
|
|
282
|
-
const spacings = {
|
|
283
|
-
postDelimiter: customSpacings?.postDelimiter || 1,
|
|
284
|
-
postName: customSpacings?.postName || 1,
|
|
285
|
-
postTag: customSpacings?.postTag || 1,
|
|
286
|
-
postType: customSpacings?.postType || 1
|
|
287
|
-
};
|
|
288
|
-
tokens.postDelimiter = nothingAfter.delim ? '' : space(spacings.postDelimiter);
|
|
289
|
-
if (!nothingAfter.tag) {
|
|
290
|
-
tokens.postTag = space(width.tag - tokens.tag.length + spacings.postTag);
|
|
291
|
-
}
|
|
292
|
-
if (!nothingAfter.type) {
|
|
293
|
-
tokens.postType = space(width.type - tokens.type.length + spacings.postType + untypedTypeAdjustment);
|
|
294
|
-
}
|
|
295
|
-
if (!nothingAfter.name) {
|
|
296
|
-
// If post name is empty for all lines (name width 0), don't add post name spacing.
|
|
297
|
-
tokens.postName = width.name === 0 ? '' : space(width.name - tokens.name.length + spacings.postName + untypedNameAdjustment);
|
|
298
|
-
}
|
|
299
|
-
return tokens;
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* @param {import('comment-parser').Line} line
|
|
304
|
-
* @param {import('./iterateJsdoc.js').Integer} index
|
|
305
|
-
* @param {import('comment-parser').Line[]} source
|
|
306
|
-
* @param {TypelessInfo} typelessInfo
|
|
307
|
-
* @param {string|false} indentTag
|
|
308
|
-
* @returns {import('comment-parser').Line}
|
|
309
|
-
*/
|
|
310
|
-
const update = (line, index, source, typelessInfo, indentTag) => {
|
|
311
|
-
/** @type {import('comment-parser').Tokens} */
|
|
312
|
-
const tokens = {
|
|
313
|
-
...line.tokens
|
|
314
|
-
};
|
|
315
|
-
if (tokens.tag !== '') {
|
|
316
|
-
intoTags = true;
|
|
317
|
-
}
|
|
318
|
-
const isEmpty = tokens.tag === '' && tokens.name === '' && tokens.type === '' && tokens.description === '';
|
|
319
|
-
|
|
320
|
-
// dangling '*/'
|
|
321
|
-
if (tokens.end === '*/' && isEmpty) {
|
|
322
|
-
tokens.start = indent + ' ';
|
|
323
|
-
return {
|
|
324
|
-
...line,
|
|
325
|
-
tokens
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
switch (tokens.delimiter) {
|
|
329
|
-
case '*':
|
|
330
|
-
tokens.start = indent + ' ';
|
|
331
|
-
break;
|
|
332
|
-
case '/**':
|
|
333
|
-
tokens.start = indent;
|
|
334
|
-
break;
|
|
335
|
-
default:
|
|
336
|
-
tokens.delimiter = '';
|
|
337
|
-
|
|
338
|
-
// compensate delimiter
|
|
339
|
-
tokens.start = indent + ' ';
|
|
340
|
-
}
|
|
341
|
-
if (!intoTags) {
|
|
342
|
-
if (tokens.description === '') {
|
|
343
|
-
tokens.postDelimiter = '';
|
|
344
|
-
} else if (!preserveMainDescriptionPostDelimiter) {
|
|
345
|
-
tokens.postDelimiter = ' ';
|
|
346
|
-
}
|
|
347
|
-
return {
|
|
348
|
-
...line,
|
|
349
|
-
tokens
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
const postHyphenSpacing = customSpacings?.postHyphen ?? 1;
|
|
353
|
-
const hyphenSpacing = /^\s*-\s+/v;
|
|
354
|
-
tokens.description = tokens.description.replace(hyphenSpacing, '-' + ''.padStart(postHyphenSpacing, ' '));
|
|
355
|
-
|
|
356
|
-
// Not align.
|
|
357
|
-
if (shouldAlign(tags, index, source)) {
|
|
358
|
-
alignTokens(tokens, typelessInfo);
|
|
359
|
-
if (!disableWrapIndent && indentTag) {
|
|
360
|
-
const {
|
|
361
|
-
hasListMarker,
|
|
362
|
-
tagStartIndex
|
|
363
|
-
} = checkForListMarkers(index, source);
|
|
364
|
-
if (hasListMarker && index > tagStartIndex) {
|
|
365
|
-
const extraIndent = calculateListExtraIndent(index, tagStartIndex, source);
|
|
366
|
-
tokens.postDelimiter += wrapIndent + extraIndent;
|
|
367
|
-
} else {
|
|
368
|
-
// Normal case: add wrapIndent after the aligned delimiter
|
|
369
|
-
tokens.postDelimiter += wrapIndent;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
return {
|
|
374
|
-
...line,
|
|
375
|
-
tokens
|
|
376
|
-
};
|
|
377
|
-
};
|
|
378
|
-
return ({
|
|
379
|
-
source,
|
|
380
|
-
...fields
|
|
381
|
-
}) => {
|
|
382
|
-
width = source.reduce(getWidth(tags), {
|
|
383
|
-
...zeroWidth
|
|
384
|
-
});
|
|
385
|
-
const typelessInfo = getTypelessInfo(fields);
|
|
386
|
-
let tagIndentMode = false;
|
|
387
|
-
return rewireSource({
|
|
388
|
-
...fields,
|
|
389
|
-
source: source.map((line, index) => {
|
|
390
|
-
const indentTag = !disableWrapIndent && tagIndentMode && !line.tokens.tag && line.tokens.description;
|
|
391
|
-
const ret = update(line, index, source, typelessInfo, indentTag);
|
|
392
|
-
if (!disableWrapIndent && line.tokens.tag) {
|
|
393
|
-
tagIndentMode = true;
|
|
394
|
-
}
|
|
395
|
-
return ret;
|
|
396
|
-
})
|
|
397
|
-
});
|
|
398
|
-
};
|
|
399
|
-
};
|
|
400
|
-
var _default = exports.default = alignTransform;
|
|
401
|
-
module.exports = exports.default;
|
|
402
|
-
//# sourceMappingURL=alignTransform.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"alignTransform.cjs","names":["util"],"sources":["../src/alignTransform.js"],"sourcesContent":["/**\n * Transform based on https://github.com/syavorsky/comment-parser/blob/master/src/transforms/align.ts\n *\n * It contains some customizations to align based on the tags, and some custom options.\n */\n\nimport {\n // `comment-parser/primitives` export\n util,\n} from 'comment-parser';\n\n/**\n * Detects if a line starts with a markdown list marker\n * Supports: -, *, numbered lists (1., 2., etc.)\n * This explicitly excludes hyphens that are part of JSDoc tag syntax\n * @param {string} text - The text to check\n * @param {boolean} isFirstLineOfTag - True if this is the first line (tag line)\n * @returns {boolean} - True if the text starts with a list marker\n */\nconst startsWithListMarker = (text, isFirstLineOfTag = false) => {\n // On the first line of a tag, the hyphen is typically the JSDoc separator,\n // not a list marker\n if (isFirstLineOfTag) {\n return false;\n }\n\n // Match lines that start with optional whitespace, then a list marker\n // - or * followed by a space\n // or a number followed by . or ) and a space\n return /^\\s*(?:[\\-*]|\\d+(?:\\.|\\)))\\s+/v.test(text);\n};\n\n/**\n * @typedef {{\n * hasNoTypes: boolean,\n * maxNamedTagLength: import('./iterateJsdoc.js').Integer,\n * maxUnnamedTagLength: import('./iterateJsdoc.js').Integer\n * }} TypelessInfo\n */\n\nconst {\n rewireSource,\n} = util;\n\n/**\n * @typedef {{\n * name: import('./iterateJsdoc.js').Integer,\n * start: import('./iterateJsdoc.js').Integer,\n * tag: import('./iterateJsdoc.js').Integer,\n * type: import('./iterateJsdoc.js').Integer\n * }} Width\n */\n\n/** @type {Width} */\nconst zeroWidth = {\n name: 0,\n start: 0,\n tag: 0,\n type: 0,\n};\n\n/**\n * @param {string[]} tags\n * @param {import('./iterateJsdoc.js').Integer} index\n * @param {import('comment-parser').Line[]} source\n * @returns {boolean}\n */\nconst shouldAlign = (tags, index, source) => {\n const tag = source[index].tokens.tag.replace('@', '');\n const includesTag = tags.includes(tag);\n\n if (includesTag) {\n return true;\n }\n\n if (tag !== '') {\n return false;\n }\n\n for (let iterator = index; iterator >= 0; iterator--) {\n const previousTag = source[iterator].tokens.tag.replace('@', '');\n\n if (previousTag !== '') {\n if (tags.includes(previousTag)) {\n return true;\n }\n\n return false;\n }\n }\n\n return true;\n};\n\n/**\n * @param {string[]} tags\n * @returns {(\n * width: Width,\n * line: {\n * tokens: import('comment-parser').Tokens\n * },\n * index: import('./iterateJsdoc.js').Integer,\n * source: import('comment-parser').Line[]\n * ) => Width}\n */\nconst getWidth = (tags) => {\n return (width, {\n tokens,\n }, index, source) => {\n if (!shouldAlign(tags, index, source)) {\n return width;\n }\n\n return {\n name: Math.max(width.name, tokens.name.length),\n start: tokens.delimiter === '/**' ? tokens.start.length : width.start,\n tag: Math.max(width.tag, tokens.tag.length),\n type: Math.max(width.type, tokens.type.length),\n };\n };\n};\n\n/**\n * @param {{\n * description: string;\n * tags: import('comment-parser').Spec[];\n * problems: import('comment-parser').Problem[];\n * }} fields\n * @returns {TypelessInfo}\n */\nconst getTypelessInfo = (fields) => {\n const hasNoTypes = fields.tags.every(({\n type,\n }) => {\n return !type;\n });\n const maxNamedTagLength = Math.max(...fields.tags.map(({\n name,\n tag,\n }) => {\n return name.length === 0 ? -1 : tag.length;\n }).filter((length) => {\n return length !== -1;\n })) + 1;\n const maxUnnamedTagLength = Math.max(...fields.tags.map(({\n name,\n tag,\n }) => {\n return name.length === 0 ? tag.length : -1;\n }).filter((length) => {\n return length !== -1;\n })) + 1;\n return {\n hasNoTypes,\n maxNamedTagLength,\n maxUnnamedTagLength,\n };\n};\n\n/**\n * @param {import('./iterateJsdoc.js').Integer} len\n * @returns {string}\n */\nconst space = (len) => {\n return ''.padStart(len, ' ');\n};\n\n/**\n * Check if a tag or any of its lines contain list markers\n * @param {import('./iterateJsdoc.js').Integer} index - Current line index\n * @param {import('comment-parser').Line[]} source - All source lines\n * @returns {{hasListMarker: boolean, tagStartIndex: import('./iterateJsdoc.js').Integer}}\n */\nconst checkForListMarkers = (index, source) => {\n let hasListMarker = false;\n let tagStartIndex = index;\n while (tagStartIndex > 0 && source[tagStartIndex].tokens.tag === '') {\n tagStartIndex--;\n }\n\n for (let idx = tagStartIndex; idx <= index; idx++) {\n const isFirstLine = (idx === tagStartIndex);\n if (source[idx]?.tokens?.description && startsWithListMarker(source[idx].tokens.description, isFirstLine)) {\n hasListMarker = true;\n break;\n }\n }\n\n return {\n hasListMarker,\n tagStartIndex,\n };\n};\n\n/**\n * Calculate extra indentation for list items relative to the first continuation line\n * @param {import('./iterateJsdoc.js').Integer} index - Current line index\n * @param {import('./iterateJsdoc.js').Integer} tagStartIndex - Index of the tag line\n * @param {import('comment-parser').Line[]} source - All source lines\n * @returns {string} - Extra indentation spaces\n */\nconst calculateListExtraIndent = (index, tagStartIndex, source) => {\n // Find the first continuation line to use as baseline\n let firstContinuationIndent = null;\n for (let idx = tagStartIndex + 1; idx < source.length; idx++) {\n if (source[idx].tokens.description && !source[idx].tokens.tag) {\n firstContinuationIndent = source[idx].tokens.postDelimiter.length;\n break;\n }\n }\n\n // Calculate the extra indentation of current line relative to the first continuation line\n const currentOriginalIndent = source[index].tokens.postDelimiter.length;\n const extraIndent = firstContinuationIndent !== null && currentOriginalIndent > firstContinuationIndent ?\n ' '.repeat(currentOriginalIndent - firstContinuationIndent) :\n '';\n\n return extraIndent;\n};\n\n/**\n * @param {{\n * customSpacings: import('../src/rules/checkLineAlignment.js').CustomSpacings,\n * tags: string[],\n * indent: string,\n * preserveMainDescriptionPostDelimiter: boolean,\n * wrapIndent: string,\n * disableWrapIndent: boolean,\n * }} cfg\n * @returns {(\n * block: import('comment-parser').Block\n * ) => import('comment-parser').Block}\n */\nconst alignTransform = ({\n customSpacings,\n disableWrapIndent,\n indent,\n preserveMainDescriptionPostDelimiter,\n tags,\n wrapIndent,\n}) => {\n let intoTags = false;\n /** @type {Width} */\n let width;\n\n /**\n * @param {import('comment-parser').Tokens} tokens\n * @param {TypelessInfo} typelessInfo\n * @returns {import('comment-parser').Tokens}\n */\n const alignTokens = (tokens, typelessInfo) => {\n const nothingAfter = {\n delim: false,\n name: false,\n tag: false,\n type: false,\n };\n\n if (tokens.description === '') {\n nothingAfter.name = true;\n tokens.postName = '';\n\n if (tokens.name === '') {\n nothingAfter.type = true;\n tokens.postType = '';\n\n if (tokens.type === '') {\n nothingAfter.tag = true;\n tokens.postTag = '';\n\n /* c8 ignore next: Never happens because the !intoTags return. But it's here for consistency with the original align transform */\n if (tokens.tag === '') {\n nothingAfter.delim = true;\n }\n }\n }\n }\n\n let untypedNameAdjustment = 0;\n let untypedTypeAdjustment = 0;\n if (typelessInfo.hasNoTypes) {\n nothingAfter.tag = true;\n tokens.postTag = '';\n if (tokens.name === '') {\n untypedNameAdjustment = typelessInfo.maxNamedTagLength - tokens.tag.length;\n } else {\n untypedNameAdjustment = typelessInfo.maxNamedTagLength > typelessInfo.maxUnnamedTagLength ? 0 :\n Math.max(0, typelessInfo.maxUnnamedTagLength - (tokens.tag.length + tokens.name.length + 1));\n untypedTypeAdjustment = typelessInfo.maxNamedTagLength - tokens.tag.length;\n }\n }\n\n // Todo: Avoid fixing alignment of blocks with multiline wrapping of type\n if (tokens.tag === '' && tokens.type) {\n return tokens;\n }\n\n const spacings = {\n postDelimiter: customSpacings?.postDelimiter || 1,\n postName: customSpacings?.postName || 1,\n postTag: customSpacings?.postTag || 1,\n postType: customSpacings?.postType || 1,\n };\n\n tokens.postDelimiter = nothingAfter.delim ? '' : space(spacings.postDelimiter);\n\n if (!nothingAfter.tag) {\n tokens.postTag = space(width.tag - tokens.tag.length + spacings.postTag);\n }\n\n if (!nothingAfter.type) {\n tokens.postType = space(width.type - tokens.type.length + spacings.postType + untypedTypeAdjustment);\n }\n\n if (!nothingAfter.name) {\n // If post name is empty for all lines (name width 0), don't add post name spacing.\n tokens.postName = width.name === 0 ? '' : space(width.name - tokens.name.length + spacings.postName + untypedNameAdjustment);\n }\n\n return tokens;\n };\n\n /**\n * @param {import('comment-parser').Line} line\n * @param {import('./iterateJsdoc.js').Integer} index\n * @param {import('comment-parser').Line[]} source\n * @param {TypelessInfo} typelessInfo\n * @param {string|false} indentTag\n * @returns {import('comment-parser').Line}\n */\n const update = (line, index, source, typelessInfo, indentTag) => {\n /** @type {import('comment-parser').Tokens} */\n const tokens = {\n ...line.tokens,\n };\n\n if (tokens.tag !== '') {\n intoTags = true;\n }\n\n const isEmpty =\n tokens.tag === '' &&\n tokens.name === '' &&\n tokens.type === '' &&\n tokens.description === '';\n\n // dangling '*/'\n if (tokens.end === '*/' && isEmpty) {\n tokens.start = indent + ' ';\n\n return {\n ...line,\n tokens,\n };\n }\n\n switch (tokens.delimiter) {\n case '*':\n tokens.start = indent + ' ';\n break;\n case '/**':\n tokens.start = indent;\n break;\n default:\n tokens.delimiter = '';\n\n // compensate delimiter\n tokens.start = indent + ' ';\n }\n\n if (!intoTags) {\n if (tokens.description === '') {\n tokens.postDelimiter = '';\n } else if (!preserveMainDescriptionPostDelimiter) {\n tokens.postDelimiter = ' ';\n }\n\n return {\n ...line,\n tokens,\n };\n }\n\n const postHyphenSpacing = customSpacings?.postHyphen ?? 1;\n const hyphenSpacing = /^\\s*-\\s+/v;\n tokens.description = tokens.description.replace(\n hyphenSpacing, '-' + ''.padStart(postHyphenSpacing, ' '),\n );\n\n // Not align.\n if (shouldAlign(tags, index, source)) {\n alignTokens(tokens, typelessInfo);\n\n if (!disableWrapIndent && indentTag) {\n const {\n hasListMarker,\n tagStartIndex,\n } = checkForListMarkers(index, source);\n\n if (hasListMarker && index > tagStartIndex) {\n const extraIndent = calculateListExtraIndent(index, tagStartIndex, source);\n tokens.postDelimiter += wrapIndent + extraIndent;\n } else {\n // Normal case: add wrapIndent after the aligned delimiter\n tokens.postDelimiter += wrapIndent;\n }\n }\n }\n\n return {\n ...line,\n tokens,\n };\n };\n\n return ({\n source,\n ...fields\n }) => {\n width = source.reduce(getWidth(tags), {\n ...zeroWidth,\n });\n\n const typelessInfo = getTypelessInfo(fields);\n\n let tagIndentMode = false;\n\n return rewireSource({\n ...fields,\n source: source.map((line, index) => {\n const indentTag = !disableWrapIndent && tagIndentMode && !line.tokens.tag && line.tokens.description;\n const ret = update(line, index, source, typelessInfo, indentTag);\n\n if (!disableWrapIndent && line.tokens.tag) {\n tagIndentMode = true;\n }\n\n return ret;\n }),\n });\n };\n};\n\nexport default alignTransform;\n"],"mappings":";;;;;;AAMA;AANA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,oBAAoB,GAAG,CAAC,IAAI,EAAE,gBAAgB,GAAG,KAAK,KAAK;EAC/D;EACA;EACA,IAAI,gBAAgB,EAAE;IACpB,OAAO,KAAK;EACd;;EAEA;EACA;EACA;EACA,OAAO,gCAAgC,CAAC,IAAI,CAAC,IAAI,CAAC;AACpD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAM;EACJ;AACF,CAAC,GAAGA,eAAA,IAAI;;AAER;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,MAAM,SAAS,GAAG;EAChB,IAAI,EAAE,CAAC;EACP,KAAK,EAAE,CAAC;EACR,GAAG,EAAE,CAAC;EACN,IAAI,EAAE;AACR,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK;EAC3C,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;EACrD,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;EAEtC,IAAI,WAAW,EAAE;IACf,OAAO,IAAI;EACb;EAEA,IAAI,GAAG,KAAK,EAAE,EAAE;IACd,OAAO,KAAK;EACd;EAEA,KAAK,IAAI,QAAQ,GAAG,KAAK,EAAE,QAAQ,IAAI,CAAC,EAAE,QAAQ,EAAE,EAAE;IACpD,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;IAEhE,IAAI,WAAW,KAAK,EAAE,EA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oreList":[]}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.buildForbidRuleDefinition = void 0;
|
|
7
|
-
var _iterateJsdoc = _interopRequireDefault(require("./iterateJsdoc.cjs"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
/**
|
|
10
|
-
* @typedef {(string|{
|
|
11
|
-
* comment: string,
|
|
12
|
-
* context: string,
|
|
13
|
-
* message?: string
|
|
14
|
-
* })[]} Contexts
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @param {{
|
|
19
|
-
* contexts?: Contexts,
|
|
20
|
-
* description?: string,
|
|
21
|
-
* getContexts?: (
|
|
22
|
-
* ctxt: import('eslint').Rule.RuleContext,
|
|
23
|
-
* report: import('./iterateJsdoc.js').Report
|
|
24
|
-
* ) => Contexts|false,
|
|
25
|
-
* contextName?: string,
|
|
26
|
-
* modifyContext?: (context: import('eslint').Rule.RuleContext) => import('eslint').Rule.RuleContext,
|
|
27
|
-
* schema?: import('eslint').Rule.RuleMetaData['schema']
|
|
28
|
-
* url?: string,
|
|
29
|
-
* }} cfg
|
|
30
|
-
* @returns {import('eslint').Rule.RuleModule}
|
|
31
|
-
*/
|
|
32
|
-
const buildForbidRuleDefinition = ({
|
|
33
|
-
contextName,
|
|
34
|
-
contexts: cntxts,
|
|
35
|
-
description,
|
|
36
|
-
getContexts,
|
|
37
|
-
modifyContext,
|
|
38
|
-
schema,
|
|
39
|
-
url
|
|
40
|
-
}) => {
|
|
41
|
-
return (0, _iterateJsdoc.default)(({
|
|
42
|
-
context,
|
|
43
|
-
info: {
|
|
44
|
-
comment
|
|
45
|
-
},
|
|
46
|
-
report,
|
|
47
|
-
utils
|
|
48
|
-
}) => {
|
|
49
|
-
/** @type {Contexts|boolean|undefined} */
|
|
50
|
-
let contexts = cntxts;
|
|
51
|
-
if (getContexts) {
|
|
52
|
-
contexts = getContexts(context, report);
|
|
53
|
-
if (!contexts) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
const {
|
|
58
|
-
contextStr,
|
|
59
|
-
foundContext
|
|
60
|
-
} = utils.findContext(/** @type {Contexts} */contexts, comment);
|
|
61
|
-
|
|
62
|
-
// We are not on the *particular* matching context/comment, so don't assume
|
|
63
|
-
// we need reporting
|
|
64
|
-
if (!foundContext) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const message = /** @type {import('./iterateJsdoc.js').ContextObject} */foundContext?.message ?? 'Syntax is restricted: {{context}}' + (comment ? ' with {{comment}}' : '');
|
|
68
|
-
report(message, null, null, comment ? {
|
|
69
|
-
comment,
|
|
70
|
-
context: contextStr
|
|
71
|
-
} : {
|
|
72
|
-
context: contextStr
|
|
73
|
-
});
|
|
74
|
-
}, {
|
|
75
|
-
contextSelected: true,
|
|
76
|
-
meta: {
|
|
77
|
-
docs: {
|
|
78
|
-
description: description ?? contextName ?? 'Reports when certain comment structures are present.',
|
|
79
|
-
url: url ?? 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/advanced.md#user-content-advanced-creating-your-own-rules'
|
|
80
|
-
},
|
|
81
|
-
schema: schema ?? [],
|
|
82
|
-
type: 'suggestion'
|
|
83
|
-
},
|
|
84
|
-
modifyContext: modifyContext ?? (getContexts ? undefined : context => {
|
|
85
|
-
// Reproduce context object with our own `contexts`
|
|
86
|
-
const propertyDescriptors = Object.getOwnPropertyDescriptors(context);
|
|
87
|
-
return Object.create(Object.getPrototypeOf(context), {
|
|
88
|
-
...propertyDescriptors,
|
|
89
|
-
options: {
|
|
90
|
-
...propertyDescriptors.options,
|
|
91
|
-
value: [{
|
|
92
|
-
contexts: cntxts
|
|
93
|
-
}]
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}),
|
|
97
|
-
nonGlobalSettings: true
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
exports.buildForbidRuleDefinition = buildForbidRuleDefinition;
|
|
101
|
-
//# sourceMappingURL=buildForbidRuleDefinition.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buildForbidRuleDefinition.cjs","names":["iterateJsdoc"],"sources":["../src/buildForbidRuleDefinition.js"],"sourcesContent":["import iterateJsdoc from './iterateJsdoc.js';\n\n/**\n * @typedef {(string|{\n * comment: string,\n * context: string,\n * message?: string\n * })[]} Contexts\n */\n\n/**\n * @param {{\n * contexts?: Contexts,\n * description?: string,\n * getContexts?: (\n * ctxt: import('eslint').Rule.RuleContext,\n * report: import('./iterateJsdoc.js').Report\n * ) => Contexts|false,\n * contextName?: string,\n * modifyContext?: (context: import('eslint').Rule.RuleContext) => import('eslint').Rule.RuleContext,\n * schema?: import('eslint').Rule.RuleMetaData['schema']\n * url?: string,\n * }} cfg\n * @returns {import('eslint').Rule.RuleModule}\n */\nexport const buildForbidRuleDefinition = ({\n contextName,\n contexts: cntxts,\n description,\n getContexts,\n modifyContext,\n schema,\n url,\n}) => {\n return iterateJsdoc(({\n context,\n info: {\n comment,\n },\n report,\n utils,\n }) => {\n /** @type {Contexts|boolean|undefined} */\n let contexts = cntxts;\n\n if (getContexts) {\n contexts = getContexts(context, report);\n if (!contexts) {\n return;\n }\n }\n\n const {\n contextStr,\n foundContext,\n } = utils.findContext(/** @type {Contexts} */ (contexts), comment);\n\n // We are not on the *particular* matching context/comment, so don't assume\n // we need reporting\n if (!foundContext) {\n return;\n }\n\n const message = /** @type {import('./iterateJsdoc.js').ContextObject} */ (\n foundContext\n )?.message ??\n 'Syntax is restricted: {{context}}' +\n (comment ? ' with {{comment}}' : '');\n\n report(message, null, null, comment ? {\n comment,\n context: contextStr,\n } : {\n context: contextStr,\n });\n }, {\n contextSelected: true,\n meta: {\n docs: {\n description: description ?? contextName ?? 'Reports when certain comment structures are present.',\n url: url ?? 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/advanced.md#user-content-advanced-creating-your-own-rules',\n },\n schema: schema ?? [],\n type: 'suggestion',\n },\n modifyContext: modifyContext ?? (getContexts ? undefined : (context) => {\n // Reproduce context object with our own `contexts`\n const propertyDescriptors = Object.getOwnPropertyDescriptors(context);\n return Object.create(\n Object.getPrototypeOf(context),\n {\n ...propertyDescriptors,\n options: {\n ...propertyDescriptors.options,\n value: [\n {\n contexts: cntxts,\n },\n ],\n },\n },\n );\n }),\n nonGlobalSettings: true,\n });\n};\n"],"mappings":";;;;;;AAAA;AAA6C;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,yBAAyB,GAAG,CAAC;EACxC,WAAW;EACX,QAAQ,EAAE,MAAM;EAChB,WAAW;EACX,WAAW;EACX,aAAa;EACb,MAAM;EACN;AACF,CAAC,KAAK;EACJ,OAAO,IAAAA,qBAAY,EAAC,CAAC;IACnB,OAAO;IACP,IAAI,EAAE;MACJ;IACF,CAAC;IACD,MAAM;IACN;EACF,CAAC,KAAK;IACJ;IACA,IAAI,QAAQ,GAAG,MAAM;IAErB,IAAI,WAAW,EAAE;MACf,QAAQ,GAAG,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC;MACvC,IAAI,CAAC,QAAQ,EAAE;QACb;MACF;IACF;IAEA,MAAM;MACJ,UAAU;MACV;IACF,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,uBAAyB,QAAQ,EAAG,OAAO,CAAC;;IAElE;IACA;IACA,IAAI,CAAC,YAAY,EAAE;MACjB;IACF;IAEA,MAAM,OAAO,GAAG,wDACd,YAAY,EACX,OAAO,IACR,mCAAmC,IAChC,OAAO,GAAG,mBAAmB,GAAG,EAAE,CAAC;IAExC,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,GAAG;MACpC,O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