ember-eslint-parser 0.2.1 → 0.2.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.
- package/package.json +1 -1
- package/src/parser/transforms.js +20 -17
package/package.json
CHANGED
package/src/parser/transforms.js
CHANGED
|
@@ -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
|
-
|
|
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,24 @@ 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 !== 'this' &&
|
|
441
|
+
!n.name.startsWith(':') &&
|
|
441
442
|
scope &&
|
|
442
|
-
|
|
443
|
-
|
|
443
|
+
(variable ||
|
|
444
|
+
isUpperCase(n.name[0]) ||
|
|
445
|
+
node.name.includes('.') ||
|
|
446
|
+
!htmlTags.includes(node.name))
|
|
444
447
|
) {
|
|
445
448
|
registerNodeInScope(n, scope, variable);
|
|
446
449
|
}
|