@typescript-eslint/eslint-plugin 8.53.2-alpha.2 → 8.53.2-alpha.3

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.
@@ -318,6 +318,20 @@ class ThisScope extends scope_manager_1.Visitor {
318
318
  /////////////////////
319
319
  // Visit selectors //
320
320
  /////////////////////
321
+ AssignmentExpression(node) {
322
+ this.visitChildren(node);
323
+ if (node.right.type === utils_1.AST_NODE_TYPES.ThisExpression &&
324
+ node.left.type === utils_1.AST_NODE_TYPES.ObjectPattern) {
325
+ this.handleThisDestructuring(node.left);
326
+ }
327
+ }
328
+ AssignmentPattern(node) {
329
+ this.visitChildren(node);
330
+ if (node.right.type === utils_1.AST_NODE_TYPES.ThisExpression &&
331
+ node.left.type === utils_1.AST_NODE_TYPES.ObjectPattern) {
332
+ this.handleThisDestructuring(node.left);
333
+ }
334
+ }
321
335
  ClassDeclaration(node) {
322
336
  this.visitClass(node);
323
337
  }
@@ -391,6 +405,39 @@ class ThisScope extends scope_manager_1.Visitor {
391
405
  StaticBlock(node) {
392
406
  this.visitIntermediate(node);
393
407
  }
408
+ VariableDeclarator(node) {
409
+ this.visitChildren(node);
410
+ if (node.init?.type === utils_1.AST_NODE_TYPES.ThisExpression &&
411
+ node.id.type === utils_1.AST_NODE_TYPES.ObjectPattern) {
412
+ this.handleThisDestructuring(node.id);
413
+ }
414
+ }
415
+ /**
416
+ * Handles destructuring from `this` in ObjectPattern.
417
+ * Example: const { property } = this;
418
+ */
419
+ handleThisDestructuring(pattern) {
420
+ if (this.thisContext == null) {
421
+ return;
422
+ }
423
+ for (const prop of pattern.properties) {
424
+ if (prop.type !== utils_1.AST_NODE_TYPES.Property) {
425
+ continue;
426
+ }
427
+ if (prop.key.type !== utils_1.AST_NODE_TYPES.Identifier || prop.computed) {
428
+ continue;
429
+ }
430
+ const memberKey = (0, types_1.publicKey)(prop.key.name);
431
+ const members = this.isStaticThisContext
432
+ ? this.thisContext.members.static
433
+ : this.thisContext.members.instance;
434
+ const member = members.get(memberKey);
435
+ if (member == null) {
436
+ continue;
437
+ }
438
+ countReference(prop.key, member);
439
+ }
440
+ }
394
441
  }
395
442
  /**
396
443
  * Any other scope that is not a class scope
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/eslint-plugin",
3
- "version": "8.53.2-alpha.2",
3
+ "version": "8.53.2-alpha.3",
4
4
  "description": "TypeScript plugin for ESLint",
5
5
  "files": [
6
6
  "dist",
@@ -59,10 +59,10 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "@eslint-community/regexpp": "^4.12.2",
62
- "@typescript-eslint/scope-manager": "8.53.2-alpha.2",
63
- "@typescript-eslint/type-utils": "8.53.2-alpha.2",
64
- "@typescript-eslint/utils": "8.53.2-alpha.2",
65
- "@typescript-eslint/visitor-keys": "8.53.2-alpha.2",
62
+ "@typescript-eslint/scope-manager": "8.53.2-alpha.3",
63
+ "@typescript-eslint/type-utils": "8.53.2-alpha.3",
64
+ "@typescript-eslint/utils": "8.53.2-alpha.3",
65
+ "@typescript-eslint/visitor-keys": "8.53.2-alpha.3",
66
66
  "ignore": "^7.0.5",
67
67
  "natural-compare": "^1.4.0",
68
68
  "ts-api-utils": "^2.4.0"
@@ -70,8 +70,8 @@
70
70
  "devDependencies": {
71
71
  "@types/mdast": "^4.0.4",
72
72
  "@types/natural-compare": "*",
73
- "@typescript-eslint/rule-schema-to-typescript-types": "8.53.2-alpha.2",
74
- "@typescript-eslint/rule-tester": "8.53.2-alpha.2",
73
+ "@typescript-eslint/rule-schema-to-typescript-types": "8.53.2-alpha.3",
74
+ "@typescript-eslint/rule-tester": "8.53.2-alpha.3",
75
75
  "@vitest/coverage-v8": "^3.2.4",
76
76
  "ajv": "^6.12.6",
77
77
  "eslint": "*",
@@ -90,7 +90,7 @@
90
90
  "vitest": "^3.2.4"
91
91
  },
92
92
  "peerDependencies": {
93
- "@typescript-eslint/parser": "^8.53.2-alpha.2",
93
+ "@typescript-eslint/parser": "^8.53.2-alpha.3",
94
94
  "eslint": "^8.57.0 || ^9.0.0",
95
95
  "typescript": ">=4.8.4 <6.0.0"
96
96
  },