eslint-plugin-jsdoc 61.1.12 → 61.2.1
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/iterateJsdoc.d.ts +2 -2
- package/dist/cjs/jsdocUtils.d.ts +2 -1
- package/dist/iterateJsdoc.cjs +9 -4
- package/dist/iterateJsdoc.cjs.map +1 -1
- package/dist/iterateJsdoc.d.ts +2 -2
- package/dist/jsdocUtils.cjs +11 -1
- package/dist/jsdocUtils.cjs.map +1 -1
- package/dist/jsdocUtils.d.ts +2 -1
- package/dist/rules/requireParam.cjs +3 -8
- package/dist/rules/requireParam.cjs.map +1 -1
- package/dist/rules/sortTags.cjs +13 -1
- package/dist/rules/sortTags.cjs.map +1 -1
- package/dist/rules/tagLines.cjs +10 -9
- package/dist/rules/tagLines.cjs.map +1 -1
- package/dist/rules.d.ts +10 -0
- package/dist/to-valid-identifier.cjs +3 -1
- package/package.json +1 -1
- package/src/iterateJsdoc.js +9 -3
- package/src/jsdocUtils.js +15 -1
- package/src/rules/requireParam.js +5 -14
- package/src/rules/sortTags.js +13 -1
- package/src/rules/tagLines.js +13 -9
- package/src/rules.d.ts +10 -0
package/dist/rules.d.ts
CHANGED
|
@@ -2660,6 +2660,16 @@ export interface Rules {
|
|
|
2660
2660
|
* may wish to use the `endLines` option of the `tag-lines` rule.
|
|
2661
2661
|
*/
|
|
2662
2662
|
reportTagGroupSpacing?: boolean;
|
|
2663
|
+
/**
|
|
2664
|
+
* Allows specification by tag of a specific higher maximum number of lines. Keys are tags and values are the maximum number of lines allowed for such tags. Overrides `linesBetween`. Defaults to no special exceptions per tag.
|
|
2665
|
+
*/
|
|
2666
|
+
tagExceptions?: {
|
|
2667
|
+
/**
|
|
2668
|
+
* This interface was referenced by `undefined`'s JSON-Schema definition
|
|
2669
|
+
* via the `patternProperty` ".*".
|
|
2670
|
+
*/
|
|
2671
|
+
[k: string]: number;
|
|
2672
|
+
};
|
|
2663
2673
|
/**
|
|
2664
2674
|
* An array of tag group objects indicating the preferred sequence for sorting tags.
|
|
2665
2675
|
*
|
|
@@ -43,13 +43,15 @@ const identifiers = [
|
|
|
43
43
|
'with',
|
|
44
44
|
'yield',
|
|
45
45
|
|
|
46
|
-
// Future reserved keywords
|
|
46
|
+
// Future reserved keywords (strict mode)
|
|
47
47
|
'implements',
|
|
48
48
|
'interface',
|
|
49
|
+
'let',
|
|
49
50
|
'package',
|
|
50
51
|
'private',
|
|
51
52
|
'protected',
|
|
52
53
|
'public',
|
|
54
|
+
'static',
|
|
53
55
|
|
|
54
56
|
// Not keywords, but still restricted
|
|
55
57
|
'arguments',
|
package/package.json
CHANGED
package/src/iterateJsdoc.js
CHANGED
|
@@ -170,7 +170,8 @@ import esquery from 'esquery';
|
|
|
170
170
|
* seedTokens: (
|
|
171
171
|
* tokens?: Partial<import('comment-parser').Tokens>
|
|
172
172
|
* ) => import('comment-parser').Tokens,
|
|
173
|
-
* descLines: string[]
|
|
173
|
+
* descLines: string[],
|
|
174
|
+
* postDelims: string[]
|
|
174
175
|
* ) => import('comment-parser').Line[]} setter
|
|
175
176
|
* @returns {void}
|
|
176
177
|
*/
|
|
@@ -257,6 +258,7 @@ import esquery from 'esquery';
|
|
|
257
258
|
/**
|
|
258
259
|
* @callback GetFunctionParameterNames
|
|
259
260
|
* @param {boolean} [useDefaultObjectProperties]
|
|
261
|
+
* @param {boolean} [ignoreInterfacedParameters]
|
|
260
262
|
* @returns {import('./jsdocUtils.js').ParamNameInfo[]}
|
|
261
263
|
*/
|
|
262
264
|
|
|
@@ -927,6 +929,8 @@ const getUtils = (
|
|
|
927
929
|
utils.setBlockDescription = (setter) => {
|
|
928
930
|
/** @type {string[]} */
|
|
929
931
|
const descLines = [];
|
|
932
|
+
/** @type {string[]} */
|
|
933
|
+
const postDelims = [];
|
|
930
934
|
/**
|
|
931
935
|
* @type {undefined|Integer}
|
|
932
936
|
*/
|
|
@@ -973,6 +977,7 @@ const getUtils = (
|
|
|
973
977
|
return true;
|
|
974
978
|
}
|
|
975
979
|
|
|
980
|
+
postDelims.push(postDelimiter);
|
|
976
981
|
descLines.push(description);
|
|
977
982
|
return false;
|
|
978
983
|
});
|
|
@@ -993,6 +998,7 @@ const getUtils = (
|
|
|
993
998
|
(info),
|
|
994
999
|
seedTokens,
|
|
995
1000
|
descLines,
|
|
1001
|
+
postDelims,
|
|
996
1002
|
),
|
|
997
1003
|
);
|
|
998
1004
|
}
|
|
@@ -1369,8 +1375,8 @@ const getUtils = (
|
|
|
1369
1375
|
utils.flattenRoots = jsdocUtils.flattenRoots;
|
|
1370
1376
|
|
|
1371
1377
|
/** @type {GetFunctionParameterNames} */
|
|
1372
|
-
utils.getFunctionParameterNames = (useDefaultObjectProperties) => {
|
|
1373
|
-
return jsdocUtils.getFunctionParameterNames(node, useDefaultObjectProperties);
|
|
1378
|
+
utils.getFunctionParameterNames = (useDefaultObjectProperties, ignoreInterfacedParameters) => {
|
|
1379
|
+
return jsdocUtils.getFunctionParameterNames(node, useDefaultObjectProperties, ignoreInterfacedParameters);
|
|
1374
1380
|
};
|
|
1375
1381
|
|
|
1376
1382
|
/** @type {HasParams} */
|
package/src/jsdocUtils.js
CHANGED
|
@@ -203,11 +203,12 @@ const getPropertiesFromPropertySignature = (propSignature) => {
|
|
|
203
203
|
/**
|
|
204
204
|
* @param {ESTreeOrTypeScriptNode|null} functionNode
|
|
205
205
|
* @param {boolean} [checkDefaultObjects]
|
|
206
|
+
* @param {boolean} [ignoreInterfacedParameters]
|
|
206
207
|
* @throws {Error}
|
|
207
208
|
* @returns {ParamNameInfo[]}
|
|
208
209
|
*/
|
|
209
210
|
const getFunctionParameterNames = (
|
|
210
|
-
functionNode, checkDefaultObjects,
|
|
211
|
+
functionNode, checkDefaultObjects, ignoreInterfacedParameters,
|
|
211
212
|
) => {
|
|
212
213
|
/* eslint-disable complexity -- Temporary */
|
|
213
214
|
/**
|
|
@@ -230,6 +231,19 @@ const getFunctionParameterNames = (
|
|
|
230
231
|
const hasLeftTypeAnnotation = 'left' in param && 'typeAnnotation' in param.left;
|
|
231
232
|
|
|
232
233
|
if ('typeAnnotation' in param || hasLeftTypeAnnotation) {
|
|
234
|
+
if (ignoreInterfacedParameters && 'typeAnnotation' in param &&
|
|
235
|
+
param.typeAnnotation) {
|
|
236
|
+
// No-op
|
|
237
|
+
return [
|
|
238
|
+
undefined, {
|
|
239
|
+
hasPropertyRest: false,
|
|
240
|
+
hasRestElement: false,
|
|
241
|
+
names: [],
|
|
242
|
+
rests: [],
|
|
243
|
+
},
|
|
244
|
+
];
|
|
245
|
+
}
|
|
246
|
+
|
|
233
247
|
const typeAnnotation = hasLeftTypeAnnotation ?
|
|
234
248
|
/** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ (
|
|
235
249
|
param.left
|
|
@@ -65,19 +65,10 @@ export default iterateJsdoc(({
|
|
|
65
65
|
useDefaultObjectProperties = false,
|
|
66
66
|
} = context.options[0] || {};
|
|
67
67
|
|
|
68
|
-
if (interfaceExemptsParamsCheck
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
'typeAnnotation' in node.params[0] && node.params[0].typeAnnotation
|
|
73
|
-
) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (node && node.parent?.type === 'VariableDeclarator' &&
|
|
78
|
-
'typeAnnotation' in node.parent.id && node.parent.id.typeAnnotation) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
68
|
+
if (interfaceExemptsParamsCheck && node &&
|
|
69
|
+
node.parent?.type === 'VariableDeclarator' &&
|
|
70
|
+
'typeAnnotation' in node.parent.id && node.parent.id.typeAnnotation) {
|
|
71
|
+
return;
|
|
81
72
|
}
|
|
82
73
|
|
|
83
74
|
const preferredTagName = /** @type {string} */ (utils.getPreferredTagName({
|
|
@@ -87,7 +78,7 @@ export default iterateJsdoc(({
|
|
|
87
78
|
return;
|
|
88
79
|
}
|
|
89
80
|
|
|
90
|
-
const functionParameterNames = utils.getFunctionParameterNames(useDefaultObjectProperties);
|
|
81
|
+
const functionParameterNames = utils.getFunctionParameterNames(useDefaultObjectProperties, interfaceExemptsParamsCheck);
|
|
91
82
|
if (!functionParameterNames.length) {
|
|
92
83
|
return;
|
|
93
84
|
}
|
package/src/rules/sortTags.js
CHANGED
|
@@ -5,11 +5,13 @@ export default iterateJsdoc(({
|
|
|
5
5
|
context,
|
|
6
6
|
jsdoc,
|
|
7
7
|
utils,
|
|
8
|
+
// eslint-disable-next-line complexity -- Temporary
|
|
8
9
|
}) => {
|
|
9
10
|
const
|
|
10
11
|
/**
|
|
11
12
|
* @type {{
|
|
12
13
|
* linesBetween: import('../iterateJsdoc.js').Integer,
|
|
14
|
+
* tagExceptions: Record<string, number>,
|
|
13
15
|
* tagSequence: {
|
|
14
16
|
* tags: string[]
|
|
15
17
|
* }[],
|
|
@@ -22,6 +24,7 @@ export default iterateJsdoc(({
|
|
|
22
24
|
linesBetween = 1,
|
|
23
25
|
reportIntraTagGroupSpacing = true,
|
|
24
26
|
reportTagGroupSpacing = true,
|
|
27
|
+
tagExceptions = {},
|
|
25
28
|
tagSequence = defaultTagOrder,
|
|
26
29
|
} = context.options[0] || {};
|
|
27
30
|
|
|
@@ -328,7 +331,7 @@ export default iterateJsdoc(({
|
|
|
328
331
|
}
|
|
329
332
|
|
|
330
333
|
const ct = countTagEmptyLines(tag);
|
|
331
|
-
if (ct) {
|
|
334
|
+
if (ct && (!tagExceptions[tag.tag] || tagExceptions[tag.tag] < ct)) {
|
|
332
335
|
const fixer = () => {
|
|
333
336
|
let foundFirstTag = false;
|
|
334
337
|
|
|
@@ -548,6 +551,15 @@ will not have spacing applied regardless. For adding line breaks there, you
|
|
|
548
551
|
may wish to use the \`endLines\` option of the \`tag-lines\` rule.`,
|
|
549
552
|
type: 'boolean',
|
|
550
553
|
},
|
|
554
|
+
tagExceptions: {
|
|
555
|
+
description: 'Allows specification by tag of a specific higher maximum number of lines. Keys are tags and values are the maximum number of lines allowed for such tags. Overrides `linesBetween`. Defaults to no special exceptions per tag.',
|
|
556
|
+
patternProperties: {
|
|
557
|
+
'.*': {
|
|
558
|
+
type: 'number',
|
|
559
|
+
},
|
|
560
|
+
},
|
|
561
|
+
type: 'object',
|
|
562
|
+
},
|
|
551
563
|
tagSequence: {
|
|
552
564
|
description: `An array of tag group objects indicating the preferred sequence for sorting tags.
|
|
553
565
|
|
package/src/rules/tagLines.js
CHANGED
|
@@ -37,18 +37,22 @@ const checkMaxBlockLines = ({
|
|
|
37
37
|
line: excessIndexLine,
|
|
38
38
|
},
|
|
39
39
|
() => {
|
|
40
|
-
utils.setBlockDescription((info, seedTokens, descLines) => {
|
|
40
|
+
utils.setBlockDescription((info, seedTokens, descLines, postDelims) => {
|
|
41
|
+
const newPostDelims = [
|
|
42
|
+
...postDelims.slice(0, excessIndexLine),
|
|
43
|
+
...postDelims.slice(excessIndexLine + excessBlockLines - 1 - maxBlockLines),
|
|
44
|
+
];
|
|
41
45
|
return [
|
|
42
46
|
...descLines.slice(0, excessIndexLine),
|
|
43
47
|
...descLines.slice(excessIndexLine + excessBlockLines - 1 - maxBlockLines),
|
|
44
|
-
].map((desc) => {
|
|
48
|
+
].map((desc, idx) => {
|
|
45
49
|
return {
|
|
46
50
|
number: 0,
|
|
47
51
|
source: '',
|
|
48
52
|
tokens: seedTokens({
|
|
49
53
|
...info,
|
|
50
54
|
description: desc,
|
|
51
|
-
postDelimiter:
|
|
55
|
+
postDelimiter: newPostDelims[idx],
|
|
52
56
|
}),
|
|
53
57
|
};
|
|
54
58
|
});
|
|
@@ -310,15 +314,15 @@ export default iterateJsdoc(({
|
|
|
310
314
|
line: lastDescriptionLine - trailingDiff,
|
|
311
315
|
},
|
|
312
316
|
() => {
|
|
313
|
-
utils.setBlockDescription((info, seedTokens, descLines) => {
|
|
314
|
-
return descLines.slice(0, -trailingDiff).map((desc) => {
|
|
317
|
+
utils.setBlockDescription((info, seedTokens, descLines, postDelims) => {
|
|
318
|
+
return descLines.slice(0, -trailingDiff).map((desc, idx) => {
|
|
315
319
|
return {
|
|
316
320
|
number: 0,
|
|
317
321
|
source: '',
|
|
318
322
|
tokens: seedTokens({
|
|
319
323
|
...info,
|
|
320
324
|
description: desc,
|
|
321
|
-
postDelimiter:
|
|
325
|
+
postDelimiter: postDelims[idx],
|
|
322
326
|
}),
|
|
323
327
|
};
|
|
324
328
|
});
|
|
@@ -332,7 +336,7 @@ export default iterateJsdoc(({
|
|
|
332
336
|
line: lastDescriptionLine,
|
|
333
337
|
},
|
|
334
338
|
() => {
|
|
335
|
-
utils.setBlockDescription((info, seedTokens, descLines) => {
|
|
339
|
+
utils.setBlockDescription((info, seedTokens, descLines, postDelims) => {
|
|
336
340
|
return [
|
|
337
341
|
...descLines,
|
|
338
342
|
...Array.from({
|
|
@@ -340,14 +344,14 @@ export default iterateJsdoc(({
|
|
|
340
344
|
}, () => {
|
|
341
345
|
return '';
|
|
342
346
|
}),
|
|
343
|
-
].map((desc) => {
|
|
347
|
+
].map((desc, idx) => {
|
|
344
348
|
return {
|
|
345
349
|
number: 0,
|
|
346
350
|
source: '',
|
|
347
351
|
tokens: seedTokens({
|
|
348
352
|
...info,
|
|
349
353
|
description: desc,
|
|
350
|
-
postDelimiter: desc.trim() ?
|
|
354
|
+
postDelimiter: desc.trim() ? postDelims[idx] : '',
|
|
351
355
|
}),
|
|
352
356
|
};
|
|
353
357
|
});
|
package/src/rules.d.ts
CHANGED
|
@@ -2660,6 +2660,16 @@ export interface Rules {
|
|
|
2660
2660
|
* may wish to use the `endLines` option of the `tag-lines` rule.
|
|
2661
2661
|
*/
|
|
2662
2662
|
reportTagGroupSpacing?: boolean;
|
|
2663
|
+
/**
|
|
2664
|
+
* Allows specification by tag of a specific higher maximum number of lines. Keys are tags and values are the maximum number of lines allowed for such tags. Overrides `linesBetween`. Defaults to no special exceptions per tag.
|
|
2665
|
+
*/
|
|
2666
|
+
tagExceptions?: {
|
|
2667
|
+
/**
|
|
2668
|
+
* This interface was referenced by `undefined`'s JSON-Schema definition
|
|
2669
|
+
* via the `patternProperty` ".*".
|
|
2670
|
+
*/
|
|
2671
|
+
[k: string]: number;
|
|
2672
|
+
};
|
|
2663
2673
|
/**
|
|
2664
2674
|
* An array of tag group objects indicating the preferred sequence for sorting tags.
|
|
2665
2675
|
*
|