@depup/eslint-plugin-jsdoc 65.2.4-depup.0 → 65.3.1-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 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) @ 65.2.4 |
17
- | Processed | 2026-10-10 |
16
+ | Original | [eslint-plugin-jsdoc](https://www.npmjs.com/package/eslint-plugin-jsdoc) @ 65.3.1 |
17
+ | Processed | 2026-10-12 |
18
18
  | Smoke test | passed |
19
19
  | Deps updated | 1 |
20
20
 
package/changes.json CHANGED
@@ -5,6 +5,6 @@
5
5
  "to": "^8.71.1"
6
6
  }
7
7
  },
8
- "timestamp": "2026-10-10T08:11:16.880Z",
8
+ "timestamp": "2026-10-12T11:09:30.803Z",
9
9
  "totalUpdated": 1
10
10
  }
package/dist/rules.d.ts CHANGED
@@ -1348,6 +1348,10 @@ export interface Rules {
1348
1348
  * Whether to enable the fixer that removes the redundant `@type` tag (and the JSDoc block if it becomes empty). Defaults to `true`.
1349
1349
  */
1350
1350
  enableFixer?: boolean;
1351
+ /**
1352
+ * Whether the fixer may also remove a redundant assertion that is broader than the inferred type, which changes the declared, exported or returned type (e.g. `/** @type {unknown} * /` on a `string`). When `false`, such an assertion is still reported but not fixed. Only matters when `enableFixer` is `true`. Defaults to `true`.
1353
+ */
1354
+ fixTypeChangingCasts?: boolean;
1351
1355
  /**
1352
1356
  * Whether to report a non-`const` literal-tuple assertion on an array literal (e.g. `/** @type {['foo']} * / (['foo'])`) and fix it to the equivalent, more concise `/** @type {const} * /` assertion. Defaults to `false`.
1353
1357
  */
package/package.json CHANGED
@@ -168,7 +168,7 @@
168
168
  "test-cov": "TIMING=1 c8 --reporter text pnpm run test-no-cov",
169
169
  "test-index": "pnpm run test-no-cov test/rules/index.js"
170
170
  },
171
- "version": "65.2.4-depup.0",
171
+ "version": "65.3.1-depup.0",
172
172
  "depup": {
173
173
  "changes": {
174
174
  "@typescript-eslint/utils": {
@@ -178,8 +178,8 @@
178
178
  },
179
179
  "depsUpdated": 1,
180
180
  "originalPackage": "eslint-plugin-jsdoc",
181
- "originalVersion": "65.2.4",
182
- "processedAt": "2026-10-10T08:11:40.592Z",
181
+ "originalVersion": "65.3.1",
182
+ "processedAt": "2026-10-12T11:09:53.209Z",
183
183
  "smokeTest": "passed"
184
184
  }
185
185
  }
@@ -229,6 +229,7 @@ export default iterateJsdoc(({
229
229
  ...tokens,
230
230
  };
231
231
  utils.emptyTokens(tokens);
232
+ tokens.lineEnd = utils.newLineEnd;
232
233
  const {
233
234
  tokens: {
234
235
  delimiter,
@@ -294,6 +295,7 @@ export default iterateJsdoc(({
294
295
  ...line,
295
296
  delimiter,
296
297
  end: '',
298
+ lineEnd: utils.newLineEnd,
297
299
  });
298
300
  };
299
301
 
@@ -59,6 +59,172 @@ const typescriptGlobals = [
59
59
  'Lowercase',
60
60
  'Capitalize',
61
61
  'Uncapitalize',
62
+
63
+ // Type-only globals of TypeScript's standard library, grouped by the
64
+ // `typescript/lib` file which first declares them
65
+
66
+ // lib.es5.d.ts
67
+ 'ArrayBufferConstructor',
68
+ 'ArrayBufferLike',
69
+ 'ArrayBufferTypes',
70
+ 'ArrayBufferView',
71
+ 'ArrayConstructor',
72
+ 'ArrayLike',
73
+ 'BooleanConstructor',
74
+ 'CallableFunction',
75
+ 'ConcatArray',
76
+ 'DataViewConstructor',
77
+ 'DateConstructor',
78
+ 'ErrorConstructor',
79
+ 'EvalErrorConstructor',
80
+ 'Float32ArrayConstructor',
81
+ 'Float64ArrayConstructor',
82
+ 'FunctionConstructor',
83
+ 'IArguments',
84
+ 'ImportAssertions',
85
+ 'ImportAttributes',
86
+ 'ImportCallOptions',
87
+ 'ImportMeta',
88
+ 'Int16ArrayConstructor',
89
+ 'Int32ArrayConstructor',
90
+ 'Int8ArrayConstructor',
91
+ 'NewableFunction',
92
+ 'NoInfer',
93
+ 'NumberConstructor',
94
+ 'ObjectConstructor',
95
+ 'PromiseConstructorLike',
96
+ 'PromiseLike',
97
+ 'PropertyDescriptor',
98
+ 'PropertyDescriptorMap',
99
+ 'PropertyKey',
100
+ 'RangeErrorConstructor',
101
+ 'ReadonlyArray',
102
+ 'ReferenceErrorConstructor',
103
+ 'RegExpConstructor',
104
+ 'RegExpExecArray',
105
+ 'RegExpMatchArray',
106
+ 'StringConstructor',
107
+ 'SyntaxErrorConstructor',
108
+ 'TemplateStringsArray',
109
+ 'TypeErrorConstructor',
110
+ 'TypedPropertyDescriptor',
111
+ 'URIErrorConstructor',
112
+ 'Uint16ArrayConstructor',
113
+ 'Uint32ArrayConstructor',
114
+ 'Uint8ArrayConstructor',
115
+ 'Uint8ClampedArrayConstructor',
116
+ 'WeakKey',
117
+ 'WeakKeyTypes',
118
+
119
+ // lib.es2015.collection.d.ts
120
+ 'MapConstructor',
121
+ 'ReadonlyMap',
122
+ 'ReadonlySet',
123
+ 'SetConstructor',
124
+ 'WeakMapConstructor',
125
+ 'WeakSetConstructor',
126
+
127
+ // lib.es2015.generator.d.ts
128
+ 'Generator',
129
+ 'GeneratorFunction',
130
+ 'GeneratorFunctionConstructor',
131
+
132
+ // lib.es2015.iterable.d.ts
133
+ 'ArrayIterator',
134
+ 'BuiltinIteratorReturn',
135
+ 'IterableIterator',
136
+ 'IteratorResult',
137
+ 'IteratorReturnResult',
138
+ 'IteratorYieldResult',
139
+ 'MapIterator',
140
+ 'PromiseConstructor',
141
+ 'SetIterator',
142
+ 'StringIterator',
143
+ 'SymbolConstructor',
144
+
145
+ // lib.es2015.proxy.d.ts
146
+ 'ProxyConstructor',
147
+ 'ProxyHandler',
148
+
149
+ // lib.es2017.sharedmemory.d.ts
150
+ 'SharedArrayBufferConstructor',
151
+
152
+ // lib.es2018.asyncgenerator.d.ts
153
+ 'AsyncGenerator',
154
+ 'AsyncGeneratorFunction',
155
+ 'AsyncGeneratorFunctionConstructor',
156
+
157
+ // lib.es2018.asynciterable.d.ts
158
+ 'AsyncIterable',
159
+ 'AsyncIterableIterator',
160
+ 'AsyncIterator',
161
+ 'AsyncIteratorObject',
162
+
163
+ // lib.es2019.array.d.ts
164
+ 'FlatArray',
165
+
166
+ // lib.es2020.bigint.d.ts
167
+ 'BigInt64ArrayConstructor',
168
+ 'BigIntConstructor',
169
+ 'BigIntToLocaleStringOptions',
170
+ 'BigUint64ArrayConstructor',
171
+
172
+ // lib.es2020.promise.d.ts
173
+ 'PromiseFulfilledResult',
174
+ 'PromiseRejectedResult',
175
+ 'PromiseSettledResult',
176
+
177
+ // lib.es2020.symbol.wellknown.d.ts
178
+ 'RegExpStringIterator',
179
+
180
+ // lib.es2021.promise.d.ts
181
+ 'AggregateErrorConstructor',
182
+
183
+ // lib.es2021.weakref.d.ts
184
+ 'FinalizationRegistryConstructor',
185
+ 'WeakRefConstructor',
186
+
187
+ // lib.es2022.error.d.ts
188
+ 'ErrorOptions',
189
+
190
+ // lib.es2022.regexp.d.ts
191
+ 'RegExpIndicesArray',
192
+
193
+ // lib.es2024.promise.d.ts
194
+ 'PromiseWithResolvers',
195
+
196
+ // lib.es2025.collection.d.ts
197
+ 'ReadonlySetLike',
198
+
199
+ // lib.es2025.iterator.d.ts
200
+ 'IteratorObjectConstructor',
201
+
202
+ // lib.esnext.disposable.d.ts
203
+ 'AsyncDisposable',
204
+ 'AsyncDisposableStackConstructor',
205
+ 'Disposable',
206
+ 'DisposableStackConstructor',
207
+ 'SuppressedErrorConstructor',
208
+
209
+ // lib.decorators.d.ts
210
+ 'ClassAccessorDecoratorContext',
211
+ 'ClassAccessorDecoratorResult',
212
+ 'ClassAccessorDecoratorTarget',
213
+ 'ClassDecoratorContext',
214
+ 'ClassFieldDecoratorContext',
215
+ 'ClassGetterDecoratorContext',
216
+ 'ClassMemberDecoratorContext',
217
+ 'ClassMethodDecoratorContext',
218
+ 'ClassSetterDecoratorContext',
219
+ 'DecoratorContext',
220
+ 'DecoratorMetadata',
221
+ 'DecoratorMetadataObject',
222
+
223
+ // lib.decorators.legacy.d.ts
224
+ 'ClassDecorator',
225
+ 'MethodDecorator',
226
+ 'ParameterDecorator',
227
+ 'PropertyDecorator',
62
228
  ];
63
229
 
64
230
  /**
@@ -95,6 +95,7 @@ export default iterateJsdoc(({
95
95
  // https://typescript-eslint.io/rules/no-unnecessary-type-assertion/
96
96
  checkLiteralConstAssertions = false,
97
97
  enableFixer = true,
98
+ fixTypeChangingCasts = true,
98
99
  preferConstToLiteralTuples = false,
99
100
  treatAnyAsRedundant = false,
100
101
  typesToIgnore = [],
@@ -354,6 +355,32 @@ export default iterateJsdoc(({
354
355
  checker.isTypeAssignableTo(assertedBaseType, inferredBaseType);
355
356
  };
356
357
 
358
+ /**
359
+ * Whether the fixer may remove a redundant assertion. With
360
+ * `fixTypeChangingCasts` (the default) every redundant assertion may be
361
+ * removed. Without it, a broader assertion (e.g. `unknown` on a `string`, or
362
+ * `'x' | 'y'` on `'x'`) is only reported, since dropping it would change the
363
+ * declared or returned type; it is removed only when the asserted type is
364
+ * also assignable back to the inferred one. A plain widening of a literal
365
+ * (`string` on `'hello'`) is the type TypeScript gives a mutable binding
366
+ * anyway, so it is kept removable.
367
+ * @param {any} rawInferredType `ts.Type`
368
+ * @param {any} rawAssertedType `ts.Type`
369
+ * @returns {boolean}
370
+ */
371
+ const mayRemove = (rawInferredType, rawAssertedType) => {
372
+ if (
373
+ fixTypeChangingCasts || assertedTypeStr === 'const' ||
374
+ checker.isTypeAssignableTo(rawAssertedType, rawInferredType)
375
+ ) {
376
+ return true;
377
+ }
378
+
379
+ const inferredBaseType = checker.getBaseTypeOfLiteralType(rawInferredType);
380
+ return checker.isTypeAssignableTo(inferredBaseType, rawAssertedType) &&
381
+ checker.isTypeAssignableTo(rawAssertedType, inferredBaseType);
382
+ };
383
+
357
384
  /**
358
385
  * A non-`const` tuple type annotation on an array literal (asserting `['foo']`
359
386
  * onto `['foo']`) turns the literal's inferred `T[]` into a tuple; since the
@@ -506,9 +533,15 @@ export default iterateJsdoc(({
506
533
  }
507
534
 
508
535
  if (isRedundantAssertion(declInferredType, declAssertedType)) {
509
- utils.reportJSDoc(message, types[0], fixer, true, {
510
- type: assertedTypeStr,
511
- });
536
+ utils.reportJSDoc(
537
+ message,
538
+ types[0],
539
+ mayRemove(declInferredType, declAssertedType) ? fixer : null,
540
+ true,
541
+ {
542
+ type: assertedTypeStr,
543
+ },
544
+ );
512
545
  }
513
546
 
514
547
  return;
@@ -593,7 +626,7 @@ export default iterateJsdoc(({
593
626
  return;
594
627
  }
595
628
 
596
- const canUnwrap = enableFixer && (
629
+ const canUnwrap = enableFixer && mayRemove(castInferredType, castAssertedType) && (
597
630
  unwrappableParentTypes.has(parent.type) ||
598
631
  (parent.type === 'ConditionalExpression' && parent.test !== node) ||
599
632
  ((parent.type === 'CallExpression' || parent.type === 'NewExpression') &&
@@ -651,6 +684,10 @@ export default iterateJsdoc(({
651
684
  description: 'Whether to enable the fixer that removes the redundant `@type` tag (and the JSDoc block if it becomes empty). Defaults to `true`.',
652
685
  type: 'boolean',
653
686
  },
687
+ fixTypeChangingCasts: {
688
+ description: 'Whether the fixer may also remove a redundant assertion that is broader than the inferred type, which changes the declared, exported or returned type (e.g. `/** @type {unknown} */` on a `string`). When `false`, such an assertion is still reported but not fixed. Only matters when `enableFixer` is `true`. Defaults to `true`.',
689
+ type: 'boolean',
690
+ },
654
691
  preferConstToLiteralTuples: {
655
692
  description: 'Whether to report a non-`const` literal-tuple assertion on an array literal (e.g. `/** @type {[\'foo\']} */ ([\'foo\'])`) and fix it to the equivalent, more concise `/** @type {const} */` assertion. Defaults to `false`.',
656
693
  type: 'boolean',
@@ -38,13 +38,16 @@ const checkMaxBlockLines = ({
38
38
  },
39
39
  () => {
40
40
  utils.setBlockDescription((info, seedTokens, descLines, postDelims) => {
41
+ // The run of newlines starts at the end of the preceding text line,
42
+ // so the blank lines to drop begin after that line.
43
+ const excessStart = descLines[excessIndexLine] ? excessIndexLine + 1 : excessIndexLine;
41
44
  const newPostDelims = [
42
- ...postDelims.slice(0, excessIndexLine),
43
- ...postDelims.slice(excessIndexLine + excessBlockLines - 1 - maxBlockLines),
45
+ ...postDelims.slice(0, excessStart),
46
+ ...postDelims.slice(excessStart + excessBlockLines - 1 - maxBlockLines),
44
47
  ];
45
48
  return [
46
- ...descLines.slice(0, excessIndexLine),
47
- ...descLines.slice(excessIndexLine + excessBlockLines - 1 - maxBlockLines),
49
+ ...descLines.slice(0, excessStart),
50
+ ...descLines.slice(excessStart + excessBlockLines - 1 - maxBlockLines),
48
51
  ].map((desc, idx) => {
49
52
  return {
50
53
  number: 0,
package/src/rules.d.ts CHANGED
@@ -1348,6 +1348,10 @@ export interface Rules {
1348
1348
  * Whether to enable the fixer that removes the redundant `@type` tag (and the JSDoc block if it becomes empty). Defaults to `true`.
1349
1349
  */
1350
1350
  enableFixer?: boolean;
1351
+ /**
1352
+ * Whether the fixer may also remove a redundant assertion that is broader than the inferred type, which changes the declared, exported or returned type (e.g. `/** @type {unknown} * /` on a `string`). When `false`, such an assertion is still reported but not fixed. Only matters when `enableFixer` is `true`. Defaults to `true`.
1353
+ */
1354
+ fixTypeChangingCasts?: boolean;
1351
1355
  /**
1352
1356
  * Whether to report a non-`const` literal-tuple assertion on an array literal (e.g. `/** @type {['foo']} * / (['foo'])`) and fix it to the equivalent, more concise `/** @type {const} * /` assertion. Defaults to `false`.
1353
1357
  */