ember-eslint-parser 0.6.0 → 0.7.0
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 +6 -6
- package/src/parser/transforms.js +43 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ember-eslint-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": {
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"src"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@babel/eslint-parser": "^7.
|
|
22
|
+
"@babel/eslint-parser": "^7.28.6",
|
|
23
23
|
"@glimmer/syntax": ">= 0.92.0",
|
|
24
24
|
"@typescript-eslint/tsconfig-utils": "^8.38.0",
|
|
25
|
-
"content-tag": "^
|
|
26
|
-
"eslint-scope": "^
|
|
27
|
-
"html-tags": "^
|
|
28
|
-
"mathml-tag-names": "^
|
|
25
|
+
"content-tag": "^4.1.0",
|
|
26
|
+
"eslint-scope": "^9.1.1",
|
|
27
|
+
"html-tags": "^5.1.0",
|
|
28
|
+
"mathml-tag-names": "^4.0.0",
|
|
29
29
|
"svg-tags": "^1.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
package/src/parser/transforms.js
CHANGED
|
@@ -3,9 +3,9 @@ const glimmer = require('@glimmer/syntax');
|
|
|
3
3
|
const { visitorKeys: glimmerVisitorKeys } = glimmer;
|
|
4
4
|
const DocumentLines = require('../utils/document');
|
|
5
5
|
const { Reference, Scope, Variable, Definition } = require('eslint-scope');
|
|
6
|
-
const htmlTags = require('html-tags');
|
|
6
|
+
const htmlTags = require('html-tags').default;
|
|
7
7
|
const svgTags = require('svg-tags');
|
|
8
|
-
const mathMLTags = require('mathml-tag-names');
|
|
8
|
+
const mathMLTags = require('mathml-tag-names').mathmlTagNames;
|
|
9
9
|
|
|
10
10
|
let TypescriptScope = null;
|
|
11
11
|
try {
|
|
@@ -442,9 +442,9 @@ function processGlimmerTemplate({ templateContent, codeLines, templateRange, tok
|
|
|
442
442
|
*/
|
|
443
443
|
module.exports.preprocessGlimmerTemplates = function preprocessGlimmerTemplates(info, code) {
|
|
444
444
|
const templateInfos = info.templateInfos.map((r) => ({
|
|
445
|
-
range: [r.contentRange.
|
|
446
|
-
templateRange: [r.range.
|
|
447
|
-
utf16Range: [byteToCharIndex(code, r.range.
|
|
445
|
+
range: [r.contentRange.startByte, r.contentRange.endByte],
|
|
446
|
+
templateRange: [r.range.startByte, r.range.endByte],
|
|
447
|
+
utf16Range: [byteToCharIndex(code, r.range.startByte), byteToCharIndex(code, r.range.endByte)],
|
|
448
448
|
}));
|
|
449
449
|
const codeLines = new DocumentLines(code);
|
|
450
450
|
const allComments = [];
|
|
@@ -669,20 +669,36 @@ module.exports.transformForLint = function transformForLint(code, fileName) {
|
|
|
669
669
|
* tagName: 'template';
|
|
670
670
|
* contents: string;
|
|
671
671
|
* range: {
|
|
672
|
-
*
|
|
673
|
-
*
|
|
672
|
+
* startByte: number;
|
|
673
|
+
* endByte: number;
|
|
674
|
+
* startChar: number;
|
|
675
|
+
* endChar: number;
|
|
676
|
+
* startUtf16Codepoint: number;
|
|
677
|
+
* endUtf16Codepoint: number;
|
|
674
678
|
* };
|
|
675
679
|
* contentRange: {
|
|
676
|
-
*
|
|
677
|
-
*
|
|
680
|
+
* startByte: number;
|
|
681
|
+
* endByte: number;
|
|
682
|
+
* startChar: number;
|
|
683
|
+
* endChar: number;
|
|
684
|
+
* startUtf16Codepoint: number;
|
|
685
|
+
* endUtf16Codepoint: number;
|
|
678
686
|
* };
|
|
679
687
|
* startRange: {
|
|
680
|
-
*
|
|
681
|
-
*
|
|
688
|
+
* startByte: number;
|
|
689
|
+
* endByte: number;
|
|
690
|
+
* startChar: number;
|
|
691
|
+
* endChar: number;
|
|
692
|
+
* startUtf16Codepoint: number;
|
|
693
|
+
* endUtf16Codepoint: number;
|
|
682
694
|
* };
|
|
683
695
|
* endRange: {
|
|
684
|
-
*
|
|
685
|
-
*
|
|
696
|
+
* startByte: number;
|
|
697
|
+
* endByte: number;
|
|
698
|
+
* startChar: number;
|
|
699
|
+
* endChar: number;
|
|
700
|
+
* startUtf16Codepoint: number;
|
|
701
|
+
* endUtf16Codepoint: number;
|
|
686
702
|
* };
|
|
687
703
|
* }[]}
|
|
688
704
|
*/
|
|
@@ -709,17 +725,27 @@ module.exports.transformForLint = function transformForLint(code, fileName) {
|
|
|
709
725
|
for (const tplInfo of result.reverse()) {
|
|
710
726
|
const content = tplInfo.contents.replace(/`/g, '\\`').replace(/\$/g, '\\$');
|
|
711
727
|
if (tplInfo.type === 'class-member') {
|
|
712
|
-
const tplLength = tplInfo.range.
|
|
728
|
+
const tplLength = tplInfo.range.endByte - tplInfo.range.startByte;
|
|
713
729
|
const spaces = tplLength - byteLength(content) - 'static{`'.length - '`}'.length;
|
|
714
730
|
const total = content + ' '.repeat(spaces);
|
|
715
731
|
const replacementCode = `static{\`${total}\`}`;
|
|
716
|
-
jsCode = replaceRange(
|
|
732
|
+
jsCode = replaceRange(
|
|
733
|
+
jsCode,
|
|
734
|
+
tplInfo.range.startByte,
|
|
735
|
+
tplInfo.range.endByte,
|
|
736
|
+
replacementCode
|
|
737
|
+
);
|
|
717
738
|
} else {
|
|
718
|
-
const tplLength = tplInfo.range.
|
|
739
|
+
const tplLength = tplInfo.range.endByte - tplInfo.range.startByte;
|
|
719
740
|
const spaces = tplLength - byteLength(content) - '`'.length - '`'.length;
|
|
720
741
|
const total = content + ' '.repeat(spaces);
|
|
721
742
|
const replacementCode = `\`${total}\``;
|
|
722
|
-
jsCode = replaceRange(
|
|
743
|
+
jsCode = replaceRange(
|
|
744
|
+
jsCode,
|
|
745
|
+
tplInfo.range.startByte,
|
|
746
|
+
tplInfo.range.endByte,
|
|
747
|
+
replacementCode
|
|
748
|
+
);
|
|
723
749
|
}
|
|
724
750
|
}
|
|
725
751
|
/* istanbul ignore next */
|