eslint-plugin-jsdoc 56.0.0 → 56.0.2
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/getJsdocProcessorPlugin.d.cts +5 -1
- package/dist/cjs/iterateJsdoc.d.cts +6 -2
- package/dist/getJsdocProcessorPlugin.cts +3 -1
- package/dist/iterateJsdoc.cts +9 -4
- package/package.json +4 -4
- package/src/getJsdocProcessorPlugin.cts +3 -1
- package/src/iterateJsdoc.cts +9 -4
- package/dist/cjs/WarnSettings.js +0 -30
- package/dist/cjs/alignTransform.js +0 -285
- package/dist/cjs/defaultTagOrder.js +0 -152
- package/dist/cjs/exportParser.js +0 -754
- package/dist/cjs/getDefaultTagStructureForMode.js +0 -840
- package/dist/cjs/getJsdocProcessorPlugin.cjs +0 -4
- package/dist/cjs/getJsdocProcessorPlugin.js +0 -553
- package/dist/cjs/index-cjs.js +0 -492
- package/dist/cjs/index.cjs.cjs +0 -6
- package/dist/cjs/iterateJsdoc.cjs +0 -38
- package/dist/cjs/iterateJsdoc.js +0 -1981
- package/dist/cjs/jsdocUtils.js +0 -1470
- package/dist/cjs/rules/checkAccess.js +0 -35
- package/dist/cjs/rules/checkAlignment.js +0 -63
- package/dist/cjs/rules/checkExamples.js +0 -486
- package/dist/cjs/rules/checkIndentation.js +0 -66
- package/dist/cjs/rules/checkLineAlignment.js +0 -297
- package/dist/cjs/rules/checkParamNames.js +0 -320
- package/dist/cjs/rules/checkPropertyNames.js +0 -105
- package/dist/cjs/rules/checkSyntax.js +0 -27
- package/dist/cjs/rules/checkTagNames.js +0 -252
- package/dist/cjs/rules/checkTemplateNames.js +0 -189
- package/dist/cjs/rules/checkTypes.js +0 -421
- package/dist/cjs/rules/checkValues.js +0 -163
- package/dist/cjs/rules/convertToJsdocComments.js +0 -313
- package/dist/cjs/rules/emptyTags.js +0 -79
- package/dist/cjs/rules/implementsOnClasses.js +0 -63
- package/dist/cjs/rules/importsAsDependencies.js +0 -105
- package/dist/cjs/rules/informativeDocs.js +0 -153
- package/dist/cjs/rules/linesBeforeBlock.js +0 -106
- package/dist/cjs/rules/matchDescription.js +0 -240
- package/dist/cjs/rules/matchName.js +0 -122
- package/dist/cjs/rules/multilineBlocks.js +0 -339
- package/dist/cjs/rules/noBadBlocks.js +0 -88
- package/dist/cjs/rules/noBlankBlockDescriptions.js +0 -56
- package/dist/cjs/rules/noBlankBlocks.js +0 -41
- package/dist/cjs/rules/noDefaults.js +0 -84
- package/dist/cjs/rules/noMissingSyntax.js +0 -164
- package/dist/cjs/rules/noMultiAsterisks.js +0 -83
- package/dist/cjs/rules/noRestrictedSyntax.js +0 -75
- package/dist/cjs/rules/noTypes.js +0 -88
- package/dist/cjs/rules/noUndefinedTypes.js +0 -451
- package/dist/cjs/rules/requireAsteriskPrefix.js +0 -144
- package/dist/cjs/rules/requireDescription.js +0 -136
- package/dist/cjs/rules/requireDescriptionCompleteSentence.js +0 -258
- package/dist/cjs/rules/requireExample.js +0 -103
- package/dist/cjs/rules/requireFileOverview.js +0 -117
- package/dist/cjs/rules/requireHyphenBeforeParamDescription.js +0 -144
- package/dist/cjs/rules/requireJsdoc.js +0 -629
- package/dist/cjs/rules/requireParam.js +0 -480
- package/dist/cjs/rules/requireParamDescription.js +0 -77
- package/dist/cjs/rules/requireParamName.js +0 -52
- package/dist/cjs/rules/requireParamType.js +0 -77
- package/dist/cjs/rules/requireProperty.js +0 -44
- package/dist/cjs/rules/requirePropertyDescription.js +0 -22
- package/dist/cjs/rules/requirePropertyName.js +0 -22
- package/dist/cjs/rules/requirePropertyType.js +0 -22
- package/dist/cjs/rules/requireReturns.js +0 -197
- package/dist/cjs/rules/requireReturnsCheck.js +0 -108
- package/dist/cjs/rules/requireReturnsDescription.js +0 -58
- package/dist/cjs/rules/requireReturnsType.js +0 -52
- package/dist/cjs/rules/requireTemplate.js +0 -173
- package/dist/cjs/rules/requireThrows.js +0 -101
- package/dist/cjs/rules/requireYields.js +0 -172
- package/dist/cjs/rules/requireYieldsCheck.js +0 -164
- package/dist/cjs/rules/sortTags.js +0 -392
- package/dist/cjs/rules/tagLines.js +0 -259
- package/dist/cjs/rules/textEscaping.js +0 -125
- package/dist/cjs/rules/typeFormatting.js +0 -328
- package/dist/cjs/rules/validTypes.js +0 -333
- package/dist/cjs/tagNames.js +0 -209
- package/dist/cjs/utils/hasReturnValue.js +0 -469
|
@@ -1,339 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const iterateJsdoc_js_1 = __importDefault(require("../iterateJsdoc.js"));
|
|
7
|
-
/**
|
|
8
|
-
* @param {import('@es-joy/jsdoccomment').JsdocBlockWithInline} jsdoc
|
|
9
|
-
* @param {import('../iterateJsdoc.js').Utils} utils
|
|
10
|
-
* @param {number} requireSingleLineUnderCount
|
|
11
|
-
*/
|
|
12
|
-
const checkForShortTags = (jsdoc, utils, requireSingleLineUnderCount) => {
|
|
13
|
-
if (!requireSingleLineUnderCount || !jsdoc.tags.length) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
let lastLineWithTag = 0;
|
|
17
|
-
let isUnderCountLimit = false;
|
|
18
|
-
let hasMultiDescOrType = false;
|
|
19
|
-
const tagLines = jsdoc.source.reduce((acc, { tokens: { delimiter, description: desc, name, postDelimiter, postName, postTag, postType, start, tag, type, }, }, idx) => {
|
|
20
|
-
if (tag.length) {
|
|
21
|
-
lastLineWithTag = idx;
|
|
22
|
-
if (start.length + delimiter.length + postDelimiter.length +
|
|
23
|
-
type.length + postType.length + name.length + postName.length +
|
|
24
|
-
tag.length + postTag.length + desc.length <
|
|
25
|
-
requireSingleLineUnderCount) {
|
|
26
|
-
isUnderCountLimit = true;
|
|
27
|
-
}
|
|
28
|
-
return acc + 1;
|
|
29
|
-
}
|
|
30
|
-
else if (desc.length || type.length) {
|
|
31
|
-
hasMultiDescOrType = true;
|
|
32
|
-
return acc;
|
|
33
|
-
}
|
|
34
|
-
return acc;
|
|
35
|
-
}, 0);
|
|
36
|
-
// Could be tagLines > 1
|
|
37
|
-
if (!hasMultiDescOrType && isUnderCountLimit && tagLines === 1) {
|
|
38
|
-
const fixer = () => {
|
|
39
|
-
const tokens = jsdoc.source[lastLineWithTag].tokens;
|
|
40
|
-
jsdoc.source = [
|
|
41
|
-
{
|
|
42
|
-
number: 0,
|
|
43
|
-
source: '',
|
|
44
|
-
tokens: utils.seedTokens({
|
|
45
|
-
delimiter: '/**',
|
|
46
|
-
description: tokens.description.trimEnd() + ' ',
|
|
47
|
-
end: '*/',
|
|
48
|
-
name: tokens.name,
|
|
49
|
-
postDelimiter: ' ',
|
|
50
|
-
postName: tokens.postName,
|
|
51
|
-
postTag: tokens.postTag,
|
|
52
|
-
postType: tokens.postType,
|
|
53
|
-
start: jsdoc.source[0].tokens.start,
|
|
54
|
-
tag: tokens.tag,
|
|
55
|
-
type: tokens.type,
|
|
56
|
-
}),
|
|
57
|
-
},
|
|
58
|
-
];
|
|
59
|
-
};
|
|
60
|
-
utils.reportJSDoc('Description is too short to be multi-line.', null, fixer);
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
return false;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* @param {import('@es-joy/jsdoccomment').JsdocBlockWithInline} jsdoc
|
|
67
|
-
* @param {import('../iterateJsdoc.js').Utils} utils
|
|
68
|
-
* @param {number} requireSingleLineUnderCount
|
|
69
|
-
*/
|
|
70
|
-
const checkForShortDescriptions = (jsdoc, utils, requireSingleLineUnderCount) => {
|
|
71
|
-
if (!requireSingleLineUnderCount || jsdoc.tags.length) {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
let lastLineWithDesc = 0;
|
|
75
|
-
let isUnderCountLimit = false;
|
|
76
|
-
const descLines = jsdoc.source.reduce((acc, { tokens: { delimiter, description: desc, postDelimiter, start, }, }, idx) => {
|
|
77
|
-
if (desc.length) {
|
|
78
|
-
lastLineWithDesc = idx;
|
|
79
|
-
if (start.length + delimiter.length + postDelimiter.length + desc.length <
|
|
80
|
-
requireSingleLineUnderCount) {
|
|
81
|
-
isUnderCountLimit = true;
|
|
82
|
-
}
|
|
83
|
-
return acc + 1;
|
|
84
|
-
}
|
|
85
|
-
return acc;
|
|
86
|
-
}, 0);
|
|
87
|
-
// Could be descLines > 1
|
|
88
|
-
if (isUnderCountLimit && descLines === 1) {
|
|
89
|
-
const fixer = () => {
|
|
90
|
-
const desc = jsdoc.source[lastLineWithDesc].tokens.description;
|
|
91
|
-
jsdoc.source = [
|
|
92
|
-
{
|
|
93
|
-
number: 0,
|
|
94
|
-
source: '',
|
|
95
|
-
tokens: utils.seedTokens({
|
|
96
|
-
delimiter: '/**',
|
|
97
|
-
description: desc.trimEnd() + ' ',
|
|
98
|
-
end: '*/',
|
|
99
|
-
postDelimiter: ' ',
|
|
100
|
-
start: jsdoc.source[0].tokens.start,
|
|
101
|
-
}),
|
|
102
|
-
},
|
|
103
|
-
];
|
|
104
|
-
};
|
|
105
|
-
utils.reportJSDoc('Description is too short to be multi-line.', null, fixer);
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
return false;
|
|
109
|
-
};
|
|
110
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ context, jsdoc, utils, }) => {
|
|
111
|
-
const { allowMultipleTags = true, minimumLengthForMultiline = Number.POSITIVE_INFINITY, multilineTags = [
|
|
112
|
-
'*',
|
|
113
|
-
], noFinalLineText = true, noMultilineBlocks = false, noSingleLineBlocks = false, noZeroLineText = true, requireSingleLineUnderCount = null, singleLineTags = [
|
|
114
|
-
'lends', 'type',
|
|
115
|
-
], } = context.options[0] || {};
|
|
116
|
-
const { source: [{ tokens, },], } = jsdoc;
|
|
117
|
-
const { description, tag, } = tokens;
|
|
118
|
-
const sourceLength = jsdoc.source.length;
|
|
119
|
-
/**
|
|
120
|
-
* @param {string} tagName
|
|
121
|
-
* @returns {boolean}
|
|
122
|
-
*/
|
|
123
|
-
const isInvalidSingleLine = (tagName) => {
|
|
124
|
-
return noSingleLineBlocks &&
|
|
125
|
-
(!tagName ||
|
|
126
|
-
!singleLineTags.includes(tagName) && !singleLineTags.includes('*'));
|
|
127
|
-
};
|
|
128
|
-
if (sourceLength === 1) {
|
|
129
|
-
if (!isInvalidSingleLine(tag.slice(1))) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
const fixer = () => {
|
|
133
|
-
utils.makeMultiline();
|
|
134
|
-
};
|
|
135
|
-
utils.reportJSDoc('Single line blocks are not permitted by your configuration.', null, fixer, true);
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
if (checkForShortDescriptions(jsdoc, utils, requireSingleLineUnderCount)) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
if (checkForShortTags(jsdoc, utils, requireSingleLineUnderCount)) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
const lineChecks = () => {
|
|
145
|
-
if (noZeroLineText &&
|
|
146
|
-
(tag || description)) {
|
|
147
|
-
const fixer = () => {
|
|
148
|
-
const line = {
|
|
149
|
-
...tokens,
|
|
150
|
-
};
|
|
151
|
-
utils.emptyTokens(tokens);
|
|
152
|
-
const { tokens: { delimiter, start, }, } = jsdoc.source[1];
|
|
153
|
-
utils.addLine(1, {
|
|
154
|
-
...line,
|
|
155
|
-
delimiter,
|
|
156
|
-
start,
|
|
157
|
-
});
|
|
158
|
-
};
|
|
159
|
-
utils.reportJSDoc('Should have no text on the "0th" line (after the `/**`).', null, fixer);
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
const finalLine = jsdoc.source[jsdoc.source.length - 1];
|
|
163
|
-
const finalLineTokens = finalLine.tokens;
|
|
164
|
-
if (noFinalLineText &&
|
|
165
|
-
finalLineTokens.description.trim()) {
|
|
166
|
-
const fixer = () => {
|
|
167
|
-
const line = {
|
|
168
|
-
...finalLineTokens,
|
|
169
|
-
};
|
|
170
|
-
line.description = line.description.trimEnd();
|
|
171
|
-
const { delimiter, } = line;
|
|
172
|
-
for (const prop of [
|
|
173
|
-
'delimiter',
|
|
174
|
-
'postDelimiter',
|
|
175
|
-
'tag',
|
|
176
|
-
'type',
|
|
177
|
-
'lineEnd',
|
|
178
|
-
'postType',
|
|
179
|
-
'postTag',
|
|
180
|
-
'name',
|
|
181
|
-
'postName',
|
|
182
|
-
'description',
|
|
183
|
-
]) {
|
|
184
|
-
finalLineTokens[
|
|
185
|
-
/**
|
|
186
|
-
* @type {"delimiter"|"postDelimiter"|"tag"|"type"|
|
|
187
|
-
* "lineEnd"|"postType"|"postTag"|"name"|
|
|
188
|
-
* "postName"|"description"}
|
|
189
|
-
*/ (prop)] = '';
|
|
190
|
-
}
|
|
191
|
-
utils.addLine(jsdoc.source.length - 1, {
|
|
192
|
-
...line,
|
|
193
|
-
delimiter,
|
|
194
|
-
end: '',
|
|
195
|
-
});
|
|
196
|
-
};
|
|
197
|
-
utils.reportJSDoc('Should have no text on the final line (before the `*/`).', null, fixer);
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
if (noMultilineBlocks) {
|
|
201
|
-
if (jsdoc.tags.length &&
|
|
202
|
-
(multilineTags.includes('*') || utils.hasATag(multilineTags))) {
|
|
203
|
-
lineChecks();
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
if (jsdoc.description.length >= minimumLengthForMultiline) {
|
|
207
|
-
lineChecks();
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
if (noSingleLineBlocks &&
|
|
211
|
-
(!jsdoc.tags.length ||
|
|
212
|
-
!utils.filterTags(({ tag: tg, }) => {
|
|
213
|
-
return !isInvalidSingleLine(tg);
|
|
214
|
-
}).length)) {
|
|
215
|
-
utils.reportJSDoc('Multiline jsdoc blocks are prohibited by ' +
|
|
216
|
-
'your configuration but fixing would result in a single ' +
|
|
217
|
-
'line block which you have prohibited with `noSingleLineBlocks`.');
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
if (jsdoc.tags.length > 1) {
|
|
221
|
-
if (!allowMultipleTags) {
|
|
222
|
-
utils.reportJSDoc('Multiline jsdoc blocks are prohibited by ' +
|
|
223
|
-
'your configuration but the block has multiple tags.');
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
else if (jsdoc.tags.length === 1 && jsdoc.description.trim()) {
|
|
228
|
-
if (!allowMultipleTags) {
|
|
229
|
-
utils.reportJSDoc('Multiline jsdoc blocks are prohibited by ' +
|
|
230
|
-
'your configuration but the block has a description with a tag.');
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
const fixer = () => {
|
|
236
|
-
jsdoc.source = [
|
|
237
|
-
{
|
|
238
|
-
number: 1,
|
|
239
|
-
source: '',
|
|
240
|
-
tokens: jsdoc.source.reduce((obj, { tokens: { description: desc, lineEnd, name: nme, postName, postTag, postType, tag: tg, type: typ, }, }) => {
|
|
241
|
-
if (typ) {
|
|
242
|
-
obj.type = typ;
|
|
243
|
-
}
|
|
244
|
-
if (tg && typ && nme) {
|
|
245
|
-
obj.postType = postType;
|
|
246
|
-
}
|
|
247
|
-
if (nme) {
|
|
248
|
-
obj.name += nme;
|
|
249
|
-
}
|
|
250
|
-
if (nme && desc) {
|
|
251
|
-
obj.postName = postName;
|
|
252
|
-
}
|
|
253
|
-
obj.description += desc;
|
|
254
|
-
const nameOrDescription = obj.description || obj.name;
|
|
255
|
-
if (nameOrDescription && nameOrDescription.slice(-1) !== ' ') {
|
|
256
|
-
obj.description += ' ';
|
|
257
|
-
}
|
|
258
|
-
obj.lineEnd = lineEnd;
|
|
259
|
-
// Already filtered for multiple tags
|
|
260
|
-
obj.tag += tg;
|
|
261
|
-
if (tg) {
|
|
262
|
-
obj.postTag = postTag || ' ';
|
|
263
|
-
}
|
|
264
|
-
return obj;
|
|
265
|
-
}, utils.seedTokens({
|
|
266
|
-
delimiter: '/**',
|
|
267
|
-
end: '*/',
|
|
268
|
-
postDelimiter: ' ',
|
|
269
|
-
})),
|
|
270
|
-
},
|
|
271
|
-
];
|
|
272
|
-
};
|
|
273
|
-
utils.reportJSDoc('Multiline jsdoc blocks are prohibited by ' +
|
|
274
|
-
'your configuration.', null, fixer);
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
lineChecks();
|
|
279
|
-
}, {
|
|
280
|
-
iterateAllJsdocs: true,
|
|
281
|
-
meta: {
|
|
282
|
-
docs: {
|
|
283
|
-
description: 'Controls how and whether jsdoc blocks can be expressed as single or multiple line blocks.',
|
|
284
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/multiline-blocks.md#repos-sticky-header',
|
|
285
|
-
},
|
|
286
|
-
fixable: 'code',
|
|
287
|
-
schema: [
|
|
288
|
-
{
|
|
289
|
-
additionalProperties: false,
|
|
290
|
-
properties: {
|
|
291
|
-
allowMultipleTags: {
|
|
292
|
-
type: 'boolean',
|
|
293
|
-
},
|
|
294
|
-
minimumLengthForMultiline: {
|
|
295
|
-
type: 'integer',
|
|
296
|
-
},
|
|
297
|
-
multilineTags: {
|
|
298
|
-
anyOf: [
|
|
299
|
-
{
|
|
300
|
-
enum: [
|
|
301
|
-
'*',
|
|
302
|
-
],
|
|
303
|
-
type: 'string',
|
|
304
|
-
}, {
|
|
305
|
-
items: {
|
|
306
|
-
type: 'string',
|
|
307
|
-
},
|
|
308
|
-
type: 'array',
|
|
309
|
-
},
|
|
310
|
-
],
|
|
311
|
-
},
|
|
312
|
-
noFinalLineText: {
|
|
313
|
-
type: 'boolean',
|
|
314
|
-
},
|
|
315
|
-
noMultilineBlocks: {
|
|
316
|
-
type: 'boolean',
|
|
317
|
-
},
|
|
318
|
-
noSingleLineBlocks: {
|
|
319
|
-
type: 'boolean',
|
|
320
|
-
},
|
|
321
|
-
noZeroLineText: {
|
|
322
|
-
type: 'boolean',
|
|
323
|
-
},
|
|
324
|
-
requireSingleLineUnderCount: {
|
|
325
|
-
type: 'number',
|
|
326
|
-
},
|
|
327
|
-
singleLineTags: {
|
|
328
|
-
items: {
|
|
329
|
-
type: 'string',
|
|
330
|
-
},
|
|
331
|
-
type: 'array',
|
|
332
|
-
},
|
|
333
|
-
},
|
|
334
|
-
type: 'object',
|
|
335
|
-
},
|
|
336
|
-
],
|
|
337
|
-
type: 'suggestion',
|
|
338
|
-
},
|
|
339
|
-
});
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const iterateJsdoc_js_1 = __importDefault(require("../iterateJsdoc.js"));
|
|
7
|
-
const comment_parser_1 = require("comment-parser");
|
|
8
|
-
// Neither a single nor 3+ asterisks are valid jsdoc per
|
|
9
|
-
// https://jsdoc.app/about-getting-started.html#adding-documentation-comments-to-your-code
|
|
10
|
-
const commentRegexp = /^\/\*(?!\*)/v;
|
|
11
|
-
const extraAsteriskCommentRegexp = /^\/\*{3,}/v;
|
|
12
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ allComments, context, makeReport, sourceCode, }) => {
|
|
13
|
-
const [{ ignore = [
|
|
14
|
-
'ts-check',
|
|
15
|
-
'ts-expect-error',
|
|
16
|
-
'ts-ignore',
|
|
17
|
-
'ts-nocheck',
|
|
18
|
-
], preventAllMultiAsteriskBlocks = false, } = {},] = context.options;
|
|
19
|
-
let extraAsterisks = false;
|
|
20
|
-
const nonJsdocNodes = /** @type {import('estree').Node[]} */ (allComments).filter((comment) => {
|
|
21
|
-
const commentText = sourceCode.getText(comment);
|
|
22
|
-
const initialText = commentText.replace(commentRegexp, '').trimStart();
|
|
23
|
-
if ([
|
|
24
|
-
'eslint',
|
|
25
|
-
].some((directive) => {
|
|
26
|
-
return initialText.startsWith(directive);
|
|
27
|
-
})) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
let sliceIndex = 2;
|
|
31
|
-
if (!commentRegexp.test(commentText)) {
|
|
32
|
-
const multiline = extraAsteriskCommentRegexp.exec(commentText)?.[0];
|
|
33
|
-
if (!multiline) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
sliceIndex = multiline.length;
|
|
37
|
-
extraAsterisks = true;
|
|
38
|
-
if (preventAllMultiAsteriskBlocks) {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
const tags = ((0, comment_parser_1.parse)(`${commentText.slice(0, 2)}*${commentText.slice(sliceIndex)}`)[0] || {}).tags ?? [];
|
|
43
|
-
return tags.length && !tags.some(({ tag, }) => {
|
|
44
|
-
return ignore.includes(tag);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
if (!nonJsdocNodes.length) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
for (const node of nonJsdocNodes) {
|
|
51
|
-
const report = /** @type {import('../iterateJsdoc.js').MakeReport} */ (makeReport)(context, node);
|
|
52
|
-
// eslint-disable-next-line no-loop-func
|
|
53
|
-
const fix = /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {
|
|
54
|
-
const text = sourceCode.getText(node);
|
|
55
|
-
return fixer.replaceText(node, extraAsterisks ?
|
|
56
|
-
text.replace(extraAsteriskCommentRegexp, '/**') :
|
|
57
|
-
text.replace('/*', '/**'));
|
|
58
|
-
};
|
|
59
|
-
report('Expected JSDoc-like comment to begin with two asterisks.', fix);
|
|
60
|
-
}
|
|
61
|
-
}, {
|
|
62
|
-
checkFile: true,
|
|
63
|
-
meta: {
|
|
64
|
-
docs: {
|
|
65
|
-
description: 'This rule checks for multi-line-style comments which fail to meet the criteria of a jsdoc block.',
|
|
66
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-bad-blocks.md#repos-sticky-header',
|
|
67
|
-
},
|
|
68
|
-
fixable: 'code',
|
|
69
|
-
schema: [
|
|
70
|
-
{
|
|
71
|
-
additionalProperties: false,
|
|
72
|
-
properties: {
|
|
73
|
-
ignore: {
|
|
74
|
-
items: {
|
|
75
|
-
type: 'string',
|
|
76
|
-
},
|
|
77
|
-
type: 'array',
|
|
78
|
-
},
|
|
79
|
-
preventAllMultiAsteriskBlocks: {
|
|
80
|
-
type: 'boolean',
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
type: 'object',
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
type: 'layout',
|
|
87
|
-
},
|
|
88
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const iterateJsdoc_js_1 = __importDefault(require("../iterateJsdoc.js"));
|
|
7
|
-
const anyWhitespaceLines = /^\s*$/v;
|
|
8
|
-
const atLeastTwoLinesWhitespace = /^[ \t]*\n[ \t]*\n\s*$/v;
|
|
9
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ jsdoc, utils, }) => {
|
|
10
|
-
const { description, descriptions, lastDescriptionLine, } = utils.getDescription();
|
|
11
|
-
const regex = jsdoc.tags.length ?
|
|
12
|
-
anyWhitespaceLines :
|
|
13
|
-
atLeastTwoLinesWhitespace;
|
|
14
|
-
if (descriptions.length && regex.test(description)) {
|
|
15
|
-
if (jsdoc.tags.length) {
|
|
16
|
-
utils.reportJSDoc('There should be no blank lines in block descriptions followed by tags.', {
|
|
17
|
-
line: lastDescriptionLine,
|
|
18
|
-
}, () => {
|
|
19
|
-
utils.setBlockDescription(() => {
|
|
20
|
-
// Remove all lines
|
|
21
|
-
return [];
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
utils.reportJSDoc('There should be no extra blank lines in block descriptions not followed by tags.', {
|
|
27
|
-
line: lastDescriptionLine,
|
|
28
|
-
}, () => {
|
|
29
|
-
utils.setBlockDescription((info, seedTokens) => {
|
|
30
|
-
return [
|
|
31
|
-
// Keep the starting line
|
|
32
|
-
{
|
|
33
|
-
number: 0,
|
|
34
|
-
source: '',
|
|
35
|
-
tokens: seedTokens({
|
|
36
|
-
...info,
|
|
37
|
-
description: '',
|
|
38
|
-
}),
|
|
39
|
-
},
|
|
40
|
-
];
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}, {
|
|
46
|
-
iterateAllJsdocs: true,
|
|
47
|
-
meta: {
|
|
48
|
-
docs: {
|
|
49
|
-
description: 'Detects and removes extra lines of a blank block description',
|
|
50
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-blank-block-descriptions.md#repos-sticky-header',
|
|
51
|
-
},
|
|
52
|
-
fixable: 'whitespace',
|
|
53
|
-
schema: [],
|
|
54
|
-
type: 'layout',
|
|
55
|
-
},
|
|
56
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const iterateJsdoc_js_1 = __importDefault(require("../iterateJsdoc.js"));
|
|
7
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ context, jsdoc, utils, }) => {
|
|
8
|
-
if (jsdoc.tags.length) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
const { description, lastDescriptionLine, } = utils.getDescription();
|
|
12
|
-
if (description.trim()) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
const { enableFixer, } = context.options[0] || {};
|
|
16
|
-
utils.reportJSDoc('No empty blocks', {
|
|
17
|
-
line: lastDescriptionLine,
|
|
18
|
-
}, enableFixer ? () => {
|
|
19
|
-
jsdoc.source.splice(0);
|
|
20
|
-
} : null);
|
|
21
|
-
}, {
|
|
22
|
-
iterateAllJsdocs: true,
|
|
23
|
-
meta: {
|
|
24
|
-
docs: {
|
|
25
|
-
description: 'Removes empty blocks with nothing but possibly line breaks',
|
|
26
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-blank-blocks.md#repos-sticky-header',
|
|
27
|
-
},
|
|
28
|
-
fixable: 'code',
|
|
29
|
-
schema: [
|
|
30
|
-
{
|
|
31
|
-
additionalProperties: false,
|
|
32
|
-
properties: {
|
|
33
|
-
enableFixer: {
|
|
34
|
-
type: 'boolean',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
type: 'suggestion',
|
|
40
|
-
},
|
|
41
|
-
});
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const iterateJsdoc_js_1 = __importDefault(require("../iterateJsdoc.js"));
|
|
7
|
-
exports.default = (0, iterateJsdoc_js_1.default)(({ context, utils, }) => {
|
|
8
|
-
const { noOptionalParamNames, } = context.options[0] || {};
|
|
9
|
-
const paramTags = utils.getPresentTags([
|
|
10
|
-
'param', 'arg', 'argument',
|
|
11
|
-
]);
|
|
12
|
-
for (const tag of paramTags) {
|
|
13
|
-
if (noOptionalParamNames && tag.optional) {
|
|
14
|
-
utils.reportJSDoc(`Optional param names are not permitted on @${tag.tag}.`, tag, () => {
|
|
15
|
-
utils.changeTag(tag, {
|
|
16
|
-
name: tag.name.replace(/([^=]*)(=.+)?/v, '$1'),
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
else if (tag.default) {
|
|
21
|
-
utils.reportJSDoc(`Defaults are not permitted on @${tag.tag}.`, tag, () => {
|
|
22
|
-
utils.changeTag(tag, {
|
|
23
|
-
name: tag.name.replace(/([^=]*)(=.+)?/v, '[$1]'),
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const defaultTags = utils.getPresentTags([
|
|
29
|
-
'default', 'defaultvalue',
|
|
30
|
-
]);
|
|
31
|
-
for (const tag of defaultTags) {
|
|
32
|
-
if (tag.description.trim()) {
|
|
33
|
-
utils.reportJSDoc(`Default values are not permitted on @${tag.tag}.`, tag, () => {
|
|
34
|
-
utils.changeTag(tag, {
|
|
35
|
-
description: '',
|
|
36
|
-
postTag: '',
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}, {
|
|
42
|
-
contextDefaults: true,
|
|
43
|
-
meta: {
|
|
44
|
-
docs: {
|
|
45
|
-
description: 'This rule reports defaults being used on the relevant portion of `@param` or `@default`.',
|
|
46
|
-
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-defaults.md#repos-sticky-header',
|
|
47
|
-
},
|
|
48
|
-
fixable: 'code',
|
|
49
|
-
schema: [
|
|
50
|
-
{
|
|
51
|
-
additionalProperties: false,
|
|
52
|
-
properties: {
|
|
53
|
-
contexts: {
|
|
54
|
-
items: {
|
|
55
|
-
anyOf: [
|
|
56
|
-
{
|
|
57
|
-
type: 'string',
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
additionalProperties: false,
|
|
61
|
-
properties: {
|
|
62
|
-
comment: {
|
|
63
|
-
type: 'string',
|
|
64
|
-
},
|
|
65
|
-
context: {
|
|
66
|
-
type: 'string',
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
type: 'object',
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
},
|
|
73
|
-
type: 'array',
|
|
74
|
-
},
|
|
75
|
-
noOptionalParamNames: {
|
|
76
|
-
type: 'boolean',
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
type: 'object',
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
type: 'suggestion',
|
|
83
|
-
},
|
|
84
|
-
});
|