ember-eslint-parser 0.11.1 → 0.11.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 +8 -3
- package/src/parser/gjs-gts-parser.js +35 -25
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-eslint-parser",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": {
|
|
@@ -23,15 +23,16 @@
|
|
|
23
23
|
"@glimmer/syntax": "^0.95.0",
|
|
24
24
|
"@typescript-eslint/tsconfig-utils": "^8.57.1",
|
|
25
25
|
"content-tag": "^4.1.1",
|
|
26
|
-
"ember-estree": "^0.6.
|
|
26
|
+
"ember-estree": "^0.6.3",
|
|
27
27
|
"eslint-scope": "^9.1.2",
|
|
28
|
-
"espree": "^10.4.0",
|
|
29
28
|
"html-tags": "^5.1.0",
|
|
30
29
|
"mathml-tag-names": "^4.0.0",
|
|
31
30
|
"svg-tags": "^1.0.0"
|
|
32
31
|
},
|
|
33
32
|
"devDependencies": {
|
|
34
33
|
"@babel/core": "^7.23.6",
|
|
34
|
+
"@babel/eslint-parser": "^7.28.6",
|
|
35
|
+
"@babel/plugin-proposal-decorators": "^7.25.9",
|
|
35
36
|
"@typescript-eslint/parser": "^7.1.0",
|
|
36
37
|
"@typescript-eslint/scope-manager": "^7.1.0",
|
|
37
38
|
"@typescript-eslint/visitor-keys": "^7.1.0",
|
|
@@ -54,9 +55,13 @@
|
|
|
54
55
|
"vitest": "^1.2.2"
|
|
55
56
|
},
|
|
56
57
|
"peerDependencies": {
|
|
58
|
+
"@babel/eslint-parser": "^7.28.6",
|
|
57
59
|
"@typescript-eslint/parser": "*"
|
|
58
60
|
},
|
|
59
61
|
"peerDependenciesMeta": {
|
|
62
|
+
"@babel/eslint-parser": {
|
|
63
|
+
"optional": true
|
|
64
|
+
},
|
|
60
65
|
"@typescript-eslint/parser": {
|
|
61
66
|
"optional": true
|
|
62
67
|
}
|
|
@@ -4,11 +4,26 @@ import { registerParsedFile } from '../preprocessor/noop.js';
|
|
|
4
4
|
import { patchTs, replaceExtensions, syncMtsGtsSourceFiles, typescriptParser } from './ts-patch.js';
|
|
5
5
|
import { buildGlimmerVisitors } from './transforms.js';
|
|
6
6
|
import { toTree } from 'ember-estree';
|
|
7
|
-
import * as eslintScope from 'eslint-scope';
|
|
8
|
-
import * as espree from 'espree';
|
|
9
7
|
|
|
10
8
|
const require = createRequire(import.meta.url);
|
|
11
9
|
|
|
10
|
+
// Resolved once at module load via createRequire — top-level `await import()`
|
|
11
|
+
// would mark the module as async, and the bench harness loads parsers
|
|
12
|
+
// synchronously through `createRequire`. `@babel/eslint-parser` is an optional
|
|
13
|
+
// peer (TS-only setups don't need it), so a missing dep yields null and the JS
|
|
14
|
+
// path below emits a targeted error.
|
|
15
|
+
//
|
|
16
|
+
// The experimental-worker entry point runs babel in a worker and matches the
|
|
17
|
+
// parser ember-cli wires up for plain `.js` files in JS-only apps, so config
|
|
18
|
+
// discovery (decorators & friends) lines up with how the rest of the project
|
|
19
|
+
// is being parsed.
|
|
20
|
+
let babelParser = null;
|
|
21
|
+
try {
|
|
22
|
+
babelParser = require('@babel/eslint-parser/experimental-worker');
|
|
23
|
+
} catch {
|
|
24
|
+
// optional peer; left null
|
|
25
|
+
}
|
|
26
|
+
|
|
12
27
|
/**
|
|
13
28
|
* implements https://eslint.org/docs/latest/extend/custom-parsers
|
|
14
29
|
*
|
|
@@ -186,30 +201,25 @@ export function parseForESLint(code, options) {
|
|
|
186
201
|
return tsResult;
|
|
187
202
|
}
|
|
188
203
|
: (placeholderJS) => {
|
|
189
|
-
// JS path:
|
|
190
|
-
//
|
|
191
|
-
//
|
|
192
|
-
//
|
|
193
|
-
//
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
comment: true,
|
|
206
|
-
});
|
|
207
|
-
scopeManager = eslintScope.analyze(program, {
|
|
208
|
-
ecmaVersion: 2022,
|
|
209
|
-
sourceType: 'module',
|
|
210
|
-
range: true,
|
|
204
|
+
// JS path: defer to @babel/eslint-parser, which discovers the
|
|
205
|
+
// consuming app's babel config and applies its plugins (notably
|
|
206
|
+
// decorators) when parsing. That keeps gjs aligned with how the
|
|
207
|
+
// app's plain `.js` files are parsed, so syntax accepted there
|
|
208
|
+
// is accepted here without a second parser config.
|
|
209
|
+
if (!babelParser) {
|
|
210
|
+
throw new Error(
|
|
211
|
+
'ember-eslint-parser: linting `.gjs`/`.gts` files in a JS-only ' +
|
|
212
|
+
'project requires `@babel/eslint-parser`. Install it as a ' +
|
|
213
|
+
'dev dependency, or install `@typescript-eslint/parser` to ' +
|
|
214
|
+
'opt into the TypeScript-based path.'
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
const babelResult = babelParser.parseForESLint(placeholderJS, {
|
|
218
|
+
...options,
|
|
219
|
+
filePath,
|
|
211
220
|
});
|
|
212
|
-
|
|
221
|
+
scopeManager = babelResult.scopeManager;
|
|
222
|
+
return babelResult;
|
|
213
223
|
},
|
|
214
224
|
// Factory form: scopeManager is set by the parser callback before this
|
|
215
225
|
// runs. Returns null when unavailable so ember-estree skips the walk.
|