@typescript-eslint/eslint-plugin 8.73.1-alpha.7 → 8.73.1-alpha.9

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.
@@ -1,4 +1,10 @@
1
- declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"adjacentSignature", [], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
1
+ export type Options = [
2
+ {
3
+ ignoreAccessors?: boolean;
4
+ }
5
+ ];
6
+ export type MessageIds = 'adjacentSignature';
7
+ declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"adjacentSignature", Options, import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
2
8
  name: string;
3
9
  };
4
10
  export default _default;
@@ -13,11 +13,22 @@ exports.default = (0, util_1.createRule)({
13
13
  messages: {
14
14
  adjacentSignature: 'All {{name}} signatures should be adjacent.',
15
15
  },
16
- schema: [],
16
+ schema: [
17
+ {
18
+ type: 'object',
19
+ additionalProperties: false,
20
+ properties: {
21
+ ignoreAccessors: {
22
+ type: 'boolean',
23
+ description: 'Whether to ignore getters and setters, which cannot be overloaded.',
24
+ },
25
+ },
26
+ },
27
+ ],
17
28
  },
18
29
  // eslint-disable-next-line @typescript-eslint/no-deprecated -- For compatibility with ESLint 8, see #12842
19
- defaultOptions: [],
20
- create(context) {
30
+ defaultOptions: [{ ignoreAccessors: false }],
31
+ create(context, [{ ignoreAccessors = false }]) {
21
32
  /**
22
33
  * Gets the name and attribute of the member being processed.
23
34
  * @param member the member being processed.
@@ -48,6 +59,10 @@ exports.default = (0, util_1.createRule)({
48
59
  }
49
60
  case utils_1.AST_NODE_TYPES.TSMethodSignature:
50
61
  case utils_1.AST_NODE_TYPES.MethodDefinition:
62
+ if (ignoreAccessors &&
63
+ (member.kind === 'get' || member.kind === 'set')) {
64
+ return null;
65
+ }
51
66
  return {
52
67
  ...(0, util_1.getNameFromMember)(member, context.sourceCode),
53
68
  callSignature: false,
@@ -202,6 +202,15 @@ exports.default = (0, util_1.createRule)({
202
202
  const displayParts = tag.text;
203
203
  return displayParts ? ts.displayPartsToString(displayParts) : '';
204
204
  }
205
+ function getPropertyDeprecation(type, propertyName) {
206
+ for (const constituent of tsutils.unionConstituents(type)) {
207
+ const reason = getJsDocDeprecation(constituent.getProperty(propertyName));
208
+ if (reason != null) {
209
+ return { type: constituent, reason };
210
+ }
211
+ }
212
+ return undefined;
213
+ }
205
214
  function isNodeCalleeOfParent(node) {
206
215
  switch (node.parent?.type) {
207
216
  case utils_1.AST_NODE_TYPES.NewExpression:
@@ -275,8 +284,7 @@ exports.default = (0, util_1.createRule)({
275
284
  }
276
285
  function getJSXAttributeDeprecation(openingElement, propertyName) {
277
286
  const contextualType = (0, util_1.nullThrows)(services.getContextualType(openingElement.name), 'Expected JSX opening element name to have contextualType');
278
- const symbol = contextualType.getProperty(propertyName);
279
- return getJsDocDeprecation(symbol);
287
+ return getPropertyDeprecation(contextualType, propertyName)?.reason;
280
288
  }
281
289
  function getDeprecationReason(node) {
282
290
  const callLikeNode = getCallLikeNode(node);
@@ -360,11 +368,12 @@ exports.default = (0, util_1.createRule)({
360
368
  if (!contextualType) {
361
369
  return;
362
370
  }
363
- const reason = getJsDocDeprecation(contextualType.getProperty(propertyName));
364
- if (reason == null) {
371
+ const deprecation = getPropertyDeprecation(contextualType, propertyName);
372
+ if (!deprecation) {
365
373
  return;
366
374
  }
367
- if ((0, util_1.typeMatchesSomeSpecifier)(contextualType, allow, services.program)) {
375
+ const { type, reason } = deprecation;
376
+ if ((0, util_1.typeMatchesSomeSpecifier)(type, allow, services.program)) {
368
377
  return;
369
378
  }
370
379
  context.report({
@@ -391,12 +400,12 @@ exports.default = (0, util_1.createRule)({
391
400
  ? propertyType.value
392
401
  : // eslint-disable-next-line @typescript-eslint/no-base-to-string
393
402
  String(propertyType.value);
394
- const property = objectType.getProperty(propertyName);
395
- const reason = getJsDocDeprecation(property);
396
- if (reason == null) {
403
+ const deprecation = getPropertyDeprecation(objectType, propertyName);
404
+ if (!deprecation) {
397
405
  return;
398
406
  }
399
- if ((0, util_1.typeMatchesSomeSpecifier)(objectType, allow, services.program)) {
407
+ const { type, reason } = deprecation;
408
+ if ((0, util_1.typeMatchesSomeSpecifier)(type, allow, services.program)) {
400
409
  return;
401
410
  }
402
411
  context.report({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/eslint-plugin",
3
- "version": "8.73.1-alpha.7",
3
+ "version": "8.73.1-alpha.9",
4
4
  "description": "TypeScript plugin for ESLint",
5
5
  "files": [
6
6
  "dist",
@@ -47,10 +47,10 @@
47
47
  ],
48
48
  "dependencies": {
49
49
  "@eslint-community/regexpp": "^4.12.2",
50
- "@typescript-eslint/scope-manager": "8.73.1-alpha.7",
51
- "@typescript-eslint/type-utils": "8.73.1-alpha.7",
52
- "@typescript-eslint/utils": "8.73.1-alpha.7",
53
- "@typescript-eslint/visitor-keys": "8.73.1-alpha.7",
50
+ "@typescript-eslint/scope-manager": "8.73.1-alpha.9",
51
+ "@typescript-eslint/type-utils": "8.73.1-alpha.9",
52
+ "@typescript-eslint/utils": "8.73.1-alpha.9",
53
+ "@typescript-eslint/visitor-keys": "8.73.1-alpha.9",
54
54
  "ignore": "^7.0.5",
55
55
  "natural-compare": "^1.4.0",
56
56
  "ts-api-utils": "^2.5.0"
@@ -60,8 +60,8 @@
60
60
  "@types/mdast": "^4.0.4",
61
61
  "@types/natural-compare": "^1.4.3",
62
62
  "@types/react": "^18.3.21",
63
- "@typescript-eslint/rule-schema-to-typescript-types": "8.73.1-alpha.7",
64
- "@typescript-eslint/rule-tester": "8.73.1-alpha.7",
63
+ "@typescript-eslint/rule-schema-to-typescript-types": "8.73.1-alpha.9",
64
+ "@typescript-eslint/rule-tester": "8.73.1-alpha.9",
65
65
  "@typescript/native": "npm:typescript@7.1.0-dev.20261009.1",
66
66
  "@vitest/coverage-v8": "^5.0.3",
67
67
  "ajv": "^6.12.6",
@@ -81,7 +81,7 @@
81
81
  "vitest": "^5.0.3"
82
82
  },
83
83
  "peerDependencies": {
84
- "@typescript-eslint/parser": "^8.73.1-alpha.7",
84
+ "@typescript-eslint/parser": "^8.73.1-alpha.9",
85
85
  "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
86
86
  "typescript": ">=4.8.4 <6.1.0"
87
87
  },