ember-eslint-parser 0.2.0 → 0.2.1

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/README.md CHANGED
@@ -1 +1,33 @@
1
1
  # ember-eslint-parser
2
+
3
+ This is the eslint parser for ember's gjs and gts files (using `<template>`).
4
+
5
+ It is meant to be used with [eslint-plugin-ember](https://github.com/ember-cli/eslint-plugin-ember), which provides nice defaults for all the different file types in ember projects.
6
+
7
+ It's recommended to only use _overrides_ when defining your eslint config, so using this parser would look like this:
8
+ ```js
9
+ {
10
+ files: ['**/*.gjs'],
11
+ parser: 'ember-eslint-parser',
12
+ plugins: ['ember'],
13
+ extends: [
14
+ 'eslint:recommended',
15
+ 'plugin:ember/recommended',
16
+ 'plugin:ember/recommended-gjs',
17
+ ],
18
+ },
19
+ {
20
+ files: ['**/*.gts'],
21
+ parser: 'ember-eslint-parser',
22
+ plugins: ['ember'],
23
+ extends: [
24
+ 'eslint:recommended',
25
+ 'plugin:ember/recommended',
26
+ 'plugin:ember/recommended-gts',
27
+ ],
28
+ },
29
+ ```
30
+
31
+ ## Support
32
+
33
+ eslint-plugin-ember is the primary consumer of this parser library, so SemVer _may_ not be respected for other consumers.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-eslint-parser",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "repository": {
@@ -28,6 +28,8 @@
28
28
  "eslint-plugin-n": "^16.4.0",
29
29
  "eslint-plugin-prettier": "^5.0.1",
30
30
  "eslint-plugin-promise": "^6.0.0",
31
+ "execa": "^8.0.1",
32
+ "fs-extra": "^11.2.0",
31
33
  "jest": "^29.7.0",
32
34
  "prettier": "^3.1.1",
33
35
  "publint": "^0.2.6",
@@ -51,7 +53,6 @@
51
53
  "typescript": "^5.3.3"
52
54
  },
53
55
  "scripts": {
54
- "test": "echo \"Error: no test specified\" && exit 1",
55
56
  "lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"",
56
57
  "lint:js": "eslint .",
57
58
  "lint:package": "pnpm publint",
@@ -48,6 +48,7 @@ function findVarInParentScopes(scopeManager, nodePath, name) {
48
48
  if (!scope) {
49
49
  return { scope: currentScope };
50
50
  }
51
+
51
52
  return { scope: currentScope, variable: scope.set.get(name) };
52
53
  }
53
54
 
@@ -268,6 +269,10 @@ module.exports.preprocessGlimmerTemplates = function preprocessGlimmerTemplates(
268
269
  for (const part of n.tag.split('.')) {
269
270
  const regex = new RegExp(`\\b${part}\\b`);
270
271
  const match = codeSlice.match(regex);
272
+
273
+ // named-blocks are not ElementNodes
274
+ if (!match && part.startsWith(':')) continue;
275
+
271
276
  const range = [start + match.index, 0];
272
277
  range[1] = range[0] + part.length;
273
278
  codeSlice = code.slice(range[1], n.range[1]);
@@ -421,14 +426,21 @@ module.exports.convertAst = function convertAst(result, preprocessedResult, visi
421
426
  // always reference first part of tag name, this also has the advantage
422
427
  // that errors regarding this tag will only mark the tag name instead of
423
428
  // the whole tag + children
424
- const n = node.parts[0];
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
+
425
439
  const { scope, variable } = findVarInParentScopes(result.scopeManager, path, n.name) || {};
426
440
  if (
427
441
  scope &&
428
- (variable ||
429
- isUpperCase(n.name[0]) ||
430
- node.name.includes('.') ||
431
- !htmlTags.includes(node.name))
442
+ !name.startsWith(':') &&
443
+ (variable || isUpperCase(n.name[0]) || name.includes('.') || !htmlTags.includes(name))
432
444
  ) {
433
445
  registerNodeInScope(n, scope, variable);
434
446
  }