eslint-plugin-jsdoc 55.4.0 → 56.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/cjs/WarnSettings.d.ts +16 -0
- package/dist/cjs/WarnSettings.js +30 -0
- package/dist/cjs/alignTransform.d.ts +33 -0
- package/dist/cjs/alignTransform.js +285 -0
- package/dist/cjs/defaultTagOrder.d.ts +4 -0
- package/dist/cjs/defaultTagOrder.js +152 -0
- package/dist/cjs/exportParser.d.ts +40 -0
- package/dist/cjs/exportParser.js +754 -0
- package/dist/cjs/getDefaultTagStructureForMode.d.ts +10 -0
- package/dist/cjs/getDefaultTagStructureForMode.js +840 -0
- package/dist/cjs/getJsdocProcessorPlugin.cjs +4 -0
- package/dist/cjs/getJsdocProcessorPlugin.d.cts +1 -0
- package/dist/cjs/getJsdocProcessorPlugin.d.ts +66 -0
- package/dist/cjs/getJsdocProcessorPlugin.js +553 -0
- package/dist/cjs/index-cjs.d.ts +16 -0
- package/dist/cjs/index-cjs.js +492 -0
- package/dist/cjs/index.cjs.cjs +6 -0
- package/dist/cjs/index.cjs.d.cts +2 -0
- package/dist/cjs/iterateJsdoc.cjs +38 -0
- package/dist/cjs/iterateJsdoc.d.cts +2 -0
- package/dist/cjs/iterateJsdoc.d.ts +462 -0
- package/dist/cjs/iterateJsdoc.js +1981 -0
- package/dist/cjs/jsdocUtils.d.ts +454 -0
- package/dist/cjs/jsdocUtils.js +1470 -0
- package/dist/cjs/rules/checkAccess.d.ts +2 -0
- package/dist/cjs/rules/checkAccess.js +35 -0
- package/dist/cjs/rules/checkAlignment.d.ts +2 -0
- package/dist/cjs/rules/checkAlignment.js +63 -0
- package/dist/cjs/rules/checkExamples.d.ts +3 -0
- package/dist/cjs/rules/checkExamples.js +486 -0
- package/dist/cjs/rules/checkIndentation.d.ts +2 -0
- package/dist/cjs/rules/checkIndentation.js +66 -0
- package/dist/cjs/rules/checkLineAlignment.d.ts +9 -0
- package/dist/cjs/rules/checkLineAlignment.js +297 -0
- package/dist/cjs/rules/checkParamNames.d.ts +2 -0
- package/dist/cjs/rules/checkParamNames.js +320 -0
- package/dist/cjs/rules/checkPropertyNames.d.ts +2 -0
- package/dist/cjs/rules/checkPropertyNames.js +105 -0
- package/dist/cjs/rules/checkSyntax.d.ts +2 -0
- package/dist/cjs/rules/checkSyntax.js +27 -0
- package/dist/cjs/rules/checkTagNames.d.ts +2 -0
- package/dist/cjs/rules/checkTagNames.js +252 -0
- package/dist/cjs/rules/checkTemplateNames.d.ts +2 -0
- package/dist/cjs/rules/checkTemplateNames.js +189 -0
- package/dist/cjs/rules/checkTypes.d.ts +2 -0
- package/dist/cjs/rules/checkTypes.js +421 -0
- package/dist/cjs/rules/checkValues.d.ts +2 -0
- package/dist/cjs/rules/checkValues.js +163 -0
- package/dist/cjs/rules/convertToJsdocComments.d.ts +251 -0
- package/dist/cjs/rules/convertToJsdocComments.js +313 -0
- package/dist/cjs/rules/emptyTags.d.ts +2 -0
- package/dist/cjs/rules/emptyTags.js +79 -0
- package/dist/cjs/rules/implementsOnClasses.d.ts +2 -0
- package/dist/cjs/rules/implementsOnClasses.js +63 -0
- package/dist/cjs/rules/importsAsDependencies.d.ts +2 -0
- package/dist/cjs/rules/importsAsDependencies.js +105 -0
- package/dist/cjs/rules/informativeDocs.d.ts +2 -0
- package/dist/cjs/rules/informativeDocs.js +153 -0
- package/dist/cjs/rules/linesBeforeBlock.d.ts +2 -0
- package/dist/cjs/rules/linesBeforeBlock.js +106 -0
- package/dist/cjs/rules/matchDescription.d.ts +2 -0
- package/dist/cjs/rules/matchDescription.js +240 -0
- package/dist/cjs/rules/matchName.d.ts +2 -0
- package/dist/cjs/rules/matchName.js +122 -0
- package/dist/cjs/rules/multilineBlocks.d.ts +2 -0
- package/dist/cjs/rules/multilineBlocks.js +339 -0
- package/dist/cjs/rules/noBadBlocks.d.ts +2 -0
- package/dist/cjs/rules/noBadBlocks.js +88 -0
- package/dist/cjs/rules/noBlankBlockDescriptions.d.ts +2 -0
- package/dist/cjs/rules/noBlankBlockDescriptions.js +56 -0
- package/dist/cjs/rules/noBlankBlocks.d.ts +2 -0
- package/dist/cjs/rules/noBlankBlocks.js +41 -0
- package/dist/cjs/rules/noDefaults.d.ts +2 -0
- package/dist/cjs/rules/noDefaults.js +84 -0
- package/dist/cjs/rules/noMissingSyntax.d.ts +9 -0
- package/dist/cjs/rules/noMissingSyntax.js +164 -0
- package/dist/cjs/rules/noMultiAsterisks.d.ts +2 -0
- package/dist/cjs/rules/noMultiAsterisks.js +83 -0
- package/dist/cjs/rules/noRestrictedSyntax.d.ts +2 -0
- package/dist/cjs/rules/noRestrictedSyntax.js +75 -0
- package/dist/cjs/rules/noTypes.d.ts +2 -0
- package/dist/cjs/rules/noTypes.js +88 -0
- package/dist/cjs/rules/noUndefinedTypes.d.ts +2 -0
- package/dist/cjs/rules/noUndefinedTypes.js +451 -0
- package/dist/cjs/rules/requireAsteriskPrefix.d.ts +2 -0
- package/dist/cjs/rules/requireAsteriskPrefix.js +144 -0
- package/dist/cjs/rules/requireDescription.d.ts +2 -0
- package/dist/cjs/rules/requireDescription.js +136 -0
- package/dist/cjs/rules/requireDescriptionCompleteSentence.d.ts +2 -0
- package/dist/cjs/rules/requireDescriptionCompleteSentence.js +258 -0
- package/dist/cjs/rules/requireExample.d.ts +2 -0
- package/dist/cjs/rules/requireExample.js +103 -0
- package/dist/cjs/rules/requireFileOverview.d.ts +2 -0
- package/dist/cjs/rules/requireFileOverview.js +117 -0
- package/dist/cjs/rules/requireHyphenBeforeParamDescription.d.ts +2 -0
- package/dist/cjs/rules/requireHyphenBeforeParamDescription.js +144 -0
- package/dist/cjs/rules/requireJsdoc.d.ts +25 -0
- package/dist/cjs/rules/requireJsdoc.js +629 -0
- package/dist/cjs/rules/requireParam.d.ts +3 -0
- package/dist/cjs/rules/requireParam.js +480 -0
- package/dist/cjs/rules/requireParamDescription.d.ts +2 -0
- package/dist/cjs/rules/requireParamDescription.js +77 -0
- package/dist/cjs/rules/requireParamName.d.ts +2 -0
- package/dist/cjs/rules/requireParamName.js +52 -0
- package/dist/cjs/rules/requireParamType.d.ts +2 -0
- package/dist/cjs/rules/requireParamType.js +77 -0
- package/dist/cjs/rules/requireProperty.d.ts +2 -0
- package/dist/cjs/rules/requireProperty.js +44 -0
- package/dist/cjs/rules/requirePropertyDescription.d.ts +2 -0
- package/dist/cjs/rules/requirePropertyDescription.js +22 -0
- package/dist/cjs/rules/requirePropertyName.d.ts +2 -0
- package/dist/cjs/rules/requirePropertyName.js +22 -0
- package/dist/cjs/rules/requirePropertyType.d.ts +2 -0
- package/dist/cjs/rules/requirePropertyType.js +22 -0
- package/dist/cjs/rules/requireReturns.d.ts +2 -0
- package/dist/cjs/rules/requireReturns.js +197 -0
- package/dist/cjs/rules/requireReturnsCheck.d.ts +2 -0
- package/dist/cjs/rules/requireReturnsCheck.js +108 -0
- package/dist/cjs/rules/requireReturnsDescription.d.ts +2 -0
- package/dist/cjs/rules/requireReturnsDescription.js +58 -0
- package/dist/cjs/rules/requireReturnsType.d.ts +2 -0
- package/dist/cjs/rules/requireReturnsType.js +52 -0
- package/dist/cjs/rules/requireTemplate.d.ts +2 -0
- package/dist/cjs/rules/requireTemplate.js +173 -0
- package/dist/cjs/rules/requireThrows.d.ts +2 -0
- package/dist/cjs/rules/requireThrows.js +101 -0
- package/dist/cjs/rules/requireYields.d.ts +2 -0
- package/dist/cjs/rules/requireYields.js +172 -0
- package/dist/cjs/rules/requireYieldsCheck.d.ts +2 -0
- package/dist/cjs/rules/requireYieldsCheck.js +164 -0
- package/dist/cjs/rules/sortTags.d.ts +2 -0
- package/dist/cjs/rules/sortTags.js +392 -0
- package/dist/cjs/rules/tagLines.d.ts +2 -0
- package/dist/cjs/rules/tagLines.js +259 -0
- package/dist/cjs/rules/textEscaping.d.ts +2 -0
- package/dist/cjs/rules/textEscaping.js +125 -0
- package/dist/cjs/rules/typeFormatting.d.ts +2 -0
- package/dist/cjs/rules/typeFormatting.js +328 -0
- package/dist/cjs/rules/validTypes.d.ts +2 -0
- package/dist/cjs/rules/validTypes.js +333 -0
- package/dist/cjs/tagNames.d.ts +15 -0
- package/dist/cjs/tagNames.js +209 -0
- package/dist/cjs/utils/hasReturnValue.d.ts +19 -0
- package/dist/cjs/utils/hasReturnValue.js +469 -0
- package/dist/getJsdocProcessorPlugin.cts +3 -0
- package/dist/index.cjs.cts +3 -0
- package/dist/iterateJsdoc.cts +6 -0
- package/package.json +21 -10
- package/src/getJsdocProcessorPlugin.cts +3 -0
- package/src/index.cjs.cts +3 -0
- package/src/iterateJsdoc.cts +6 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default WarnSettings;
|
|
2
|
+
declare function WarnSettings(): {
|
|
3
|
+
/**
|
|
4
|
+
* Warn only once for each context and setting
|
|
5
|
+
* @param {{}} context
|
|
6
|
+
* @param {string} setting
|
|
7
|
+
* @returns {boolean}
|
|
8
|
+
*/
|
|
9
|
+
hasBeenWarned(context: {}, setting: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* @param {{}} context
|
|
12
|
+
* @param {string} setting
|
|
13
|
+
* @returns {void}
|
|
14
|
+
*/
|
|
15
|
+
markSettingAsWarned(context: {}, setting: string): void;
|
|
16
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const WarnSettings = function () {
|
|
4
|
+
/** @type {WeakMap<object, Set<string>>} */
|
|
5
|
+
const warnedSettings = new WeakMap();
|
|
6
|
+
return {
|
|
7
|
+
/**
|
|
8
|
+
* Warn only once for each context and setting
|
|
9
|
+
* @param {{}} context
|
|
10
|
+
* @param {string} setting
|
|
11
|
+
* @returns {boolean}
|
|
12
|
+
*/
|
|
13
|
+
hasBeenWarned(context, setting) {
|
|
14
|
+
return warnedSettings.has(context) && /** @type {Set<string>} */ (warnedSettings.get(context)).has(setting);
|
|
15
|
+
},
|
|
16
|
+
/**
|
|
17
|
+
* @param {{}} context
|
|
18
|
+
* @param {string} setting
|
|
19
|
+
* @returns {void}
|
|
20
|
+
*/
|
|
21
|
+
markSettingAsWarned(context, setting) {
|
|
22
|
+
// c8 ignore else
|
|
23
|
+
if (!warnedSettings.has(context)) {
|
|
24
|
+
warnedSettings.set(context, new Set());
|
|
25
|
+
}
|
|
26
|
+
/** @type {Set<string>} */ (warnedSettings.get(context)).add(setting);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
exports.default = WarnSettings;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export default alignTransform;
|
|
2
|
+
export type TypelessInfo = {
|
|
3
|
+
hasNoTypes: boolean;
|
|
4
|
+
maxNamedTagLength: import("./iterateJsdoc.js").Integer;
|
|
5
|
+
maxUnnamedTagLength: import("./iterateJsdoc.js").Integer;
|
|
6
|
+
};
|
|
7
|
+
export type Width = {
|
|
8
|
+
name: import("./iterateJsdoc.js").Integer;
|
|
9
|
+
start: import("./iterateJsdoc.js").Integer;
|
|
10
|
+
tag: import("./iterateJsdoc.js").Integer;
|
|
11
|
+
type: import("./iterateJsdoc.js").Integer;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* @param {{
|
|
15
|
+
* customSpacings: import('../src/rules/checkLineAlignment.js').CustomSpacings,
|
|
16
|
+
* tags: string[],
|
|
17
|
+
* indent: string,
|
|
18
|
+
* preserveMainDescriptionPostDelimiter: boolean,
|
|
19
|
+
* wrapIndent: string,
|
|
20
|
+
* disableWrapIndent: boolean,
|
|
21
|
+
* }} cfg
|
|
22
|
+
* @returns {(
|
|
23
|
+
* block: import('comment-parser').Block
|
|
24
|
+
* ) => import('comment-parser').Block}
|
|
25
|
+
*/
|
|
26
|
+
declare function alignTransform({ customSpacings, disableWrapIndent, indent, preserveMainDescriptionPostDelimiter, tags, wrapIndent, }: {
|
|
27
|
+
customSpacings: import("../src/rules/checkLineAlignment.js").CustomSpacings;
|
|
28
|
+
tags: string[];
|
|
29
|
+
indent: string;
|
|
30
|
+
preserveMainDescriptionPostDelimiter: boolean;
|
|
31
|
+
wrapIndent: string;
|
|
32
|
+
disableWrapIndent: boolean;
|
|
33
|
+
}): (block: import("comment-parser").Block) => import("comment-parser").Block;
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Transform based on https://github.com/syavorsky/comment-parser/blob/master/src/transforms/align.ts
|
|
4
|
+
*
|
|
5
|
+
* It contains some customizations to align based on the tags, and some custom options.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const comment_parser_1 = require("comment-parser");
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {{
|
|
11
|
+
* hasNoTypes: boolean,
|
|
12
|
+
* maxNamedTagLength: import('./iterateJsdoc.js').Integer,
|
|
13
|
+
* maxUnnamedTagLength: import('./iterateJsdoc.js').Integer
|
|
14
|
+
* }} TypelessInfo
|
|
15
|
+
*/
|
|
16
|
+
const { rewireSource, } = comment_parser_1.util;
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {{
|
|
19
|
+
* name: import('./iterateJsdoc.js').Integer,
|
|
20
|
+
* start: import('./iterateJsdoc.js').Integer,
|
|
21
|
+
* tag: import('./iterateJsdoc.js').Integer,
|
|
22
|
+
* type: import('./iterateJsdoc.js').Integer
|
|
23
|
+
* }} Width
|
|
24
|
+
*/
|
|
25
|
+
/** @type {Width} */
|
|
26
|
+
const zeroWidth = {
|
|
27
|
+
name: 0,
|
|
28
|
+
start: 0,
|
|
29
|
+
tag: 0,
|
|
30
|
+
type: 0,
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* @param {string[]} tags
|
|
34
|
+
* @param {import('./iterateJsdoc.js').Integer} index
|
|
35
|
+
* @param {import('comment-parser').Line[]} source
|
|
36
|
+
* @returns {boolean}
|
|
37
|
+
*/
|
|
38
|
+
const shouldAlign = (tags, index, source) => {
|
|
39
|
+
const tag = source[index].tokens.tag.replace('@', '');
|
|
40
|
+
const includesTag = tags.includes(tag);
|
|
41
|
+
if (includesTag) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
if (tag !== '') {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
for (let iterator = index; iterator >= 0; iterator--) {
|
|
48
|
+
const previousTag = source[iterator].tokens.tag.replace('@', '');
|
|
49
|
+
if (previousTag !== '') {
|
|
50
|
+
if (tags.includes(previousTag)) {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* @param {string[]} tags
|
|
60
|
+
* @returns {(
|
|
61
|
+
* width: Width,
|
|
62
|
+
* line: {
|
|
63
|
+
* tokens: import('comment-parser').Tokens
|
|
64
|
+
* },
|
|
65
|
+
* index: import('./iterateJsdoc.js').Integer,
|
|
66
|
+
* source: import('comment-parser').Line[]
|
|
67
|
+
* ) => Width}
|
|
68
|
+
*/
|
|
69
|
+
const getWidth = (tags) => {
|
|
70
|
+
return (width, { tokens, }, index, source) => {
|
|
71
|
+
if (!shouldAlign(tags, index, source)) {
|
|
72
|
+
return width;
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
name: Math.max(width.name, tokens.name.length),
|
|
76
|
+
start: tokens.delimiter === '/**' ? tokens.start.length : width.start,
|
|
77
|
+
tag: Math.max(width.tag, tokens.tag.length),
|
|
78
|
+
type: Math.max(width.type, tokens.type.length),
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* @param {{
|
|
84
|
+
* description: string;
|
|
85
|
+
* tags: import('comment-parser').Spec[];
|
|
86
|
+
* problems: import('comment-parser').Problem[];
|
|
87
|
+
* }} fields
|
|
88
|
+
* @returns {TypelessInfo}
|
|
89
|
+
*/
|
|
90
|
+
const getTypelessInfo = (fields) => {
|
|
91
|
+
const hasNoTypes = fields.tags.every(({ type, }) => {
|
|
92
|
+
return !type;
|
|
93
|
+
});
|
|
94
|
+
const maxNamedTagLength = Math.max(...fields.tags.map(({ name, tag, }) => {
|
|
95
|
+
return name.length === 0 ? -1 : tag.length;
|
|
96
|
+
}).filter((length) => {
|
|
97
|
+
return length !== -1;
|
|
98
|
+
})) + 1;
|
|
99
|
+
const maxUnnamedTagLength = Math.max(...fields.tags.map(({ name, tag, }) => {
|
|
100
|
+
return name.length === 0 ? tag.length : -1;
|
|
101
|
+
}).filter((length) => {
|
|
102
|
+
return length !== -1;
|
|
103
|
+
})) + 1;
|
|
104
|
+
return {
|
|
105
|
+
hasNoTypes,
|
|
106
|
+
maxNamedTagLength,
|
|
107
|
+
maxUnnamedTagLength,
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* @param {import('./iterateJsdoc.js').Integer} len
|
|
112
|
+
* @returns {string}
|
|
113
|
+
*/
|
|
114
|
+
const space = (len) => {
|
|
115
|
+
return ''.padStart(len, ' ');
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* @param {{
|
|
119
|
+
* customSpacings: import('../src/rules/checkLineAlignment.js').CustomSpacings,
|
|
120
|
+
* tags: string[],
|
|
121
|
+
* indent: string,
|
|
122
|
+
* preserveMainDescriptionPostDelimiter: boolean,
|
|
123
|
+
* wrapIndent: string,
|
|
124
|
+
* disableWrapIndent: boolean,
|
|
125
|
+
* }} cfg
|
|
126
|
+
* @returns {(
|
|
127
|
+
* block: import('comment-parser').Block
|
|
128
|
+
* ) => import('comment-parser').Block}
|
|
129
|
+
*/
|
|
130
|
+
const alignTransform = ({ customSpacings, disableWrapIndent, indent, preserveMainDescriptionPostDelimiter, tags, wrapIndent, }) => {
|
|
131
|
+
let intoTags = false;
|
|
132
|
+
/** @type {Width} */
|
|
133
|
+
let width;
|
|
134
|
+
/**
|
|
135
|
+
* @param {import('comment-parser').Tokens} tokens
|
|
136
|
+
* @param {TypelessInfo} typelessInfo
|
|
137
|
+
* @returns {import('comment-parser').Tokens}
|
|
138
|
+
*/
|
|
139
|
+
const alignTokens = (tokens, typelessInfo) => {
|
|
140
|
+
const nothingAfter = {
|
|
141
|
+
delim: false,
|
|
142
|
+
name: false,
|
|
143
|
+
tag: false,
|
|
144
|
+
type: false,
|
|
145
|
+
};
|
|
146
|
+
if (tokens.description === '') {
|
|
147
|
+
nothingAfter.name = true;
|
|
148
|
+
tokens.postName = '';
|
|
149
|
+
if (tokens.name === '') {
|
|
150
|
+
nothingAfter.type = true;
|
|
151
|
+
tokens.postType = '';
|
|
152
|
+
if (tokens.type === '') {
|
|
153
|
+
nothingAfter.tag = true;
|
|
154
|
+
tokens.postTag = '';
|
|
155
|
+
/* c8 ignore next: Never happens because the !intoTags return. But it's here for consistency with the original align transform */
|
|
156
|
+
if (tokens.tag === '') {
|
|
157
|
+
nothingAfter.delim = true;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
let untypedNameAdjustment = 0;
|
|
163
|
+
let untypedTypeAdjustment = 0;
|
|
164
|
+
if (typelessInfo.hasNoTypes) {
|
|
165
|
+
nothingAfter.tag = true;
|
|
166
|
+
tokens.postTag = '';
|
|
167
|
+
if (tokens.name === '') {
|
|
168
|
+
untypedNameAdjustment = typelessInfo.maxNamedTagLength - tokens.tag.length;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
untypedNameAdjustment = typelessInfo.maxNamedTagLength > typelessInfo.maxUnnamedTagLength ? 0 :
|
|
172
|
+
Math.max(0, typelessInfo.maxUnnamedTagLength - (tokens.tag.length + tokens.name.length + 1));
|
|
173
|
+
untypedTypeAdjustment = typelessInfo.maxNamedTagLength - tokens.tag.length;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// Todo: Avoid fixing alignment of blocks with multiline wrapping of type
|
|
177
|
+
if (tokens.tag === '' && tokens.type) {
|
|
178
|
+
return tokens;
|
|
179
|
+
}
|
|
180
|
+
const spacings = {
|
|
181
|
+
postDelimiter: customSpacings?.postDelimiter || 1,
|
|
182
|
+
postName: customSpacings?.postName || 1,
|
|
183
|
+
postTag: customSpacings?.postTag || 1,
|
|
184
|
+
postType: customSpacings?.postType || 1,
|
|
185
|
+
};
|
|
186
|
+
tokens.postDelimiter = nothingAfter.delim ? '' : space(spacings.postDelimiter);
|
|
187
|
+
if (!nothingAfter.tag) {
|
|
188
|
+
tokens.postTag = space(width.tag - tokens.tag.length + spacings.postTag);
|
|
189
|
+
}
|
|
190
|
+
if (!nothingAfter.type) {
|
|
191
|
+
tokens.postType = space(width.type - tokens.type.length + spacings.postType + untypedTypeAdjustment);
|
|
192
|
+
}
|
|
193
|
+
if (!nothingAfter.name) {
|
|
194
|
+
// If post name is empty for all lines (name width 0), don't add post name spacing.
|
|
195
|
+
tokens.postName = width.name === 0 ? '' : space(width.name - tokens.name.length + spacings.postName + untypedNameAdjustment);
|
|
196
|
+
}
|
|
197
|
+
return tokens;
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* @param {import('comment-parser').Line} line
|
|
201
|
+
* @param {import('./iterateJsdoc.js').Integer} index
|
|
202
|
+
* @param {import('comment-parser').Line[]} source
|
|
203
|
+
* @param {TypelessInfo} typelessInfo
|
|
204
|
+
* @param {string|false} indentTag
|
|
205
|
+
* @returns {import('comment-parser').Line}
|
|
206
|
+
*/
|
|
207
|
+
const update = (line, index, source, typelessInfo, indentTag) => {
|
|
208
|
+
/** @type {import('comment-parser').Tokens} */
|
|
209
|
+
const tokens = {
|
|
210
|
+
...line.tokens,
|
|
211
|
+
};
|
|
212
|
+
if (tokens.tag !== '') {
|
|
213
|
+
intoTags = true;
|
|
214
|
+
}
|
|
215
|
+
const isEmpty = tokens.tag === '' &&
|
|
216
|
+
tokens.name === '' &&
|
|
217
|
+
tokens.type === '' &&
|
|
218
|
+
tokens.description === '';
|
|
219
|
+
// dangling '*/'
|
|
220
|
+
if (tokens.end === '*/' && isEmpty) {
|
|
221
|
+
tokens.start = indent + ' ';
|
|
222
|
+
return {
|
|
223
|
+
...line,
|
|
224
|
+
tokens,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
switch (tokens.delimiter) {
|
|
228
|
+
case '*':
|
|
229
|
+
tokens.start = indent + ' ';
|
|
230
|
+
break;
|
|
231
|
+
case '/**':
|
|
232
|
+
tokens.start = indent;
|
|
233
|
+
break;
|
|
234
|
+
default:
|
|
235
|
+
tokens.delimiter = '';
|
|
236
|
+
// compensate delimiter
|
|
237
|
+
tokens.start = indent + ' ';
|
|
238
|
+
}
|
|
239
|
+
if (!intoTags) {
|
|
240
|
+
if (tokens.description === '') {
|
|
241
|
+
tokens.postDelimiter = '';
|
|
242
|
+
}
|
|
243
|
+
else if (!preserveMainDescriptionPostDelimiter) {
|
|
244
|
+
tokens.postDelimiter = ' ';
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
...line,
|
|
248
|
+
tokens,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
const postHyphenSpacing = customSpacings?.postHyphen ?? 1;
|
|
252
|
+
const hyphenSpacing = /^\s*-\s+/v;
|
|
253
|
+
tokens.description = tokens.description.replace(hyphenSpacing, '-' + ''.padStart(postHyphenSpacing, ' '));
|
|
254
|
+
// Not align.
|
|
255
|
+
if (shouldAlign(tags, index, source)) {
|
|
256
|
+
alignTokens(tokens, typelessInfo);
|
|
257
|
+
if (!disableWrapIndent && indentTag) {
|
|
258
|
+
tokens.postDelimiter += wrapIndent;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
...line,
|
|
263
|
+
tokens,
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
return ({ source, ...fields }) => {
|
|
267
|
+
width = source.reduce(getWidth(tags), {
|
|
268
|
+
...zeroWidth,
|
|
269
|
+
});
|
|
270
|
+
const typelessInfo = getTypelessInfo(fields);
|
|
271
|
+
let tagIndentMode = false;
|
|
272
|
+
return rewireSource({
|
|
273
|
+
...fields,
|
|
274
|
+
source: source.map((line, index) => {
|
|
275
|
+
const indentTag = !disableWrapIndent && tagIndentMode && !line.tokens.tag && line.tokens.description;
|
|
276
|
+
const ret = update(line, index, source, typelessInfo, indentTag);
|
|
277
|
+
if (!disableWrapIndent && line.tokens.tag) {
|
|
278
|
+
tagIndentMode = true;
|
|
279
|
+
}
|
|
280
|
+
return ret;
|
|
281
|
+
}),
|
|
282
|
+
});
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
exports.default = alignTransform;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const defaultTagOrder = [
|
|
4
|
+
{
|
|
5
|
+
tags: [
|
|
6
|
+
// Brief descriptions
|
|
7
|
+
'summary',
|
|
8
|
+
'typeSummary',
|
|
9
|
+
// Module/file-level
|
|
10
|
+
'module',
|
|
11
|
+
'exports',
|
|
12
|
+
'file',
|
|
13
|
+
'fileoverview',
|
|
14
|
+
'overview',
|
|
15
|
+
'import',
|
|
16
|
+
// Identifying (name, type)
|
|
17
|
+
'template',
|
|
18
|
+
'typedef',
|
|
19
|
+
'interface',
|
|
20
|
+
'record',
|
|
21
|
+
'name',
|
|
22
|
+
'kind',
|
|
23
|
+
'type',
|
|
24
|
+
'alias',
|
|
25
|
+
'external',
|
|
26
|
+
'host',
|
|
27
|
+
'callback',
|
|
28
|
+
'func',
|
|
29
|
+
'function',
|
|
30
|
+
'method',
|
|
31
|
+
'class',
|
|
32
|
+
'constructor',
|
|
33
|
+
// Relationships
|
|
34
|
+
'modifies',
|
|
35
|
+
'mixes',
|
|
36
|
+
'mixin',
|
|
37
|
+
'mixinClass',
|
|
38
|
+
'mixinFunction',
|
|
39
|
+
'namespace',
|
|
40
|
+
'borrows',
|
|
41
|
+
'constructs',
|
|
42
|
+
'lends',
|
|
43
|
+
'implements',
|
|
44
|
+
'requires',
|
|
45
|
+
// Long descriptions
|
|
46
|
+
'desc',
|
|
47
|
+
'description',
|
|
48
|
+
'classdesc',
|
|
49
|
+
'tutorial',
|
|
50
|
+
'copyright',
|
|
51
|
+
'license',
|
|
52
|
+
// Simple annotations
|
|
53
|
+
// TypeScript
|
|
54
|
+
'internal',
|
|
55
|
+
'overload',
|
|
56
|
+
'const',
|
|
57
|
+
'constant',
|
|
58
|
+
'final',
|
|
59
|
+
'global',
|
|
60
|
+
'readonly',
|
|
61
|
+
'abstract',
|
|
62
|
+
'virtual',
|
|
63
|
+
'var',
|
|
64
|
+
'member',
|
|
65
|
+
'memberof',
|
|
66
|
+
'memberof!',
|
|
67
|
+
'inner',
|
|
68
|
+
'instance',
|
|
69
|
+
'inheritdoc',
|
|
70
|
+
'inheritDoc',
|
|
71
|
+
'override',
|
|
72
|
+
'hideconstructor',
|
|
73
|
+
// Core function/object info
|
|
74
|
+
'param',
|
|
75
|
+
'arg',
|
|
76
|
+
'argument',
|
|
77
|
+
'prop',
|
|
78
|
+
'property',
|
|
79
|
+
'return',
|
|
80
|
+
'returns',
|
|
81
|
+
// Important behavior details
|
|
82
|
+
'async',
|
|
83
|
+
'generator',
|
|
84
|
+
'default',
|
|
85
|
+
'defaultvalue',
|
|
86
|
+
'enum',
|
|
87
|
+
'augments',
|
|
88
|
+
'extends',
|
|
89
|
+
'throws',
|
|
90
|
+
'exception',
|
|
91
|
+
'yield',
|
|
92
|
+
'yields',
|
|
93
|
+
'event',
|
|
94
|
+
'fires',
|
|
95
|
+
'emits',
|
|
96
|
+
'listens',
|
|
97
|
+
'this',
|
|
98
|
+
// TypeScript
|
|
99
|
+
'satisfies',
|
|
100
|
+
// Access
|
|
101
|
+
'static',
|
|
102
|
+
'private',
|
|
103
|
+
'protected',
|
|
104
|
+
'public',
|
|
105
|
+
'access',
|
|
106
|
+
'package',
|
|
107
|
+
'-other',
|
|
108
|
+
// Supplementary descriptions
|
|
109
|
+
'see',
|
|
110
|
+
'example',
|
|
111
|
+
// METADATA
|
|
112
|
+
// Other Closure (undocumented) metadata
|
|
113
|
+
'closurePrimitive',
|
|
114
|
+
'customElement',
|
|
115
|
+
'expose',
|
|
116
|
+
'hidden',
|
|
117
|
+
'idGenerator',
|
|
118
|
+
'meaning',
|
|
119
|
+
'ngInject',
|
|
120
|
+
'owner',
|
|
121
|
+
'wizaction',
|
|
122
|
+
// Other Closure (documented) metadata
|
|
123
|
+
'define',
|
|
124
|
+
'dict',
|
|
125
|
+
'export',
|
|
126
|
+
'externs',
|
|
127
|
+
'implicitCast',
|
|
128
|
+
'noalias',
|
|
129
|
+
'nocollapse',
|
|
130
|
+
'nocompile',
|
|
131
|
+
'noinline',
|
|
132
|
+
'nosideeffects',
|
|
133
|
+
'polymer',
|
|
134
|
+
'polymerBehavior',
|
|
135
|
+
'preserve',
|
|
136
|
+
'struct',
|
|
137
|
+
'suppress',
|
|
138
|
+
'unrestricted',
|
|
139
|
+
// @homer0/prettier-plugin-jsdoc metadata
|
|
140
|
+
'category',
|
|
141
|
+
// Non-Closure metadata
|
|
142
|
+
'ignore',
|
|
143
|
+
'author',
|
|
144
|
+
'version',
|
|
145
|
+
'variation',
|
|
146
|
+
'since',
|
|
147
|
+
'deprecated',
|
|
148
|
+
'todo',
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
];
|
|
152
|
+
exports.default = defaultTagOrder;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
export { isUncommentedExport };
|
|
3
|
+
export { parse };
|
|
4
|
+
}
|
|
5
|
+
export default _default;
|
|
6
|
+
export type ValueObject = {
|
|
7
|
+
value: string;
|
|
8
|
+
};
|
|
9
|
+
export type CreatedNode = {
|
|
10
|
+
type?: string;
|
|
11
|
+
value?: ValueObject | import("eslint").Rule.Node | import("@typescript-eslint/types").TSESTree.Node;
|
|
12
|
+
props: {
|
|
13
|
+
[key: string]: CreatedNode | null;
|
|
14
|
+
};
|
|
15
|
+
special?: true;
|
|
16
|
+
globalVars?: CreatedNode;
|
|
17
|
+
exported?: boolean;
|
|
18
|
+
ANONYMOUS_DEFAULT?: import("eslint").Rule.Node;
|
|
19
|
+
};
|
|
20
|
+
export type CreateSymbol = (node: import("eslint").Rule.Node | null, globals: CreatedNode, value: import("eslint").Rule.Node | import("@typescript-eslint/types").TSESTree.Node | null, scope?: CreatedNode | undefined, isGlobal?: boolean | SymbolOptions | undefined) => CreatedNode | null;
|
|
21
|
+
export type SymbolOptions = {
|
|
22
|
+
simpleIdentifier?: boolean;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @param {import('eslint').Rule.Node} node
|
|
27
|
+
* @param {import('eslint').SourceCode} sourceCode
|
|
28
|
+
* @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opt
|
|
29
|
+
* @param {import('./iterateJsdoc.js').Settings} settings
|
|
30
|
+
* @returns {boolean}
|
|
31
|
+
*/
|
|
32
|
+
declare function isUncommentedExport(node: import("eslint").Rule.Node, sourceCode: import("eslint").SourceCode, opt: import("./rules/requireJsdoc.js").RequireJsdocOpts, settings: import("./iterateJsdoc.js").Settings): boolean;
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @param {import('eslint').Rule.Node} ast
|
|
36
|
+
* @param {import('eslint').Rule.Node} node
|
|
37
|
+
* @param {import('./rules/requireJsdoc.js').RequireJsdocOpts} opt
|
|
38
|
+
* @returns {CreatedNode}
|
|
39
|
+
*/
|
|
40
|
+
declare function parse(ast: import("eslint").Rule.Node, node: import("eslint").Rule.Node, opt: import("./rules/requireJsdoc.js").RequireJsdocOpts): CreatedNode;
|