@typescript-eslint/scope-manager 8.41.1-alpha.7 → 8.41.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.
@@ -3,13 +3,13 @@ import type { Referencer } from './Referencer';
3
3
  import { Visitor } from './Visitor';
4
4
  export declare class ClassVisitor extends Visitor {
5
5
  #private;
6
- constructor(referencer: Referencer, node: TSESTree.ClassDeclaration | TSESTree.ClassExpression);
6
+ constructor(referencer: Referencer);
7
7
  static visit(referencer: Referencer, node: TSESTree.ClassDeclaration | TSESTree.ClassExpression): void;
8
8
  visit(node: TSESTree.Node | null | undefined): void;
9
9
  protected visitClass(node: TSESTree.ClassDeclaration | TSESTree.ClassExpression): void;
10
10
  protected visitFunctionParameterTypeAnnotation(node: TSESTree.Parameter): void;
11
11
  protected visitMethod(node: TSESTree.MethodDefinition): void;
12
- protected visitMethodFunction(node: TSESTree.FunctionExpression, methodNode: TSESTree.MethodDefinition): void;
12
+ protected visitMethodFunction(node: TSESTree.FunctionExpression): void;
13
13
  protected visitPropertyBase(node: TSESTree.AccessorProperty | TSESTree.PropertyDefinition | TSESTree.TSAbstractAccessorProperty | TSESTree.TSAbstractMethodDefinition | TSESTree.TSAbstractPropertyDefinition): void;
14
14
  protected visitPropertyDefinition(node: TSESTree.AccessorProperty | TSESTree.PropertyDefinition | TSESTree.TSAbstractAccessorProperty | TSESTree.TSAbstractPropertyDefinition): void;
15
15
  protected visitType(node: TSESTree.Node | null | undefined): void;
@@ -1 +1 @@
1
- {"version":3,"file":"ClassVisitor.d.ts","sourceRoot":"","sources":["../../src/referencer/ClassVisitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAIzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,qBAAa,YAAa,SAAQ,OAAO;;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SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,WAAW,GAAG,IAAI;IAQvD,SAAS,CAAC,0BAA0B,CAClC,IAAI,EAAE,QAAQ,CAAC,0BAA0B,GACxC,IAAI;IAIP,SAAS,CAAC,0BAA0B,CAClC,IAAI,EAAE,QAAQ,CAAC,0BAA0B,GACxC,IAAI;IAIP,SAAS,CAAC,4BAA4B,CACpC,IAAI,EAAE,QAAQ,CAAC,4BAA4B,GAC1C,IAAI;IAIP,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,gBAAgB,GAAG,IAAI;CAGlE"}
@@ -6,15 +6,13 @@ const definition_1 = require("../definition");
6
6
  const TypeVisitor_1 = require("./TypeVisitor");
7
7
  const Visitor_1 = require("./Visitor");
8
8
  class ClassVisitor extends Visitor_1.Visitor {
9
- #classNode;
10
9
  #referencer;
11
- constructor(referencer, node) {
10
+ constructor(referencer) {
12
11
  super(referencer);
13
12
  this.#referencer = referencer;
14
- this.#classNode = node;
15
13
  }
16
14
  static visit(referencer, node) {
17
- const classVisitor = new ClassVisitor(referencer, node);
15
+ const classVisitor = new ClassVisitor(referencer);
18
16
  classVisitor.visitClass(node);
19
17
  }
20
18
  visit(node) {
@@ -70,14 +68,14 @@ class ClassVisitor extends Visitor_1.Visitor {
70
68
  this.#referencer.visit(node.key);
71
69
  }
72
70
  if (node.value.type === types_1.AST_NODE_TYPES.FunctionExpression) {
73
- this.visitMethodFunction(node.value, node);
71
+ this.visitMethodFunction(node.value);
74
72
  }
75
73
  else {
76
74
  this.#referencer.visit(node.value);
77
75
  }
78
76
  node.decorators.forEach(d => this.#referencer.visit(d));
79
77
  }
80
- visitMethodFunction(node, methodNode) {
78
+ visitMethodFunction(node) {
81
79
  if (node.id) {
82
80
  // FunctionExpression with name creates its special scope;
83
81
  // FunctionExpressionNameScope.
@@ -88,61 +86,6 @@ class ClassVisitor extends Visitor_1.Visitor {
88
86
  });
89
87
  // Consider this function is in the MethodDefinition.
90
88
  this.#referencer.scopeManager.nestFunctionScope(node, true);
91
- /**
92
- * class A {
93
- * @meta // <--- check this
94
- * foo(a: Type) {}
95
- *
96
- * @meta // <--- check this
97
- * foo(): Type {}
98
- * }
99
- */
100
- let withMethodDecorators = !!methodNode.decorators.length;
101
- /**
102
- * class A {
103
- * foo(
104
- * @meta // <--- check this
105
- * a: Type
106
- * ) {}
107
- *
108
- * set foo(
109
- * @meta // <--- EXCEPT this. TS do nothing for this
110
- * a: Type
111
- * ) {}
112
- * }
113
- */
114
- withMethodDecorators ||=
115
- methodNode.kind !== 'set' &&
116
- node.params.some(param => param.decorators.length);
117
- if (!withMethodDecorators && methodNode.kind === 'set') {
118
- const keyName = getLiteralMethodKeyName(methodNode);
119
- /**
120
- * class A {
121
- * @meta // <--- check this
122
- * get a() {}
123
- * set ['a'](v: Type) {}
124
- * }
125
- */
126
- if (keyName != null &&
127
- this.#classNode.body.body.find((node) => node !== methodNode &&
128
- node.type === types_1.AST_NODE_TYPES.MethodDefinition &&
129
- // Node must both be static or not
130
- node.static === methodNode.static &&
131
- getLiteralMethodKeyName(node) === keyName)?.decorators.length) {
132
- withMethodDecorators = true;
133
- }
134
- }
135
- /**
136
- * @meta // <--- check this
137
- * class A {
138
- * constructor(a: Type) {}
139
- * }
140
- */
141
- if (!withMethodDecorators &&
142
- methodNode.kind === 'constructor' &&
143
- this.#classNode.decorators.length) {
144
- withMethodDecorators = true;
145
- }
146
89
  // Process parameter declarations.
147
90
  for (const param of node.params) {
148
91
  this.visitPattern(param, (pattern, info) => {
@@ -233,35 +176,3 @@ class ClassVisitor extends Visitor_1.Visitor {
233
176
  }
234
177
  }
235
178
  exports.ClassVisitor = ClassVisitor;
236
- /**
237
- * Only if key is one of [identifier, string, number], ts will combine metadata of accessors .
238
- * class A {
239
- * get a() {}
240
- * set ['a'](v: Type) {}
241
- *
242
- * get [1]() {}
243
- * set [1](v: Type) {}
244
- *
245
- * // Following won't be combined
246
- * get [key]() {}
247
- * set [key](v: Type) {}
248
- *
249
- * get [true]() {}
250
- * set [true](v: Type) {}
251
- *
252
- * get ['a'+'b']() {}
253
- * set ['a'+'b']() {}
254
- * }
255
- */
256
- function getLiteralMethodKeyName(node) {
257
- if (node.computed && node.key.type === types_1.AST_NODE_TYPES.Literal) {
258
- if (typeof node.key.value === 'string' ||
259
- typeof node.key.value === 'number') {
260
- return node.key.value;
261
- }
262
- }
263
- else if (!node.computed && node.key.type === types_1.AST_NODE_TYPES.Identifier) {
264
- return node.key.name;
265
- }
266
- return null;
267
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/scope-manager",
3
- "version": "8.41.1-alpha.7",
3
+ "version": "8.41.1-alpha.9",
4
4
  "description": "TypeScript scope analyser for ESLint",
5
5
  "files": [
6
6
  "dist",
@@ -47,11 +47,11 @@
47
47
  "typecheck": "yarn run -BT nx typecheck"
48
48
  },
49
49
  "dependencies": {
50
- "@typescript-eslint/types": "8.41.1-alpha.7",
51
- "@typescript-eslint/visitor-keys": "8.41.1-alpha.7"
50
+ "@typescript-eslint/types": "8.41.1-alpha.9",
51
+ "@typescript-eslint/visitor-keys": "8.41.1-alpha.9"
52
52
  },
53
53
  "devDependencies": {
54
- "@typescript-eslint/typescript-estree": "8.41.1-alpha.7",
54
+ "@typescript-eslint/typescript-estree": "8.41.1-alpha.9",
55
55
  "@vitest/coverage-v8": "^3.1.3",
56
56
  "@vitest/pretty-format": "^3.1.3",
57
57
  "eslint": "*",