ember-eslint-parser 0.14.7 → 0.14.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-eslint-parser",
3
- "version": "0.14.7",
3
+ "version": "0.14.8",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "repository": {
@@ -33,6 +33,7 @@
33
33
  "@babel/core": "^7.23.6",
34
34
  "@babel/eslint-parser": "^7.28.6",
35
35
  "@babel/plugin-proposal-decorators": "^7.25.9",
36
+ "@typescript-eslint/eslint-plugin": "^8.46.4",
36
37
  "@typescript-eslint/parser": "^8.0.0",
37
38
  "@typescript-eslint/scope-manager": "^8.0.0",
38
39
  "@typescript-eslint/visitor-keys": "^8.0.0",
@@ -85,13 +85,24 @@ function isUpperCase(char) {
85
85
  return char.toUpperCase() === char;
86
86
  }
87
87
 
88
- function registerBlockParams(node, path, scopeManager, isTypescript) {
89
- const blockParamNodes = node.blockParamNodes || [];
90
- if (blockParamNodes.length === 0) return;
88
+ function createBlockScope(node, path, scopeManager, isTypescript) {
91
89
  const upperScope = findParentScope(scopeManager, path);
92
- const scope = isTypescript
90
+ return isTypescript
93
91
  ? new TypescriptScope.BlockScope(scopeManager, upperScope, node)
94
92
  : new Scope(scopeManager, 'block', upperScope, node);
93
+ }
94
+
95
+ // Give each template a scope of its own. Otherwise typescript-eslint's
96
+ // no-use-before-define treats a reference in `const Foo = <template>` as
97
+ // running in Foo's initializer, though a template reads its scope lazily.
98
+ function registerTemplateScope(node, path, scopeManager, isTypescript) {
99
+ createBlockScope(node, path, scopeManager, isTypescript);
100
+ }
101
+
102
+ function registerBlockParams(node, path, scopeManager, isTypescript) {
103
+ const blockParamNodes = node.blockParamNodes || [];
104
+ if (blockParamNodes.length === 0) return;
105
+ const scope = createBlockScope(node, path, scopeManager, isTypescript);
95
106
  const declaredVariables = scopeManager.declaredVariables || scopeManager.__declaredVariables;
96
107
  const vars = [];
97
108
  declaredVariables.set(node, vars);
@@ -104,7 +115,10 @@ function registerBlockParams(node, path, scopeManager, isTypescript) {
104
115
  };
105
116
  for (const [i, b] of blockParamNodes.entries()) {
106
117
  const v = new Variable(b.name, scope);
107
- v.identifiers.push(b);
118
+ // The block param, parented to the virtual function, so rules that walk
119
+ // up from a declaration (no-use-before-define's initializer check) stop
120
+ // there, as they do for a function parameter.
121
+ v.identifiers.push({ ...b, parent: virtualJSParentNode });
108
122
  scope.variables.push(v);
109
123
  scope.set.set(b.name, v);
110
124
  vars.push(v);
@@ -177,6 +191,9 @@ function registerElementNode(node, path, scopeManager) {
177
191
  export function buildGlimmerVisitors(scopeManager, isTypescript, collectComments) {
178
192
  if (!scopeManager) return null;
179
193
  const visitors = {
194
+ GlimmerTemplate(node, path) {
195
+ registerTemplateScope(node, path, scopeManager, isTypescript);
196
+ },
180
197
  GlimmerPathExpression(node, path) {
181
198
  registerPathExpression(node, path, scopeManager);
182
199
  },
@@ -251,6 +268,9 @@ export function registerGlimmerScopes(result) {
251
268
  traverse(result.visitorKeys, result.ast, (path) => {
252
269
  const node = path.node;
253
270
  if (!node) return;
271
+ if (node.type === 'GlimmerTemplate') {
272
+ registerTemplateScope(node, path, result.scopeManager, result.isTypescript);
273
+ }
254
274
  if (node.type === 'GlimmerPathExpression') {
255
275
  registerPathExpression(node, path, result.scopeManager);
256
276
  }