ember-eslint-parser 0.14.5 → 0.14.7

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
@@ -31,6 +31,21 @@ It's recommended to only use _overrides_ when defining your eslint config, so us
31
31
  if we detect a typescript parser, it will also be used for all files, otherwise babel parser will be used.
32
32
  If we cannot find a typescript parser when linting gts we throw an error.
33
33
 
34
+ If you use type-aware rules, route `.js`/`.ts` through this parser too, as
35
+ `eslint-plugin-ember`'s configs do:
36
+
37
+ ```js
38
+ {
39
+ files: ['**/*.{js,ts}'],
40
+ parser: 'ember-eslint-parser',
41
+ // ...
42
+ },
43
+ ```
44
+
45
+ `@typescript-eslint/parser` hands TypeScript the source as ESLint read it, so a
46
+ `.ts` file importing from a `.gts` gets an `error` type for that import. This
47
+ parser rewrites the specifier first.
48
+
34
49
  ## HBS (Handlebars) support
35
50
 
36
51
  For `.hbs` template files, use the `ember-eslint-parser/hbs` parser. In ESLint's flat config format (ESLint 9+):
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-eslint-parser",
3
- "version": "0.14.5",
3
+ "version": "0.14.7",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from 'node:module';
2
2
  import { registerParsedFile } from '../preprocessor/noop.js';
3
- import { patchTs, replaceExtensions, syncMtsGtsSourceFiles, typescriptParser } from './ts-patch.js';
3
+ import { replaceExtensions, syncMtsGtsSourceFiles, typescriptParser } from './ts-patch.js';
4
4
  import { buildGlimmerVisitors } from './transforms.js';
5
5
  import { toTree } from 'ember-estree';
6
6
 
@@ -48,10 +48,6 @@ export const meta = {
48
48
  };
49
49
 
50
50
  export function parseForESLint(code, options) {
51
- // Only patch TypeScript if we actually need it.
52
- if (options.programs || options.projectService || options.project) {
53
- patchTs();
54
- }
55
51
  registerParsedFile(options.filePath);
56
52
 
57
53
  const isTypescript = options.filePath.endsWith('.gts') || options.filePath.endsWith('.ts');
@@ -61,6 +61,13 @@ function findVarInParentScopes(scopeManager, nodePath, name) {
61
61
 
62
62
  function registerNodeInScope(node, scope, variable) {
63
63
  const ref = new Reference(node, scope, Reference.READ);
64
+ // A template reference always reads a value. typescript-eslint's scope
65
+ // manager flags every reference as a value or type reference, and its rules
66
+ // rely on that (no-unused-vars treats a reference without
67
+ // isValueReference as type-only since 8.71.1), but eslint-scope's
68
+ // Reference has neither flag.
69
+ ref.isValueReference = true;
70
+ ref.isTypeReference = false;
64
71
  if (variable) {
65
72
  variable.references.push(ref);
66
73
  ref.resolved = variable;
@@ -123,6 +123,12 @@ try {
123
123
  return jsCode;
124
124
  };
125
125
 
126
+ // typescript-eslint copies `ts.sys` by value when it builds a program or
127
+ // project service, on the first type-aware parse in the process — which may be
128
+ // a plain .ts file that never reaches this parser. Patching at module load is
129
+ // what puts the wrappers in that copy, and in the project's first file scan.
130
+ patchTs();
131
+
126
132
  /**
127
133
  *
128
134
  * @param program {ts.Program}