ember-eslint-parser 0.2.4 → 0.2.5

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.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "repository": {
@@ -114,6 +114,7 @@ function traverse(visitorKeys, node, visitor) {
114
114
  parent: null,
115
115
  parentKey: null,
116
116
  parentPath: null,
117
+ context: {},
117
118
  });
118
119
 
119
120
  while (queue.length > 0) {
@@ -136,6 +137,7 @@ function traverse(visitorKeys, node, visitor) {
136
137
  queue.push({
137
138
  node: item,
138
139
  parent: currentPath.node,
140
+ context: Object.assign({}, currentPath.context),
139
141
  parentKey: visitorKey,
140
142
  parentPath: currentPath,
141
143
  });
@@ -144,6 +146,7 @@ function traverse(visitorKeys, node, visitor) {
144
146
  queue.push({
145
147
  node: child,
146
148
  parent: currentPath.node,
149
+ context: Object.assign({}, currentPath.context),
147
150
  parentKey: visitorKey,
148
151
  parentPath: currentPath,
149
152
  });
@@ -455,6 +458,9 @@ module.exports.convertAst = function convertAst(result, preprocessedResult, visi
455
458
  }
456
459
  }
457
460
  if (node.type === 'GlimmerElementNode') {
461
+ if (node.tag === 'svg') {
462
+ path.context.inSvg = true;
463
+ }
458
464
  // always reference first part of tag name, this also has the advantage
459
465
  // that errors regarding this tag will only mark the tag name instead of
460
466
  // the whole tag + children
@@ -462,22 +468,19 @@ module.exports.convertAst = function convertAst(result, preprocessedResult, visi
462
468
  const { scope, variable } = findVarInParentScopes(result.scopeManager, path, n.name) || {};
463
469
  /*
464
470
  register a node in scope if we found a variable
465
- we ignore named-blocks as we know that it doesn't reference anything in current scope
471
+ we ignore named-blocks and args as we know that it doesn't reference anything in current scope
472
+ we also ignore `this`
466
473
  if we do not find a variable we register it with a missing variable if
467
474
  * it starts with upper case, it should be a component with a reference
468
475
  * it includes a dot, it's a path which should have a reference
469
476
  * it's NOT a standard html tag, it should have a referenced variable
470
477
  */
471
- if (
472
- n.name !== 'this' &&
473
- !n.name.startsWith(':') &&
474
- !n.name.startsWith('@') &&
475
- scope &&
476
- (variable ||
477
- isUpperCase(n.name[0]) ||
478
- node.name.includes('.') ||
479
- !htmlTags.includes(node.name))
480
- ) {
478
+ const ignore =
479
+ n.name === 'this' || n.name.startsWith(':') || n.name.startsWith('@') || !scope;
480
+ const registerUndef =
481
+ isUpperCase(n.name[0]) || node.name.includes('.') || !htmlTags.includes(node.name);
482
+ const allowUndef = path.parentPath?.context.inSvg;
483
+ if (!ignore && (variable || (registerUndef && !allowUndef))) {
481
484
  registerNodeInScope(n, scope, variable);
482
485
  }
483
486
  }