ember-eslint-parser 0.2.1 → 0.2.2

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.1",
3
+ "version": "0.2.2",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "repository": {
@@ -267,12 +267,12 @@ module.exports.preprocessGlimmerTemplates = function preprocessGlimmerTemplates(
267
267
  let start = n.range[0];
268
268
  let codeSlice = code.slice(...n.range);
269
269
  for (const part of n.tag.split('.')) {
270
- const regex = new RegExp(`\\b${part}\\b`);
270
+ let pattern = `\\b${part}\\b`;
271
+ if (part.startsWith(':')) {
272
+ pattern = `${part}\\b`;
273
+ }
274
+ const regex = new RegExp(pattern);
271
275
  const match = codeSlice.match(regex);
272
-
273
- // named-blocks are not ElementNodes
274
- if (!match && part.startsWith(':')) continue;
275
-
276
276
  const range = [start + match.index, 0];
277
277
  range[1] = range[0] + part.length;
278
278
  codeSlice = code.slice(range[1], n.range[1]);
@@ -426,21 +426,23 @@ module.exports.convertAst = function convertAst(result, preprocessedResult, visi
426
426
  // always reference first part of tag name, this also has the advantage
427
427
  // that errors regarding this tag will only mark the tag name instead of
428
428
  // the whole tag + children
429
- //
430
- // However, with plain <footer> type nodes, there will be no "parts"
431
- const n = node.parts?.[0] ?? node;
432
-
433
- const name = n?.name ?? n.tag;
434
-
435
- if (htmlTags.includes(name)) {
436
- return null;
437
- }
438
-
429
+ const n = node.parts[0];
439
430
  const { scope, variable } = findVarInParentScopes(result.scopeManager, path, n.name) || {};
431
+ /*
432
+ register a node in scope if we found a variable
433
+ we ignore named-blocks as we know that it doesn't reference anything in current scope
434
+ if we do not find a variable we register it with a missing variable if
435
+ * it starts with upper case, it should be a component with a reference
436
+ * it includes a dot, it's a path which should have a reference
437
+ * it's NOT a standard html tag, it should have a referenced variable
438
+ */
440
439
  if (
440
+ !n.name.startsWith(':') &&
441
441
  scope &&
442
- !name.startsWith(':') &&
443
- (variable || isUpperCase(n.name[0]) || name.includes('.') || !htmlTags.includes(name))
442
+ (variable ||
443
+ isUpperCase(n.name[0]) ||
444
+ node.name.includes('.') ||
445
+ !htmlTags.includes(node.name))
444
446
  ) {
445
447
  registerNodeInScope(n, scope, variable);
446
448
  }