ember-eslint-parser 0.3.8 → 0.4.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/package.json +13 -9
- package/src/parser/transforms.js +12 -8
- 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.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": {
|
|
@@ -19,8 +19,9 @@
|
|
|
19
19
|
],
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@babel/core": "^7.23.6",
|
|
22
|
-
"@typescript-eslint/
|
|
23
|
-
"@typescript-eslint/
|
|
22
|
+
"@typescript-eslint/scope-manager": "^7.1.0",
|
|
23
|
+
"@typescript-eslint/parser": "^7.1.0",
|
|
24
|
+
"@typescript-eslint/visitor-keys": "^7.1.0",
|
|
24
25
|
"concurrently": "^8.2.2",
|
|
25
26
|
"eslint": "^8.0.1",
|
|
26
27
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
"fs-extra": "^11.2.0",
|
|
34
35
|
"prettier": "^3.2.5",
|
|
35
36
|
"publint": "^0.2.6",
|
|
36
|
-
"release-plan": "^0.
|
|
37
|
+
"release-plan": "^0.8.0",
|
|
37
38
|
"typescript": "^5.3.3",
|
|
38
39
|
"vite": "^5.0.12",
|
|
39
40
|
"vitest": "^1.2.2"
|
|
@@ -41,7 +42,6 @@
|
|
|
41
42
|
"dependencies": {
|
|
42
43
|
"@babel/eslint-parser": "7.23.10",
|
|
43
44
|
"@glimmer/syntax": "^0.88.0",
|
|
44
|
-
"@typescript-eslint/scope-manager": "^6.21.0",
|
|
45
45
|
"content-tag": "^1.2.2",
|
|
46
46
|
"eslint-scope": "^7.2.2",
|
|
47
47
|
"html-tags": "^3.3.1"
|
|
@@ -51,15 +51,19 @@
|
|
|
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",
|
|
59
63
|
"lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"",
|
|
60
|
-
"lint:js": "eslint .",
|
|
64
|
+
"lint:js": "eslint . --max-warnings=0",
|
|
61
65
|
"lint:package": "pnpm publint",
|
|
62
66
|
"lint:fix": "concurrently \"npm:lint:*:fix\" --names \"fix:\"",
|
|
63
|
-
"lint:js:fix": "eslint . --fix"
|
|
67
|
+
"lint:js:fix": "eslint . --fix --max-warnings=0"
|
|
64
68
|
}
|
|
65
69
|
}
|
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) {
|
|
@@ -566,20 +574,16 @@ module.exports.transformForLint = function transformForLint(code) {
|
|
|
566
574
|
*/
|
|
567
575
|
const result = processor.parse(code);
|
|
568
576
|
for (const tplInfo of result.reverse()) {
|
|
569
|
-
const
|
|
570
|
-
(prev, curr) => (prev + (curr.codePointAt(0) === '`') ? 1 : 0),
|
|
571
|
-
0
|
|
572
|
-
);
|
|
573
|
-
const content = tplInfo.contents.replace(/`/g, '\\`');
|
|
577
|
+
const content = tplInfo.contents.replace(/`/g, '\\`').replace(/\$/g, '\\$');
|
|
574
578
|
if (tplInfo.type === 'class-member') {
|
|
575
579
|
const tplLength = tplInfo.range.end - tplInfo.range.start;
|
|
576
|
-
const spaces = tplLength - byteLength(content) - 'static{`'.length - '`}'.length
|
|
580
|
+
const spaces = tplLength - byteLength(content) - 'static{`'.length - '`}'.length;
|
|
577
581
|
const total = content + ' '.repeat(spaces);
|
|
578
582
|
const replacementCode = `static{\`${total}\`}`;
|
|
579
583
|
jsCode = replaceRange(jsCode, tplInfo.range.start, tplInfo.range.end, replacementCode);
|
|
580
584
|
} else {
|
|
581
585
|
const tplLength = tplInfo.range.end - tplInfo.range.start;
|
|
582
|
-
const spaces = tplLength - byteLength(content) - '`'.length - '`'.length
|
|
586
|
+
const spaces = tplLength - byteLength(content) - '`'.length - '`'.length;
|
|
583
587
|
const total = content + ' '.repeat(spaces);
|
|
584
588
|
const replacementCode = `\`${total}\``;
|
|
585
589
|
jsCode = replaceRange(jsCode, tplInfo.range.start, tplInfo.range.end, replacementCode);
|
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) {
|