eslint-plugin-jsdoc 60.8.3 → 61.0.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/index-cjs.cjs +4 -4
- package/dist/index-cjs.cjs.map +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/rules/typeFormatting.cjs +339 -7
- package/dist/rules/typeFormatting.cjs.map +1 -1
- package/dist/rules.d.ts +65 -1
- package/package.json +4 -4
- package/src/index-cjs.js +4 -4
- package/src/index.js +4 -4
- package/src/rules/typeFormatting.js +349 -7
- package/src/rules.d.ts +65 -1
package/dist/rules.d.ts
CHANGED
|
@@ -2947,14 +2947,66 @@ export interface Rules {
|
|
|
2947
2947
|
* Determines how array generics are represented. Set to `angle` for the style `Array<type>` or `square` for the style `type[]`. Defaults to "square".
|
|
2948
2948
|
*/
|
|
2949
2949
|
arrayBrackets?: "angle" | "square";
|
|
2950
|
+
/**
|
|
2951
|
+
* The space character (if any) to use after return markers (`=>`). Defaults to " ".
|
|
2952
|
+
*/
|
|
2953
|
+
arrowFunctionPostReturnMarkerSpacing?: string;
|
|
2954
|
+
/**
|
|
2955
|
+
* The space character (if any) to use before return markers (`=>`). Defaults to " ".
|
|
2956
|
+
*/
|
|
2957
|
+
arrowFunctionPreReturnMarkerSpacing?: string;
|
|
2950
2958
|
/**
|
|
2951
2959
|
* Whether to enable the fixer. Defaults to `true`.
|
|
2952
2960
|
*/
|
|
2953
2961
|
enableFixer?: boolean;
|
|
2962
|
+
/**
|
|
2963
|
+
* The space character (if any) to use between function or class parameters. Defaults to " ".
|
|
2964
|
+
*/
|
|
2965
|
+
functionOrClassParameterSpacing?: string;
|
|
2966
|
+
/**
|
|
2967
|
+
* The space character (if any) to use after a generic expression in a function or class. Defaults to "".
|
|
2968
|
+
*/
|
|
2969
|
+
functionOrClassPostGenericSpacing?: string;
|
|
2970
|
+
/**
|
|
2971
|
+
* The space character (if any) to use after return markers (`:`). Defaults to "".
|
|
2972
|
+
*/
|
|
2973
|
+
functionOrClassPostReturnMarkerSpacing?: string;
|
|
2974
|
+
/**
|
|
2975
|
+
* The space character (if any) to use before return markers (`:`). Defaults to "".
|
|
2976
|
+
*/
|
|
2977
|
+
functionOrClassPreReturnMarkerSpacing?: string;
|
|
2978
|
+
/**
|
|
2979
|
+
* The space character (if any) to use between type parameters in a function or class. Defaults to " ".
|
|
2980
|
+
*/
|
|
2981
|
+
functionOrClassTypeParameterSpacing?: string;
|
|
2982
|
+
/**
|
|
2983
|
+
* The space character (if any) to use between elements in generics and tuples. Defaults to " ".
|
|
2984
|
+
*/
|
|
2985
|
+
genericAndTupleElementSpacing?: string;
|
|
2954
2986
|
/**
|
|
2955
2987
|
* Boolean value of whether to use a dot before the angled brackets of a generic (e.g., `SomeType.<AnotherType>`). Defaults to `false`.
|
|
2956
2988
|
*/
|
|
2957
2989
|
genericDot?: boolean;
|
|
2990
|
+
/**
|
|
2991
|
+
* The amount of spacing (if any) after the colon of a key-value or object-field pair. Defaults to " ".
|
|
2992
|
+
*/
|
|
2993
|
+
keyValuePostColonSpacing?: string;
|
|
2994
|
+
/**
|
|
2995
|
+
* The amount of spacing (if any) immediately after keys in a key-value or object-field pair. Defaults to "".
|
|
2996
|
+
*/
|
|
2997
|
+
keyValuePostKeySpacing?: string;
|
|
2998
|
+
/**
|
|
2999
|
+
* The amount of spacing (if any) after the optional operator (`?`) in a key-value or object-field pair. Defaults to "".
|
|
3000
|
+
*/
|
|
3001
|
+
keyValuePostOptionalSpacing?: string;
|
|
3002
|
+
/**
|
|
3003
|
+
* The amount of spacing (if any) after a variadic operator (`...`) in a key-value pair. Defaults to "".
|
|
3004
|
+
*/
|
|
3005
|
+
keyValuePostVariadicSpacing?: string;
|
|
3006
|
+
/**
|
|
3007
|
+
* The style of quotation mark for surrounding method names when quoted. Defaults to `double`
|
|
3008
|
+
*/
|
|
3009
|
+
methodQuotes?: "double" | "single";
|
|
2958
3010
|
/**
|
|
2959
3011
|
* A string indicating the whitespace to be added on each line preceding an
|
|
2960
3012
|
* object property-value field. Defaults to the empty string.
|
|
@@ -2990,6 +3042,18 @@ export interface Rules {
|
|
|
2990
3042
|
* Defaults to `false`.
|
|
2991
3043
|
*/
|
|
2992
3044
|
objectFieldSeparatorTrailingPunctuation?: boolean;
|
|
3045
|
+
/**
|
|
3046
|
+
* The space character (if any) to use between the equal signs of a default value. Defaults to " ".
|
|
3047
|
+
*/
|
|
3048
|
+
parameterDefaultValueSpacing?: string;
|
|
3049
|
+
/**
|
|
3050
|
+
* The space character (if any) to add after a method name. Defaults to "".
|
|
3051
|
+
*/
|
|
3052
|
+
postMethodNameSpacing?: string;
|
|
3053
|
+
/**
|
|
3054
|
+
* The space character (if any) to add after "new" in a constructor. Defaults to " ".
|
|
3055
|
+
*/
|
|
3056
|
+
postNewSpacing?: string;
|
|
2993
3057
|
/**
|
|
2994
3058
|
* Whether to apply the `objectFieldSeparator` (e.g., a semicolon) when there
|
|
2995
3059
|
* is only one property-value object field present. Defaults to `false`.
|
|
@@ -2997,7 +3061,7 @@ export interface Rules {
|
|
|
2997
3061
|
separatorForSingleObjectField?: boolean;
|
|
2998
3062
|
/**
|
|
2999
3063
|
* How string literals should be quoted (e.g., `"abc"`). Set to `single`
|
|
3000
|
-
* or `double`. Defaults to '
|
|
3064
|
+
* or `double`. Defaults to 'double'.
|
|
3001
3065
|
*/
|
|
3002
3066
|
stringQuotes?: "double" | "single";
|
|
3003
3067
|
/**
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"url": "http://gajus.com"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@es-joy/jsdoccomment": "~0.
|
|
8
|
+
"@es-joy/jsdoccomment": "~0.75.0",
|
|
9
9
|
"are-docs-informative": "^0.0.2",
|
|
10
10
|
"comment-parser": "1.4.1",
|
|
11
11
|
"debug": "^4.4.3",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"html-entities": "^2.6.0",
|
|
16
16
|
"object-deep-merge": "^1.0.5",
|
|
17
17
|
"parse-imports-exports": "^0.2.4",
|
|
18
|
-
"semver": "^7.7.
|
|
18
|
+
"semver": "^7.7.3",
|
|
19
19
|
"spdx-expression-parse": "^4.0.0"
|
|
20
20
|
},
|
|
21
21
|
"description": "JSDoc linting rules for ESLint.",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"glob": "^11.0.3",
|
|
59
59
|
"globals": "^16.4.0",
|
|
60
60
|
"husky": "^9.1.7",
|
|
61
|
-
"jsdoc-type-pratt-parser": "^6.
|
|
61
|
+
"jsdoc-type-pratt-parser": "^6.9.1",
|
|
62
62
|
"json-schema": "^0.4.0",
|
|
63
63
|
"json-schema-to-typescript": "^15.0.4",
|
|
64
64
|
"lint-staged": "^16.2.3",
|
|
@@ -178,5 +178,5 @@
|
|
|
178
178
|
"test-cov": "TIMING=1 c8 --reporter text pnpm run test-no-cov",
|
|
179
179
|
"test-index": "pnpm run test-no-cov test/rules/index.js"
|
|
180
180
|
},
|
|
181
|
-
"version": "
|
|
181
|
+
"version": "61.0.1"
|
|
182
182
|
}
|
package/src/index-cjs.js
CHANGED
|
@@ -205,7 +205,7 @@ index.rules = {
|
|
|
205
205
|
'require-throws-description': buildForbidRuleDefinition({
|
|
206
206
|
contexts: [
|
|
207
207
|
{
|
|
208
|
-
comment: 'JsdocBlock:has(JsdocTag[tag
|
|
208
|
+
comment: 'JsdocBlock:has(JsdocTag[tag=/^(?:throws|exception)$/]:not([description!=""]))',
|
|
209
209
|
context: 'any',
|
|
210
210
|
message: '@throws should have a description',
|
|
211
211
|
},
|
|
@@ -216,7 +216,7 @@ index.rules = {
|
|
|
216
216
|
'require-throws-type': buildForbidRuleDefinition({
|
|
217
217
|
contexts: [
|
|
218
218
|
{
|
|
219
|
-
comment: 'JsdocBlock:has(JsdocTag[tag
|
|
219
|
+
comment: 'JsdocBlock:has(JsdocTag[tag=/^(?:throws|exception)$/]:not([parsedType.type]))',
|
|
220
220
|
context: 'any',
|
|
221
221
|
message: '@throws should have a type',
|
|
222
222
|
},
|
|
@@ -229,7 +229,7 @@ index.rules = {
|
|
|
229
229
|
'require-yields-description': buildForbidRuleDefinition({
|
|
230
230
|
contexts: [
|
|
231
231
|
{
|
|
232
|
-
comment: 'JsdocBlock:has(JsdocTag[tag
|
|
232
|
+
comment: 'JsdocBlock:has(JsdocTag[tag=/^yields?$/]:not([name!=""]):not([description!=""]))',
|
|
233
233
|
context: 'any',
|
|
234
234
|
message: '@yields should have a description',
|
|
235
235
|
},
|
|
@@ -240,7 +240,7 @@ index.rules = {
|
|
|
240
240
|
'require-yields-type': buildForbidRuleDefinition({
|
|
241
241
|
contexts: [
|
|
242
242
|
{
|
|
243
|
-
comment: 'JsdocBlock:has(JsdocTag[tag
|
|
243
|
+
comment: 'JsdocBlock:has(JsdocTag[tag=/^yields?$/]:not([parsedType.type]))',
|
|
244
244
|
context: 'any',
|
|
245
245
|
message: '@yields should have a type',
|
|
246
246
|
},
|
package/src/index.js
CHANGED
|
@@ -211,7 +211,7 @@ index.rules = {
|
|
|
211
211
|
'require-throws-description': buildForbidRuleDefinition({
|
|
212
212
|
contexts: [
|
|
213
213
|
{
|
|
214
|
-
comment: 'JsdocBlock:has(JsdocTag[tag
|
|
214
|
+
comment: 'JsdocBlock:has(JsdocTag[tag=/^(?:throws|exception)$/]:not([description!=""]))',
|
|
215
215
|
context: 'any',
|
|
216
216
|
message: '@throws should have a description',
|
|
217
217
|
},
|
|
@@ -222,7 +222,7 @@ index.rules = {
|
|
|
222
222
|
'require-throws-type': buildForbidRuleDefinition({
|
|
223
223
|
contexts: [
|
|
224
224
|
{
|
|
225
|
-
comment: 'JsdocBlock:has(JsdocTag[tag
|
|
225
|
+
comment: 'JsdocBlock:has(JsdocTag[tag=/^(?:throws|exception)$/]:not([parsedType.type]))',
|
|
226
226
|
context: 'any',
|
|
227
227
|
message: '@throws should have a type',
|
|
228
228
|
},
|
|
@@ -235,7 +235,7 @@ index.rules = {
|
|
|
235
235
|
'require-yields-description': buildForbidRuleDefinition({
|
|
236
236
|
contexts: [
|
|
237
237
|
{
|
|
238
|
-
comment: 'JsdocBlock:has(JsdocTag[tag
|
|
238
|
+
comment: 'JsdocBlock:has(JsdocTag[tag=/^yields?$/]:not([name!=""]):not([description!=""]))',
|
|
239
239
|
context: 'any',
|
|
240
240
|
message: '@yields should have a description',
|
|
241
241
|
},
|
|
@@ -246,7 +246,7 @@ index.rules = {
|
|
|
246
246
|
'require-yields-type': buildForbidRuleDefinition({
|
|
247
247
|
contexts: [
|
|
248
248
|
{
|
|
249
|
-
comment: 'JsdocBlock:has(JsdocTag[tag
|
|
249
|
+
comment: 'JsdocBlock:has(JsdocTag[tag=/^yields?$/]:not([parsedType.type]))',
|
|
250
250
|
context: 'any',
|
|
251
251
|
message: '@yields should have a type',
|
|
252
252
|
},
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
|
|
9
9
|
const digitRegex = (/^(\d+(\.\d*)?|\.\d+)([eE][\-+]?\d+)?$/v);
|
|
10
10
|
|
|
11
|
+
// eslint-disable-next-line complexity -- Todo
|
|
11
12
|
export default iterateJsdoc(({
|
|
12
13
|
context,
|
|
13
14
|
indent,
|
|
@@ -17,16 +18,32 @@ export default iterateJsdoc(({
|
|
|
17
18
|
}) => {
|
|
18
19
|
const {
|
|
19
20
|
arrayBrackets = 'square',
|
|
21
|
+
arrowFunctionPostReturnMarkerSpacing = ' ',
|
|
22
|
+
arrowFunctionPreReturnMarkerSpacing = ' ',
|
|
20
23
|
enableFixer = true,
|
|
24
|
+
functionOrClassParameterSpacing = ' ',
|
|
25
|
+
functionOrClassPostGenericSpacing = '',
|
|
26
|
+
functionOrClassPostReturnMarkerSpacing = ' ',
|
|
27
|
+
functionOrClassPreReturnMarkerSpacing = '',
|
|
28
|
+
functionOrClassTypeParameterSpacing = ' ',
|
|
29
|
+
genericAndTupleElementSpacing = ' ',
|
|
21
30
|
genericDot = false,
|
|
31
|
+
keyValuePostColonSpacing = ' ',
|
|
32
|
+
keyValuePostKeySpacing = '',
|
|
33
|
+
keyValuePostOptionalSpacing = '',
|
|
34
|
+
keyValuePostVariadicSpacing = '',
|
|
35
|
+
methodQuotes = 'double',
|
|
22
36
|
objectFieldIndent = '',
|
|
23
37
|
objectFieldQuote = null,
|
|
24
38
|
objectFieldSeparator = 'comma',
|
|
25
39
|
objectFieldSeparatorOptionalLinebreak = true,
|
|
26
40
|
objectFieldSeparatorTrailingPunctuation = false,
|
|
41
|
+
parameterDefaultValueSpacing = ' ',
|
|
42
|
+
postMethodNameSpacing = '',
|
|
43
|
+
postNewSpacing = ' ',
|
|
27
44
|
// propertyQuotes = null,
|
|
28
45
|
separatorForSingleObjectField = false,
|
|
29
|
-
stringQuotes = '
|
|
46
|
+
stringQuotes = 'double',
|
|
30
47
|
typeBracketSpacing = '',
|
|
31
48
|
unionSpacing = ' ',
|
|
32
49
|
} = context.options[0] || {};
|
|
@@ -215,7 +232,177 @@ export default iterateJsdoc(({
|
|
|
215
232
|
traverse(parsedType, (nde) => {
|
|
216
233
|
let errorMessage = '';
|
|
217
234
|
|
|
235
|
+
/**
|
|
236
|
+
* @param {Partial<import('jsdoc-type-pratt-parser').FunctionResult['meta']> & {
|
|
237
|
+
* postNewSpacing?: string,
|
|
238
|
+
* postMethodNameSpacing?: string
|
|
239
|
+
* }} meta
|
|
240
|
+
* @returns {Required<import('jsdoc-type-pratt-parser').FunctionResult['meta']> & {
|
|
241
|
+
* postNewSpacing?: string,
|
|
242
|
+
* postMethodNameSpacing?: string
|
|
243
|
+
* }}
|
|
244
|
+
*/
|
|
245
|
+
const conditionalAdds = (meta) => {
|
|
246
|
+
const typNode =
|
|
247
|
+
/**
|
|
248
|
+
* @type {import('jsdoc-type-pratt-parser').FunctionResult|
|
|
249
|
+
* import('jsdoc-type-pratt-parser').CallSignatureResult|
|
|
250
|
+
* import('jsdoc-type-pratt-parser').ComputedMethodResult|
|
|
251
|
+
* import('jsdoc-type-pratt-parser').ConstructorSignatureResult|
|
|
252
|
+
* import('jsdoc-type-pratt-parser').MethodSignatureResult
|
|
253
|
+
* }
|
|
254
|
+
*/ (nde);
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* @type {Required<import('jsdoc-type-pratt-parser').FunctionResult['meta']> & {
|
|
258
|
+
* postNewSpacing?: string,
|
|
259
|
+
* postMethodNameSpacing?: string
|
|
260
|
+
* }}
|
|
261
|
+
*/
|
|
262
|
+
const newMeta = {
|
|
263
|
+
parameterSpacing: meta.parameterSpacing ?? typNode.meta?.parameterSpacing ?? ' ',
|
|
264
|
+
postGenericSpacing: meta.postGenericSpacing ?? typNode.meta?.postGenericSpacing ?? '',
|
|
265
|
+
postReturnMarkerSpacing: meta.postReturnMarkerSpacing ?? typNode.meta?.postReturnMarkerSpacing ?? ' ',
|
|
266
|
+
preReturnMarkerSpacing: meta.preReturnMarkerSpacing ?? typNode.meta?.preReturnMarkerSpacing ?? '',
|
|
267
|
+
typeParameterSpacing: meta.typeParameterSpacing ?? typNode.meta?.typeParameterSpacing ?? ' ',
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
if (typNode.type === 'JsdocTypeConstructorSignature') {
|
|
271
|
+
newMeta.postNewSpacing = meta.postNewSpacing;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (typNode.type === 'JsdocTypeMethodSignature') {
|
|
275
|
+
newMeta.postMethodNameSpacing = meta.postMethodNameSpacing ?? typNode.meta?.postMethodNameSpacing ?? '';
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return newMeta;
|
|
279
|
+
};
|
|
280
|
+
|
|
218
281
|
switch (nde.type) {
|
|
282
|
+
case 'JsdocTypeConstructorSignature': {
|
|
283
|
+
const typeNode = /** @type {import('jsdoc-type-pratt-parser').ConstructorSignatureResult} */ (nde);
|
|
284
|
+
/* c8 ignore next -- Guard */
|
|
285
|
+
if ((typeNode.meta?.postNewSpacing ?? ' ') !== postNewSpacing) {
|
|
286
|
+
typeNode.meta =
|
|
287
|
+
/**
|
|
288
|
+
* @type {Required<import('jsdoc-type-pratt-parser').FunctionResult['meta']> & {
|
|
289
|
+
* postNewSpacing: string,
|
|
290
|
+
* }}
|
|
291
|
+
*/ (conditionalAdds({
|
|
292
|
+
postNewSpacing,
|
|
293
|
+
}));
|
|
294
|
+
errorMessage = `Post-\`new\` spacing should be "${postNewSpacing}"`;
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
case 'JsdocTypeFunction': {
|
|
300
|
+
const typeNode =
|
|
301
|
+
/**
|
|
302
|
+
* @type {import('jsdoc-type-pratt-parser').FunctionResult}
|
|
303
|
+
*/ nde;
|
|
304
|
+
if ('arrow' in typeNode && typeNode.arrow) {
|
|
305
|
+
/* c8 ignore next -- Guard */
|
|
306
|
+
if ((typeNode.meta?.postReturnMarkerSpacing ?? ' ') !== arrowFunctionPostReturnMarkerSpacing) {
|
|
307
|
+
typeNode.meta =
|
|
308
|
+
/**
|
|
309
|
+
* @type {Required<import('jsdoc-type-pratt-parser').FunctionResult['meta']> & {
|
|
310
|
+
* postNewSpacing: string,
|
|
311
|
+
* }}
|
|
312
|
+
*/ (conditionalAdds({
|
|
313
|
+
postReturnMarkerSpacing: arrowFunctionPostReturnMarkerSpacing,
|
|
314
|
+
/* c8 ignore next -- Guard */
|
|
315
|
+
preReturnMarkerSpacing: typeNode.meta?.preReturnMarkerSpacing ?? ' ',
|
|
316
|
+
}));
|
|
317
|
+
errorMessage = `Post-return-marker spacing should be "${arrowFunctionPostReturnMarkerSpacing}"`;
|
|
318
|
+
break;
|
|
319
|
+
/* c8 ignore next -- Guard */
|
|
320
|
+
} else if ((typeNode.meta?.preReturnMarkerSpacing ?? ' ') !== arrowFunctionPreReturnMarkerSpacing) {
|
|
321
|
+
typeNode.meta =
|
|
322
|
+
/**
|
|
323
|
+
* @type {Required<import('jsdoc-type-pratt-parser').FunctionResult['meta']> & {
|
|
324
|
+
* postNewSpacing: string,
|
|
325
|
+
* }}
|
|
326
|
+
*/ (conditionalAdds({
|
|
327
|
+
/* c8 ignore next -- Guard */
|
|
328
|
+
postReturnMarkerSpacing: typeNode.meta?.postReturnMarkerSpacing ?? ' ',
|
|
329
|
+
preReturnMarkerSpacing: arrowFunctionPreReturnMarkerSpacing,
|
|
330
|
+
}));
|
|
331
|
+
errorMessage = `Pre-return-marker spacing should be "${arrowFunctionPreReturnMarkerSpacing}"`;
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
case 'JsdocTypeCallSignature':
|
|
340
|
+
case 'JsdocTypeComputedMethod':
|
|
341
|
+
case 'JsdocTypeMethodSignature': {
|
|
342
|
+
const typeNode =
|
|
343
|
+
/**
|
|
344
|
+
* @type {import('jsdoc-type-pratt-parser').FunctionResult|
|
|
345
|
+
* import('jsdoc-type-pratt-parser').CallSignatureResult|
|
|
346
|
+
* import('jsdoc-type-pratt-parser').ComputedMethodResult|
|
|
347
|
+
* import('jsdoc-type-pratt-parser').ConstructorSignatureResult|
|
|
348
|
+
* import('jsdoc-type-pratt-parser').MethodSignatureResult
|
|
349
|
+
* }
|
|
350
|
+
*/ (nde);
|
|
351
|
+
if (typeNode.type === 'JsdocTypeMethodSignature' &&
|
|
352
|
+
(typeNode.meta?.postMethodNameSpacing ?? '') !== postMethodNameSpacing
|
|
353
|
+
) {
|
|
354
|
+
typeNode.meta = {
|
|
355
|
+
quote: typeNode.meta.quote,
|
|
356
|
+
...conditionalAdds({
|
|
357
|
+
postMethodNameSpacing,
|
|
358
|
+
}),
|
|
359
|
+
};
|
|
360
|
+
errorMessage = `Post-method-name spacing should be "${postMethodNameSpacing}"`;
|
|
361
|
+
break;
|
|
362
|
+
} else if (typeNode.type === 'JsdocTypeMethodSignature' &&
|
|
363
|
+
typeNode.meta.quote !== undefined &&
|
|
364
|
+
typeNode.meta.quote !== methodQuotes
|
|
365
|
+
) {
|
|
366
|
+
typeNode.meta = {
|
|
367
|
+
...conditionalAdds({
|
|
368
|
+
postMethodNameSpacing: typeNode.meta.postMethodNameSpacing ?? '',
|
|
369
|
+
}),
|
|
370
|
+
quote: methodQuotes,
|
|
371
|
+
};
|
|
372
|
+
errorMessage = `Method quoting style should be "${methodQuotes}"`;
|
|
373
|
+
break;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
if ((typeNode.meta?.parameterSpacing ?? ' ') !== functionOrClassParameterSpacing) {
|
|
377
|
+
typeNode.meta = conditionalAdds({
|
|
378
|
+
parameterSpacing: functionOrClassParameterSpacing,
|
|
379
|
+
});
|
|
380
|
+
errorMessage = `Parameter spacing should be "${functionOrClassParameterSpacing}"`;
|
|
381
|
+
} else if ((typeNode.meta?.postGenericSpacing ?? '') !== functionOrClassPostGenericSpacing) {
|
|
382
|
+
typeNode.meta = conditionalAdds({
|
|
383
|
+
postGenericSpacing: functionOrClassPostGenericSpacing,
|
|
384
|
+
});
|
|
385
|
+
errorMessage = `Post-generic spacing should be "${functionOrClassPostGenericSpacing}"`;
|
|
386
|
+
} else if ((typeNode.meta?.postReturnMarkerSpacing ?? ' ') !== functionOrClassPostReturnMarkerSpacing) {
|
|
387
|
+
typeNode.meta = conditionalAdds({
|
|
388
|
+
postReturnMarkerSpacing: functionOrClassPostReturnMarkerSpacing,
|
|
389
|
+
});
|
|
390
|
+
errorMessage = `Post-return-marker spacing should be "${functionOrClassPostReturnMarkerSpacing}"`;
|
|
391
|
+
} else if ((typeNode.meta?.preReturnMarkerSpacing ?? '') !== functionOrClassPreReturnMarkerSpacing) {
|
|
392
|
+
typeNode.meta = conditionalAdds({
|
|
393
|
+
preReturnMarkerSpacing: functionOrClassPreReturnMarkerSpacing,
|
|
394
|
+
});
|
|
395
|
+
errorMessage = `Pre-return-marker spacing should be "${functionOrClassPreReturnMarkerSpacing}"`;
|
|
396
|
+
} else if ((typeNode.meta?.typeParameterSpacing ?? ' ') !== functionOrClassTypeParameterSpacing) {
|
|
397
|
+
typeNode.meta = conditionalAdds({
|
|
398
|
+
typeParameterSpacing: functionOrClassTypeParameterSpacing,
|
|
399
|
+
});
|
|
400
|
+
errorMessage = `Type parameter spacing should be "${functionOrClassTypeParameterSpacing}"`;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
|
|
219
406
|
case 'JsdocTypeGeneric': {
|
|
220
407
|
const typeNode = /** @type {import('jsdoc-type-pratt-parser').GenericResult} */ (nde);
|
|
221
408
|
if ('value' in typeNode.left && typeNode.left.value === 'Array') {
|
|
@@ -226,6 +413,58 @@ export default iterateJsdoc(({
|
|
|
226
413
|
} else if (typeNode.meta.dot !== genericDot) {
|
|
227
414
|
typeNode.meta.dot = genericDot;
|
|
228
415
|
errorMessage = `Dot usage should be ${genericDot}`;
|
|
416
|
+
} else if ((typeNode.meta.elementSpacing ?? ' ') !== genericAndTupleElementSpacing) {
|
|
417
|
+
typeNode.meta.elementSpacing = genericAndTupleElementSpacing;
|
|
418
|
+
errorMessage = `Element spacing should be "${genericAndTupleElementSpacing}"`;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
break;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
case 'JsdocTypeKeyValue': {
|
|
425
|
+
const typeNode = /** @type {import('jsdoc-type-pratt-parser').KeyValueResult} */ (nde);
|
|
426
|
+
/* c8 ignore next -- Guard */
|
|
427
|
+
if ((typeNode.meta?.postKeySpacing ?? '') !== keyValuePostKeySpacing) {
|
|
428
|
+
typeNode.meta = {
|
|
429
|
+
/* c8 ignore next -- Guard */
|
|
430
|
+
postColonSpacing: typeNode.meta?.postColonSpacing ?? ' ',
|
|
431
|
+
postKeySpacing: keyValuePostKeySpacing,
|
|
432
|
+
/* c8 ignore next 2 -- Guard */
|
|
433
|
+
postOptionalSpacing: typeNode.meta?.postOptionalSpacing ?? '',
|
|
434
|
+
postVariadicSpacing: typeNode.meta?.postVariadicSpacing ?? '',
|
|
435
|
+
};
|
|
436
|
+
errorMessage = `Post key spacing should be "${keyValuePostKeySpacing}"`;
|
|
437
|
+
/* c8 ignore next -- Guard */
|
|
438
|
+
} else if ((typeNode.meta?.postColonSpacing ?? ' ') !== keyValuePostColonSpacing) {
|
|
439
|
+
typeNode.meta = {
|
|
440
|
+
postColonSpacing: keyValuePostColonSpacing,
|
|
441
|
+
/* c8 ignore next 3 -- Guard */
|
|
442
|
+
postKeySpacing: typeNode.meta?.postKeySpacing ?? '',
|
|
443
|
+
postOptionalSpacing: typeNode.meta?.postOptionalSpacing ?? '',
|
|
444
|
+
postVariadicSpacing: typeNode.meta?.postVariadicSpacing ?? '',
|
|
445
|
+
};
|
|
446
|
+
errorMessage = `Post colon spacing should be "${keyValuePostColonSpacing}"`;
|
|
447
|
+
/* c8 ignore next -- Guard */
|
|
448
|
+
} else if ((typeNode.meta?.postOptionalSpacing ?? '') !== keyValuePostOptionalSpacing) {
|
|
449
|
+
typeNode.meta = {
|
|
450
|
+
/* c8 ignore next 2 -- Guard */
|
|
451
|
+
postColonSpacing: typeNode.meta?.postColonSpacing ?? ' ',
|
|
452
|
+
postKeySpacing: typeNode.meta?.postKeySpacing ?? '',
|
|
453
|
+
postOptionalSpacing: keyValuePostOptionalSpacing,
|
|
454
|
+
/* c8 ignore next -- Guard */
|
|
455
|
+
postVariadicSpacing: typeNode.meta?.postVariadicSpacing ?? '',
|
|
456
|
+
};
|
|
457
|
+
errorMessage = `Post optional (\`?\`) spacing should be "${keyValuePostOptionalSpacing}"`;
|
|
458
|
+
/* c8 ignore next -- Guard */
|
|
459
|
+
} else if (typeNode.variadic && (typeNode.meta?.postVariadicSpacing ?? '') !== keyValuePostVariadicSpacing) {
|
|
460
|
+
typeNode.meta = {
|
|
461
|
+
/* c8 ignore next 3 -- Guard */
|
|
462
|
+
postColonSpacing: typeNode.meta?.postColonSpacing ?? ' ',
|
|
463
|
+
postKeySpacing: typeNode.meta?.postKeySpacing ?? '',
|
|
464
|
+
postOptionalSpacing: typeNode.meta?.postOptionalSpacing ?? '',
|
|
465
|
+
postVariadicSpacing: keyValuePostVariadicSpacing,
|
|
466
|
+
};
|
|
467
|
+
errorMessage = `Post variadic (\`...\`) spacing should be "${keyValuePostVariadicSpacing}"`;
|
|
229
468
|
}
|
|
230
469
|
|
|
231
470
|
break;
|
|
@@ -272,6 +511,25 @@ export default iterateJsdoc(({
|
|
|
272
511
|
) {
|
|
273
512
|
typeNode.meta.quote = objectFieldQuote ?? undefined;
|
|
274
513
|
errorMessage = `Inconsistent object field quotes ${objectFieldQuote}`;
|
|
514
|
+
} else if ((typeNode.meta?.postKeySpacing ?? '') !== keyValuePostKeySpacing) {
|
|
515
|
+
typeNode.meta.postKeySpacing = keyValuePostKeySpacing;
|
|
516
|
+
errorMessage = `Post key spacing should be "${keyValuePostKeySpacing}"`;
|
|
517
|
+
} else if ((typeNode.meta?.postColonSpacing ?? ' ') !== keyValuePostColonSpacing) {
|
|
518
|
+
typeNode.meta.postColonSpacing = keyValuePostColonSpacing;
|
|
519
|
+
errorMessage = `Post colon spacing should be "${keyValuePostColonSpacing}"`;
|
|
520
|
+
} else if ((typeNode.meta?.postOptionalSpacing ?? '') !== keyValuePostOptionalSpacing) {
|
|
521
|
+
typeNode.meta.postOptionalSpacing = keyValuePostOptionalSpacing;
|
|
522
|
+
errorMessage = `Post optional (\`?\`) spacing should be "${keyValuePostOptionalSpacing}"`;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
break;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
case 'JsdocTypeStringValue': {
|
|
529
|
+
const typeNode = /** @type {import('jsdoc-type-pratt-parser').StringValueResult} */ (nde);
|
|
530
|
+
if (typeNode.meta.quote !== stringQuotes) {
|
|
531
|
+
typeNode.meta.quote = stringQuotes;
|
|
532
|
+
errorMessage = `Inconsistent ${stringQuotes} string quotes usage`;
|
|
275
533
|
}
|
|
276
534
|
|
|
277
535
|
break;
|
|
@@ -292,11 +550,27 @@ export default iterateJsdoc(({
|
|
|
292
550
|
// break;
|
|
293
551
|
// }
|
|
294
552
|
|
|
295
|
-
case '
|
|
296
|
-
const typeNode = /** @type {import('jsdoc-type-pratt-parser').
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
553
|
+
case 'JsdocTypeTuple': {
|
|
554
|
+
const typeNode = /** @type {import('jsdoc-type-pratt-parser').TupleResult} */ (nde);
|
|
555
|
+
/* c8 ignore next -- Guard */
|
|
556
|
+
if ((typeNode.meta?.elementSpacing ?? ' ') !== genericAndTupleElementSpacing) {
|
|
557
|
+
typeNode.meta = {
|
|
558
|
+
elementSpacing: genericAndTupleElementSpacing,
|
|
559
|
+
};
|
|
560
|
+
errorMessage = `Element spacing should be "${genericAndTupleElementSpacing}"`;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
break;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
case 'JsdocTypeTypeParameter': {
|
|
567
|
+
const typeNode = /** @type {import('jsdoc-type-pratt-parser').TypeParameterResult} */ (nde);
|
|
568
|
+
/* c8 ignore next -- Guard */
|
|
569
|
+
if (typeNode.defaultValue && (typeNode.meta?.defaultValueSpacing ?? ' ') !== parameterDefaultValueSpacing) {
|
|
570
|
+
typeNode.meta = {
|
|
571
|
+
defaultValueSpacing: parameterDefaultValueSpacing,
|
|
572
|
+
};
|
|
573
|
+
errorMessage = `Default value spacing should be "${parameterDefaultValueSpacing}"`;
|
|
300
574
|
}
|
|
301
575
|
|
|
302
576
|
break;
|
|
@@ -377,14 +651,70 @@ export default iterateJsdoc(({
|
|
|
377
651
|
],
|
|
378
652
|
type: 'string',
|
|
379
653
|
},
|
|
654
|
+
arrowFunctionPostReturnMarkerSpacing: {
|
|
655
|
+
description: 'The space character (if any) to use after return markers (`=>`). Defaults to " ".',
|
|
656
|
+
type: 'string',
|
|
657
|
+
},
|
|
658
|
+
arrowFunctionPreReturnMarkerSpacing: {
|
|
659
|
+
description: 'The space character (if any) to use before return markers (`=>`). Defaults to " ".',
|
|
660
|
+
type: 'string',
|
|
661
|
+
},
|
|
380
662
|
enableFixer: {
|
|
381
663
|
description: 'Whether to enable the fixer. Defaults to `true`.',
|
|
382
664
|
type: 'boolean',
|
|
383
665
|
},
|
|
666
|
+
functionOrClassParameterSpacing: {
|
|
667
|
+
description: 'The space character (if any) to use between function or class parameters. Defaults to " ".',
|
|
668
|
+
type: 'string',
|
|
669
|
+
},
|
|
670
|
+
functionOrClassPostGenericSpacing: {
|
|
671
|
+
description: 'The space character (if any) to use after a generic expression in a function or class. Defaults to "".',
|
|
672
|
+
type: 'string',
|
|
673
|
+
},
|
|
674
|
+
functionOrClassPostReturnMarkerSpacing: {
|
|
675
|
+
description: 'The space character (if any) to use after return markers (`:`). Defaults to "".',
|
|
676
|
+
type: 'string',
|
|
677
|
+
},
|
|
678
|
+
functionOrClassPreReturnMarkerSpacing: {
|
|
679
|
+
description: 'The space character (if any) to use before return markers (`:`). Defaults to "".',
|
|
680
|
+
type: 'string',
|
|
681
|
+
},
|
|
682
|
+
functionOrClassTypeParameterSpacing: {
|
|
683
|
+
description: 'The space character (if any) to use between type parameters in a function or class. Defaults to " ".',
|
|
684
|
+
type: 'string',
|
|
685
|
+
},
|
|
686
|
+
genericAndTupleElementSpacing: {
|
|
687
|
+
description: 'The space character (if any) to use between elements in generics and tuples. Defaults to " ".',
|
|
688
|
+
type: 'string',
|
|
689
|
+
},
|
|
384
690
|
genericDot: {
|
|
385
691
|
description: 'Boolean value of whether to use a dot before the angled brackets of a generic (e.g., `SomeType.<AnotherType>`). Defaults to `false`.',
|
|
386
692
|
type: 'boolean',
|
|
387
693
|
},
|
|
694
|
+
keyValuePostColonSpacing: {
|
|
695
|
+
description: 'The amount of spacing (if any) after the colon of a key-value or object-field pair. Defaults to " ".',
|
|
696
|
+
type: 'string',
|
|
697
|
+
},
|
|
698
|
+
keyValuePostKeySpacing: {
|
|
699
|
+
description: 'The amount of spacing (if any) immediately after keys in a key-value or object-field pair. Defaults to "".',
|
|
700
|
+
type: 'string',
|
|
701
|
+
},
|
|
702
|
+
keyValuePostOptionalSpacing: {
|
|
703
|
+
description: 'The amount of spacing (if any) after the optional operator (`?`) in a key-value or object-field pair. Defaults to "".',
|
|
704
|
+
type: 'string',
|
|
705
|
+
},
|
|
706
|
+
keyValuePostVariadicSpacing: {
|
|
707
|
+
description: 'The amount of spacing (if any) after a variadic operator (`...`) in a key-value pair. Defaults to "".',
|
|
708
|
+
type: 'string',
|
|
709
|
+
},
|
|
710
|
+
methodQuotes: {
|
|
711
|
+
description: 'The style of quotation mark for surrounding method names when quoted. Defaults to `double`',
|
|
712
|
+
enum: [
|
|
713
|
+
'double',
|
|
714
|
+
'single',
|
|
715
|
+
],
|
|
716
|
+
type: 'string',
|
|
717
|
+
},
|
|
388
718
|
objectFieldIndent: {
|
|
389
719
|
description: `A string indicating the whitespace to be added on each line preceding an
|
|
390
720
|
object property-value field. Defaults to the empty string.`,
|
|
@@ -431,6 +761,18 @@ will determine whether to add punctuation corresponding to the
|
|
|
431
761
|
Defaults to \`false\`.`,
|
|
432
762
|
type: 'boolean',
|
|
433
763
|
},
|
|
764
|
+
parameterDefaultValueSpacing: {
|
|
765
|
+
description: 'The space character (if any) to use between the equal signs of a default value. Defaults to " ".',
|
|
766
|
+
type: 'string',
|
|
767
|
+
},
|
|
768
|
+
postMethodNameSpacing: {
|
|
769
|
+
description: 'The space character (if any) to add after a method name. Defaults to "".',
|
|
770
|
+
type: 'string',
|
|
771
|
+
},
|
|
772
|
+
postNewSpacing: {
|
|
773
|
+
description: 'The space character (if any) to add after "new" in a constructor. Defaults to " ".',
|
|
774
|
+
type: 'string',
|
|
775
|
+
},
|
|
434
776
|
// propertyQuotes: {
|
|
435
777
|
// description: `Whether and how namepath properties should be quoted (e.g., \`ab."cd"."ef"\`).
|
|
436
778
|
// Set to \`single\`, \`double\`, or \`null\`. Defaults to \`null\` (no quotes unless
|
|
@@ -448,7 +790,7 @@ is only one property-value object field present. Defaults to \`false\`.`,
|
|
|
448
790
|
},
|
|
449
791
|
stringQuotes: {
|
|
450
792
|
description: `How string literals should be quoted (e.g., \`"abc"\`). Set to \`single\`
|
|
451
|
-
or \`double\`. Defaults to '
|
|
793
|
+
or \`double\`. Defaults to 'double'.`,
|
|
452
794
|
enum: [
|
|
453
795
|
'double',
|
|
454
796
|
'single',
|