ember-eslint-parser 0.2.0 → 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/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.2",
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
 
@@ -266,7 +267,11 @@ module.exports.preprocessGlimmerTemplates = function preprocessGlimmerTemplates(
266
267
  let start = n.range[0];
267
268
  let codeSlice = code.slice(...n.range);
268
269
  for (const part of n.tag.split('.')) {
269
- 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);
270
275
  const match = codeSlice.match(regex);
271
276
  const range = [start + match.index, 0];
272
277
  range[1] = range[0] + part.length;
@@ -423,7 +428,16 @@ module.exports.convertAst = function convertAst(result, preprocessedResult, visi
423
428
  // the whole tag + children
424
429
  const n = node.parts[0];
425
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
+ */
426
439
  if (
440
+ !n.name.startsWith(':') &&
427
441
  scope &&
428
442
  (variable ||
429
443
  isUpperCase(n.name[0]) ||