@depup/eslint-plugin-jsdoc 64.3.5-depup.0 → 64.3.6-depup.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/README.md +2 -2
- package/changes.json +1 -1
- package/package.json +7 -7
- package/src/rules/noUnnecessaryTypeAssertion.js +59 -0
- package/src/rules/requireJsdoc.js +0 -1
package/README.md
CHANGED
|
@@ -13,8 +13,8 @@ npm install @depup/eslint-plugin-jsdoc
|
|
|
13
13
|
|
|
14
14
|
| Field | Value |
|
|
15
15
|
|-------|-------|
|
|
16
|
-
| Original | [eslint-plugin-jsdoc](https://www.npmjs.com/package/eslint-plugin-jsdoc) @ 64.3.
|
|
17
|
-
| Processed | 2026-09-
|
|
16
|
+
| Original | [eslint-plugin-jsdoc](https://www.npmjs.com/package/eslint-plugin-jsdoc) @ 64.3.6 |
|
|
17
|
+
| Processed | 2026-09-06 |
|
|
18
18
|
| Smoke test | passed |
|
|
19
19
|
| Deps updated | 0 |
|
|
20
20
|
|
package/changes.json
CHANGED
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.97.0",
|
|
9
9
|
"@es-joy/resolve.exports": "1.2.0",
|
|
10
10
|
"@typescript-eslint/utils": "^8.69.0",
|
|
11
11
|
"are-docs-informative": "^0.1.1",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"camelcase": "^9.0.0",
|
|
52
52
|
"chai": "^6.2.2",
|
|
53
53
|
"decamelize": "^6.0.1",
|
|
54
|
-
"eslint": "10.
|
|
54
|
+
"eslint": "10.10.0",
|
|
55
55
|
"eslint-config-canonical": "^47.4.2",
|
|
56
56
|
"gitdown": "^4.1.1",
|
|
57
57
|
"glob": "^13.0.6",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"jsdoc-type-pratt-parser": "^9.2.1",
|
|
61
61
|
"json-schema": "^0.4.0",
|
|
62
62
|
"json-schema-to-typescript": "^16.0.0",
|
|
63
|
-
"lint-staged": "^17.
|
|
63
|
+
"lint-staged": "^17.5.0",
|
|
64
64
|
"mocha": "^12.0.0",
|
|
65
65
|
"open-editor": "^6.0.0",
|
|
66
|
-
"playwright": "^1.
|
|
66
|
+
"playwright": "^1.63.0",
|
|
67
67
|
"replace": "^1.2.2",
|
|
68
68
|
"rimraf": "^6.1.3",
|
|
69
69
|
"semantic-release": "^25.0.9",
|
|
@@ -162,13 +162,13 @@
|
|
|
162
162
|
"test-cov": "TIMING=1 c8 --reporter text pnpm run test-no-cov",
|
|
163
163
|
"test-index": "pnpm run test-no-cov test/rules/index.js"
|
|
164
164
|
},
|
|
165
|
-
"version": "64.3.
|
|
165
|
+
"version": "64.3.6-depup.0",
|
|
166
166
|
"depup": {
|
|
167
167
|
"changes": {},
|
|
168
168
|
"depsUpdated": 0,
|
|
169
169
|
"originalPackage": "eslint-plugin-jsdoc",
|
|
170
|
-
"originalVersion": "64.3.
|
|
171
|
-
"processedAt": "2026-09-
|
|
170
|
+
"originalVersion": "64.3.6",
|
|
171
|
+
"processedAt": "2026-09-06T00:59:25.028Z",
|
|
172
172
|
"smokeTest": "passed"
|
|
173
173
|
}
|
|
174
174
|
}
|
|
@@ -363,6 +363,51 @@ export default iterateJsdoc(({
|
|
|
363
363
|
checker.isTupleType(assertedType);
|
|
364
364
|
};
|
|
365
365
|
|
|
366
|
+
/**
|
|
367
|
+
* An array-literal annotation whose element type is a literal (or union of
|
|
368
|
+
* literals) — `type {ViewType[]}` on `['single-panel', 'user']` —
|
|
369
|
+
* narrows the element type that the bare literal would widen (`string[]` ->
|
|
370
|
+
* `ViewType[]`). Like the tuple idiom, the literal takes that element type
|
|
371
|
+
* only *from* the annotation, so the contextually-typed initializer echoes
|
|
372
|
+
* the asserted array straight back and the genuine narrowing looks redundant.
|
|
373
|
+
* @param {any} assertedType `ts.Type`
|
|
374
|
+
* @param {import('@typescript-eslint/utils').TSESTree.Node | null | undefined} operand
|
|
375
|
+
* @returns {boolean}
|
|
376
|
+
*/
|
|
377
|
+
const narrowsArrayLiteralElement = (assertedType, operand) => {
|
|
378
|
+
if (operand?.type !== 'ArrayExpression' || !checker.isArrayType(assertedType)) {
|
|
379
|
+
return false;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const [
|
|
383
|
+
elementType,
|
|
384
|
+
] = checker.getTypeArguments(assertedType);
|
|
385
|
+
return isLiteralType(elementType);
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Whether `operand` is an object literal carrying a method or function-valued
|
|
390
|
+
* property. Under a surrounding `@type` object annotation such a function is
|
|
391
|
+
* contextually typed by the annotation — its otherwise-implicit-`any`
|
|
392
|
+
* parameters (and hence its signature) come straight from it — so
|
|
393
|
+
* `getTypeAtLocation` echoes the asserted object shape back and a genuine
|
|
394
|
+
* typing looks redundant. As elsewhere in this rule the uncontaminated type
|
|
395
|
+
* cannot be recovered here, so such literals are left alone (at the cost of
|
|
396
|
+
* missing the rare object annotation that only restates a fully
|
|
397
|
+
* self-evident method signature).
|
|
398
|
+
* @param {import('@typescript-eslint/utils').TSESTree.Node | null | undefined} operand
|
|
399
|
+
* @returns {boolean}
|
|
400
|
+
*/
|
|
401
|
+
const hasContextuallyTypedFunctionMember = (operand) => {
|
|
402
|
+
return operand?.type === 'ObjectExpression' &&
|
|
403
|
+
operand.properties.some((property) => {
|
|
404
|
+
return property.type === 'Property' && (
|
|
405
|
+
property.value.type === 'FunctionExpression' ||
|
|
406
|
+
property.value.type === 'ArrowFunctionExpression'
|
|
407
|
+
);
|
|
408
|
+
});
|
|
409
|
+
};
|
|
410
|
+
|
|
366
411
|
/**
|
|
367
412
|
* Whether every element of `tupleType` is a literal type, so a `const`
|
|
368
413
|
* assertion would reproduce the same element types (`['foo', 1]` but not
|
|
@@ -445,6 +490,13 @@ export default iterateJsdoc(({
|
|
|
445
490
|
return;
|
|
446
491
|
}
|
|
447
492
|
|
|
493
|
+
if (
|
|
494
|
+
narrowsArrayLiteralElement(declAssertedType, decl.init) ||
|
|
495
|
+
hasContextuallyTypedFunctionMember(decl.init)
|
|
496
|
+
) {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
|
|
448
500
|
if (isRedundantAssertion(declInferredType, declAssertedType)) {
|
|
449
501
|
utils.reportJSDoc(message, types[0], fixer, true, {
|
|
450
502
|
type: assertedTypeStr,
|
|
@@ -522,6 +574,13 @@ export default iterateJsdoc(({
|
|
|
522
574
|
return;
|
|
523
575
|
}
|
|
524
576
|
|
|
577
|
+
if (
|
|
578
|
+
narrowsArrayLiteralElement(castAssertedType, node) ||
|
|
579
|
+
hasContextuallyTypedFunctionMember(node)
|
|
580
|
+
) {
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
|
|
525
584
|
if (!isRedundantAssertion(castInferredType, castAssertedType)) {
|
|
526
585
|
return;
|
|
527
586
|
}
|