eslint-plugin-jsdoc 50.8.0 → 51.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/alignTransform.cjs +5 -5
- package/dist/alignTransform.cjs.map +1 -1
- package/dist/exportParser.cjs +2 -3
- package/dist/exportParser.cjs.map +1 -1
- package/dist/generateRule.cjs +2 -5
- package/dist/generateRule.cjs.map +1 -1
- package/dist/getJsdocProcessorPlugin.cjs +2 -4
- package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
- package/dist/iterateJsdoc.cjs +29 -34
- package/dist/iterateJsdoc.cjs.map +1 -1
- package/dist/jsdocUtils.cjs +19 -31
- package/dist/jsdocUtils.cjs.map +1 -1
- package/dist/rules/checkLineAlignment.cjs +3 -3
- package/dist/rules/checkLineAlignment.cjs.map +1 -1
- package/dist/rules/checkParamNames.cjs +2 -3
- package/dist/rules/checkParamNames.cjs.map +1 -1
- package/dist/rules/checkTagNames.cjs +1 -2
- package/dist/rules/checkTagNames.cjs.map +1 -1
- package/dist/rules/checkTemplateNames.cjs +1 -2
- package/dist/rules/checkTemplateNames.cjs.map +1 -1
- package/dist/rules/checkTypes.cjs +11 -13
- package/dist/rules/checkTypes.cjs.map +1 -1
- package/dist/rules/convertToJsdocComments.cjs +2 -3
- package/dist/rules/convertToJsdocComments.cjs.map +1 -1
- package/dist/rules/informativeDocs.cjs +1 -1
- package/dist/rules/informativeDocs.cjs.map +1 -1
- package/dist/rules/linesBeforeBlock.cjs +8 -11
- package/dist/rules/linesBeforeBlock.cjs.map +1 -1
- package/dist/rules/noBadBlocks.cjs +1 -2
- package/dist/rules/noBadBlocks.cjs.map +1 -1
- package/dist/rules/noMissingSyntax.cjs +5 -5
- package/dist/rules/noMissingSyntax.cjs.map +1 -1
- package/dist/rules/noRestrictedSyntax.cjs +1 -1
- package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
- package/dist/rules/noUndefinedTypes.cjs +5 -9
- package/dist/rules/noUndefinedTypes.cjs.map +1 -1
- package/dist/rules/requireAsteriskPrefix.cjs +4 -8
- package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
- package/dist/rules/requireJsdoc.cjs +5 -6
- package/dist/rules/requireJsdoc.cjs.map +1 -1
- package/dist/rules/requireReturns.cjs +4 -4
- package/dist/rules/requireReturns.cjs.map +1 -1
- package/dist/rules/requireTemplate.cjs +2 -3
- package/dist/rules/requireTemplate.cjs.map +1 -1
- package/dist/rules/sortTags.cjs +3 -6
- package/dist/rules/sortTags.cjs.map +1 -1
- package/dist/rules/tagLines.cjs +8 -12
- package/dist/rules/tagLines.cjs.map +1 -1
- package/dist/rules/validTypes.cjs +1 -2
- package/dist/rules/validTypes.cjs.map +1 -1
- package/dist/utils/hasReturnValue.cjs +7 -15
- package/dist/utils/hasReturnValue.cjs.map +1 -1
- package/package.json +5 -5
- package/src/getJsdocProcessorPlugin.js +1 -7
package/dist/jsdocUtils.cjs
CHANGED
|
@@ -189,7 +189,6 @@ const getPropertiesFromPropertySignature = propSignature => {
|
|
|
189
189
|
* @returns {ParamNameInfo[]}
|
|
190
190
|
*/
|
|
191
191
|
const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
|
|
192
|
-
var _functionNode$value;
|
|
193
192
|
/* eslint-disable complexity -- Temporary */
|
|
194
193
|
/**
|
|
195
194
|
* @param {import('estree').Identifier|import('estree').AssignmentPattern|
|
|
@@ -207,14 +206,12 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
|
|
|
207
206
|
* @returns {ParamNameInfo|[string, ParamNameInfo[]]}
|
|
208
207
|
*/
|
|
209
208
|
const getParamName = (param, isProperty) => {
|
|
210
|
-
var _param$left2;
|
|
211
209
|
/* eslint-enable complexity -- Temporary */
|
|
212
210
|
const hasLeftTypeAnnotation = 'left' in param && 'typeAnnotation' in param.left;
|
|
213
211
|
if ('typeAnnotation' in param || hasLeftTypeAnnotation) {
|
|
214
|
-
var _typeAnnotation$typeA;
|
|
215
212
|
const typeAnnotation = hasLeftTypeAnnotation ? /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */param.left.typeAnnotation : /** @type {import('@typescript-eslint/types').TSESTree.Identifier|import('@typescript-eslint/types').TSESTree.ObjectPattern} */
|
|
216
213
|
param.typeAnnotation;
|
|
217
|
-
if (
|
|
214
|
+
if (typeAnnotation?.typeAnnotation?.type === 'TSTypeLiteral') {
|
|
218
215
|
const propertyNames = typeAnnotation.typeAnnotation.members.map(member => {
|
|
219
216
|
return getPropertiesFromPropertySignature(/** @type {import('@typescript-eslint/types').TSESTree.TSPropertySignature} */
|
|
220
217
|
member);
|
|
@@ -237,8 +234,8 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
|
|
|
237
234
|
return param.left.name;
|
|
238
235
|
}
|
|
239
236
|
if (param.type === 'ObjectPattern' || 'left' in param && param.left.type === 'ObjectPattern') {
|
|
240
|
-
|
|
241
|
-
|
|
237
|
+
const properties = /** @type {import('@typescript-eslint/types').TSESTree.ObjectPattern} */param.properties || /** @type {import('estree').ObjectPattern} */
|
|
238
|
+
(/** @type {import('@typescript-eslint/types').TSESTree.AssignmentPattern} */param.left)?.properties;
|
|
242
239
|
const roots = properties.map(prop => {
|
|
243
240
|
return getParamName(prop, true);
|
|
244
241
|
});
|
|
@@ -252,7 +249,7 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
|
|
|
252
249
|
param.key.name, /** @type {import('estree').ArrayPattern} */param.value.elements.map((prop, idx) => {
|
|
253
250
|
return {
|
|
254
251
|
name: idx,
|
|
255
|
-
restElement:
|
|
252
|
+
restElement: prop?.type === 'RestElement'
|
|
256
253
|
};
|
|
257
254
|
})];
|
|
258
255
|
}
|
|
@@ -270,7 +267,7 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
|
|
|
270
267
|
param.key.name, /** @type {import('estree').ArrayPattern} */param.value.left.elements.map((prop, idx) => {
|
|
271
268
|
return {
|
|
272
269
|
name: idx,
|
|
273
|
-
restElement:
|
|
270
|
+
restElement: prop?.type === 'RestElement'
|
|
274
271
|
};
|
|
275
272
|
})];
|
|
276
273
|
case 'Identifier':
|
|
@@ -308,29 +305,27 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
|
|
|
308
305
|
return undefined;
|
|
309
306
|
}
|
|
310
307
|
}
|
|
311
|
-
if (param.type === 'ArrayPattern' || /** @type {import('estree').AssignmentPattern} */
|
|
312
|
-
|
|
313
|
-
const elements = /** @type {import('estree').ArrayPattern} */param.elements || (/** @type {import('estree').ArrayPattern} */(_param$left3 = /** @type {import('estree').AssignmentPattern} */param.left) === null || _param$left3 === void 0 ? void 0 : _param$left3.elements);
|
|
308
|
+
if (param.type === 'ArrayPattern' || /** @type {import('estree').AssignmentPattern} */param.left?.type === 'ArrayPattern') {
|
|
309
|
+
const elements = /** @type {import('estree').ArrayPattern} */param.elements || /** @type {import('estree').ArrayPattern} */(/** @type {import('estree').AssignmentPattern} */param.left)?.elements;
|
|
314
310
|
const roots = elements.map((prop, idx) => {
|
|
315
311
|
return {
|
|
316
312
|
name: `"${idx}"`,
|
|
317
|
-
restElement:
|
|
313
|
+
restElement: prop?.type === 'RestElement'
|
|
318
314
|
};
|
|
319
315
|
});
|
|
320
316
|
return [undefined, flattenRoots(roots)];
|
|
321
317
|
}
|
|
322
318
|
if (['ExperimentalRestProperty', 'RestElement'].includes(param.type)) {
|
|
323
|
-
var _param$argument;
|
|
324
319
|
return {
|
|
325
320
|
isRestProperty: isProperty,
|
|
326
321
|
name: /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */(/** @type {import('@typescript-eslint/types').TSESTree.RestElement} */param
|
|
327
322
|
// @ts-expect-error Ok
|
|
328
|
-
.argument).name ??
|
|
323
|
+
.argument).name ?? param?.argument?.elements?.map(({
|
|
329
324
|
// @ts-expect-error Ok
|
|
330
325
|
name
|
|
331
326
|
}) => {
|
|
332
327
|
return name;
|
|
333
|
-
})
|
|
328
|
+
}),
|
|
334
329
|
restElement: true
|
|
335
330
|
};
|
|
336
331
|
}
|
|
@@ -343,7 +338,7 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
|
|
|
343
338
|
if (!functionNode) {
|
|
344
339
|
return [];
|
|
345
340
|
}
|
|
346
|
-
return (/** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */functionNode.params ||
|
|
341
|
+
return (/** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */functionNode.params || /** @type {import('@typescript-eslint/types').TSESTree.MethodDefinition} */functionNode.value?.params || []).map(param => {
|
|
347
342
|
return getParamName(param);
|
|
348
343
|
});
|
|
349
344
|
};
|
|
@@ -490,7 +485,6 @@ context = {
|
|
|
490
485
|
// No-op
|
|
491
486
|
}
|
|
492
487
|
}) => {
|
|
493
|
-
var _Object$entries$find;
|
|
494
488
|
const prefValues = Object.values(tagPreference);
|
|
495
489
|
if (prefValues.includes(name) || prefValues.some(prefVal => {
|
|
496
490
|
return prefVal && typeof prefVal === 'object' && prefVal.replacement === name;
|
|
@@ -510,9 +504,9 @@ context = {
|
|
|
510
504
|
return tagPreferenceFixed[name];
|
|
511
505
|
}
|
|
512
506
|
const tagNames = getTagNamesForMode(mode, context);
|
|
513
|
-
const preferredTagName =
|
|
507
|
+
const preferredTagName = Object.entries(tagNames).find(([, aliases]) => {
|
|
514
508
|
return aliases.includes(name);
|
|
515
|
-
})
|
|
509
|
+
})?.[0];
|
|
516
510
|
if (preferredTagName) {
|
|
517
511
|
return preferredTagName;
|
|
518
512
|
}
|
|
@@ -1263,8 +1257,7 @@ const parseClosureTemplateTag = tag => {
|
|
|
1263
1257
|
*/
|
|
1264
1258
|
exports.parseClosureTemplateTag = parseClosureTemplateTag;
|
|
1265
1259
|
const enforcedContexts = (context, defaultContexts, settings) => {
|
|
1266
|
-
|
|
1267
|
-
const contexts = ((_context$options$ = context.options[0]) === null || _context$options$ === void 0 ? void 0 : _context$options$.contexts) || settings.contexts || (defaultContexts === true ? ['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction'] : defaultContexts);
|
|
1260
|
+
const contexts = context.options[0]?.contexts || settings.contexts || (defaultContexts === true ? ['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction'] : defaultContexts);
|
|
1268
1261
|
return contexts;
|
|
1269
1262
|
};
|
|
1270
1263
|
|
|
@@ -1378,8 +1371,7 @@ const getTagsByType = (context, mode, tags) => {
|
|
|
1378
1371
|
*/
|
|
1379
1372
|
exports.getTagsByType = getTagsByType;
|
|
1380
1373
|
const getIndent = sourceCode => {
|
|
1381
|
-
|
|
1382
|
-
return (((_sourceCode$text$matc = sourceCode.text.match(/^\n*([ \t]+)/u)) === null || _sourceCode$text$matc === void 0 ? void 0 : _sourceCode$text$matc[1]) ?? '') + ' ';
|
|
1374
|
+
return (sourceCode.text.match(/^\n*([ \t]+)/u)?.[1] ?? '') + ' ';
|
|
1383
1375
|
};
|
|
1384
1376
|
|
|
1385
1377
|
/**
|
|
@@ -1388,8 +1380,7 @@ const getIndent = sourceCode => {
|
|
|
1388
1380
|
*/
|
|
1389
1381
|
exports.getIndent = getIndent;
|
|
1390
1382
|
const isConstructor = node => {
|
|
1391
|
-
|
|
1392
|
-
return (node === null || node === void 0 ? void 0 : node.type) === 'MethodDefinition' && node.kind === 'constructor' || /** @type {import('@typescript-eslint/types').TSESTree.MethodDefinition} */(node === null || node === void 0 || (_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent.kind) === 'constructor';
|
|
1383
|
+
return node?.type === 'MethodDefinition' && node.kind === 'constructor' || /** @type {import('@typescript-eslint/types').TSESTree.MethodDefinition} */node?.parent?.kind === 'constructor';
|
|
1393
1384
|
};
|
|
1394
1385
|
|
|
1395
1386
|
/**
|
|
@@ -1398,13 +1389,12 @@ const isConstructor = node => {
|
|
|
1398
1389
|
*/
|
|
1399
1390
|
exports.isConstructor = isConstructor;
|
|
1400
1391
|
const isGetter = node => {
|
|
1401
|
-
var _node$parent2;
|
|
1402
1392
|
return node !== null &&
|
|
1403
1393
|
/**
|
|
1404
1394
|
* @type {import('@typescript-eslint/types').TSESTree.MethodDefinition|
|
|
1405
1395
|
* import('@typescript-eslint/types').TSESTree.Property}
|
|
1406
1396
|
*/
|
|
1407
|
-
|
|
1397
|
+
node.parent?.kind === 'get';
|
|
1408
1398
|
};
|
|
1409
1399
|
|
|
1410
1400
|
/**
|
|
@@ -1413,13 +1403,12 @@ const isGetter = node => {
|
|
|
1413
1403
|
*/
|
|
1414
1404
|
exports.isGetter = isGetter;
|
|
1415
1405
|
const isSetter = node => {
|
|
1416
|
-
var _node$parent3;
|
|
1417
1406
|
return node !== null &&
|
|
1418
1407
|
/**
|
|
1419
1408
|
* @type {import('@typescript-eslint/types').TSESTree.MethodDefinition|
|
|
1420
1409
|
* import('@typescript-eslint/types').TSESTree.Property}
|
|
1421
1410
|
*/
|
|
1422
|
-
|
|
1411
|
+
node.parent?.kind === 'set';
|
|
1423
1412
|
};
|
|
1424
1413
|
|
|
1425
1414
|
/**
|
|
@@ -1469,9 +1458,8 @@ const exemptSpeciaMethods = (jsdoc, node, context, schema) => {
|
|
|
1469
1458
|
* @returns {boolean|"no-setter"|"no-getter"}
|
|
1470
1459
|
*/
|
|
1471
1460
|
const hasSchemaOption = prop => {
|
|
1472
|
-
var _context$options$2;
|
|
1473
1461
|
const schemaProperties = schema[0].properties;
|
|
1474
|
-
return
|
|
1462
|
+
return context.options[0]?.[prop] ?? (schemaProperties[prop] && schemaProperties[prop].default);
|
|
1475
1463
|
};
|
|
1476
1464
|
const checkGetters = hasSchemaOption('checkGetters');
|
|
1477
1465
|
const checkSetters = hasSchemaOption('checkSetters');
|