ember-eslint-parser 0.4.0 → 0.4.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/package.json +9 -5
- package/src/parser/transforms.js +19 -6
- package/src/parser/ts-patch.js +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-eslint-parser",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": {
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
],
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@babel/core": "^7.23.6",
|
|
22
|
+
"@typescript-eslint/scope-manager": "^7.1.0",
|
|
22
23
|
"@typescript-eslint/parser": "^7.1.0",
|
|
23
24
|
"@typescript-eslint/visitor-keys": "^7.1.0",
|
|
24
25
|
"concurrently": "^8.2.2",
|
|
@@ -40,8 +41,7 @@
|
|
|
40
41
|
},
|
|
41
42
|
"dependencies": {
|
|
42
43
|
"@babel/eslint-parser": "7.23.10",
|
|
43
|
-
"@glimmer/syntax": "^0.
|
|
44
|
-
"@typescript-eslint/scope-manager": "^7.1.0",
|
|
44
|
+
"@glimmer/syntax": "^0.92.0",
|
|
45
45
|
"content-tag": "^1.2.2",
|
|
46
46
|
"eslint-scope": "^7.2.2",
|
|
47
47
|
"html-tags": "^3.3.1"
|
|
@@ -51,8 +51,12 @@
|
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@babel/core": "^7.23.6",
|
|
54
|
-
"@typescript-eslint/parser": "
|
|
55
|
-
|
|
54
|
+
"@typescript-eslint/parser": "*"
|
|
55
|
+
},
|
|
56
|
+
"peerDependenciesMeta": {
|
|
57
|
+
"@typescript-eslint/parser": {
|
|
58
|
+
"optional": true
|
|
59
|
+
}
|
|
56
60
|
},
|
|
57
61
|
"scripts": {
|
|
58
62
|
"test": "vitest run",
|
package/src/parser/transforms.js
CHANGED
|
@@ -2,10 +2,18 @@ const ContentTag = require('content-tag');
|
|
|
2
2
|
const glimmer = require('@glimmer/syntax');
|
|
3
3
|
const DocumentLines = require('../utils/document');
|
|
4
4
|
const { visitorKeys: glimmerVisitorKeys } = require('@glimmer/syntax');
|
|
5
|
-
const TypescriptScope = require('@typescript-eslint/scope-manager');
|
|
6
5
|
const { Reference, Scope, Variable, Definition } = require('eslint-scope');
|
|
7
6
|
const htmlTags = require('html-tags');
|
|
8
7
|
|
|
8
|
+
let TypescriptScope = null;
|
|
9
|
+
try {
|
|
10
|
+
const path = require.resolve('@typescript-eslint/parser');
|
|
11
|
+
// eslint-disable-next-line n/no-unpublished-require
|
|
12
|
+
TypescriptScope = require('@typescript-eslint/scope-manager', { paths: [path] });
|
|
13
|
+
} catch {
|
|
14
|
+
// not available
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
const BufferMap = new Map();
|
|
10
18
|
|
|
11
19
|
function getBuffer(str) {
|
|
@@ -312,7 +320,7 @@ module.exports.preprocessGlimmerTemplates = function preprocessGlimmerTemplates(
|
|
|
312
320
|
|
|
313
321
|
if (n.type === 'ElementNode') {
|
|
314
322
|
n.name = n.tag;
|
|
315
|
-
n.parts = n.
|
|
323
|
+
n.parts = [n.path.head].map((p) => {
|
|
316
324
|
const range = [
|
|
317
325
|
offset + docLines.positionToOffset(p.loc.start),
|
|
318
326
|
offset + docLines.positionToOffset(p.loc.end),
|
|
@@ -323,9 +331,9 @@ module.exports.preprocessGlimmerTemplates = function preprocessGlimmerTemplates(
|
|
|
323
331
|
};
|
|
324
332
|
return {
|
|
325
333
|
...p,
|
|
334
|
+
name: p.original,
|
|
326
335
|
parent: n,
|
|
327
336
|
type: 'GlimmerElementNodePart',
|
|
328
|
-
name: p.value,
|
|
329
337
|
range,
|
|
330
338
|
loc,
|
|
331
339
|
};
|
|
@@ -333,8 +341,7 @@ module.exports.preprocessGlimmerTemplates = function preprocessGlimmerTemplates(
|
|
|
333
341
|
}
|
|
334
342
|
|
|
335
343
|
if ('blockParams' in n) {
|
|
336
|
-
|
|
337
|
-
n.params = (n.blockParamNodes || []).map((p) => {
|
|
344
|
+
n.params = (n.params || []).map((p) => {
|
|
338
345
|
const range = [
|
|
339
346
|
offset + docLines.positionToOffset(p.loc.start),
|
|
340
347
|
offset + docLines.positionToOffset(p.loc.end),
|
|
@@ -345,8 +352,9 @@ module.exports.preprocessGlimmerTemplates = function preprocessGlimmerTemplates(
|
|
|
345
352
|
};
|
|
346
353
|
return {
|
|
347
354
|
...p,
|
|
355
|
+
type: 'BlockParam',
|
|
356
|
+
name: p.original,
|
|
348
357
|
parent: n,
|
|
349
|
-
name: p.value,
|
|
350
358
|
range,
|
|
351
359
|
loc,
|
|
352
360
|
};
|
|
@@ -500,12 +508,17 @@ module.exports.convertAst = function convertAst(result, preprocessedResult, visi
|
|
|
500
508
|
const scope = result.isTypescript
|
|
501
509
|
? new TypescriptScope.BlockScope(result.scopeManager, upperScope, node)
|
|
502
510
|
: new Scope(result.scopeManager, 'block', upperScope, node);
|
|
511
|
+
const declaredVariables =
|
|
512
|
+
result.scopeManager.declaredVariables || result.scopeManager.__declaredVariables;
|
|
513
|
+
const vars = [];
|
|
514
|
+
declaredVariables.set(node, vars);
|
|
503
515
|
for (const [i, b] of node.params.entries()) {
|
|
504
516
|
const v = new Variable(b.name, scope);
|
|
505
517
|
v.identifiers.push(b);
|
|
506
518
|
v.defs.push(new Definition('Parameter', b, node, node, i, 'Block Param'));
|
|
507
519
|
scope.variables.push(v);
|
|
508
520
|
scope.set.set(b.name, v);
|
|
521
|
+
vars.push(v);
|
|
509
522
|
}
|
|
510
523
|
}
|
|
511
524
|
return null;
|
package/src/parser/ts-patch.js
CHANGED
|
@@ -5,7 +5,9 @@ const { replaceRange } = require('./transforms');
|
|
|
5
5
|
let patchTs, replaceExtensions, syncMtsGtsSourceFiles, typescriptParser, isPatched;
|
|
6
6
|
|
|
7
7
|
try {
|
|
8
|
-
const
|
|
8
|
+
const tsPath = require.resolve('@typescript-eslint/parser');
|
|
9
|
+
// eslint-disable-next-line n/no-unpublished-require
|
|
10
|
+
const ts = require('typescript', { paths: [tsPath] });
|
|
9
11
|
typescriptParser = require('@typescript-eslint/parser');
|
|
10
12
|
patchTs = function patchTs() {
|
|
11
13
|
if (isPatched) {
|