ember-eslint-parser 0.2.5 → 0.2.6
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 +1 -1
- package/src/parser/gjs-gts-parser.js +23 -14
- package/src/parser/transforms.js +3 -0
package/package.json
CHANGED
|
@@ -40,20 +40,29 @@ module.exports = {
|
|
|
40
40
|
throw new Error('Please install typescript to process gts');
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
try {
|
|
44
|
+
result = isTypescript
|
|
45
|
+
? typescriptParser.parseForESLint(jsCode, { ...options, ranges: true, filePath })
|
|
46
|
+
: babelParser.parseForESLint(jsCode, {
|
|
47
|
+
...options,
|
|
48
|
+
requireConfigFile: false,
|
|
49
|
+
ranges: true,
|
|
50
|
+
});
|
|
51
|
+
if (!info.templateInfos?.length) {
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
const preprocessedResult = preprocessGlimmerTemplates(info, code);
|
|
55
|
+
const { templateVisitorKeys } = preprocessedResult;
|
|
56
|
+
const visitorKeys = { ...result.visitorKeys, ...templateVisitorKeys };
|
|
57
|
+
result.isTypescript = isTypescript;
|
|
58
|
+
convertAst(result, preprocessedResult, visitorKeys);
|
|
59
|
+
if (result.services?.program) {
|
|
60
|
+
syncMtsGtsSourceFiles(result.services?.program);
|
|
61
|
+
}
|
|
62
|
+
return { ...result, visitorKeys };
|
|
63
|
+
} catch (e) {
|
|
64
|
+
console.error(e);
|
|
65
|
+
throw e;
|
|
48
66
|
}
|
|
49
|
-
const preprocessedResult = preprocessGlimmerTemplates(info, code);
|
|
50
|
-
const { templateVisitorKeys } = preprocessedResult;
|
|
51
|
-
const visitorKeys = { ...result.visitorKeys, ...templateVisitorKeys };
|
|
52
|
-
result.isTypescript = isTypescript;
|
|
53
|
-
convertAst(result, preprocessedResult, visitorKeys);
|
|
54
|
-
if (result.services?.program) {
|
|
55
|
-
syncMtsGtsSourceFiles(result.services?.program);
|
|
56
|
-
}
|
|
57
|
-
return { ...result, visitorKeys };
|
|
58
67
|
},
|
|
59
68
|
};
|
package/src/parser/transforms.js
CHANGED
|
@@ -122,6 +122,8 @@ function traverse(visitorKeys, node, visitor) {
|
|
|
122
122
|
|
|
123
123
|
visitor(currentPath);
|
|
124
124
|
|
|
125
|
+
if (!currentPath.node) continue;
|
|
126
|
+
|
|
125
127
|
const visitorKeys = allVisitorKeys[currentPath.node.type];
|
|
126
128
|
if (!visitorKeys) {
|
|
127
129
|
continue;
|
|
@@ -422,6 +424,7 @@ module.exports.convertAst = function convertAst(result, preprocessedResult, visi
|
|
|
422
424
|
// eslint-disable-next-line complexity
|
|
423
425
|
traverse(visitorKeys, result.ast, (path) => {
|
|
424
426
|
const node = path.node;
|
|
427
|
+
if (!node) return null;
|
|
425
428
|
if (
|
|
426
429
|
node.type === 'ExpressionStatement' ||
|
|
427
430
|
node.type === 'StaticBlock' ||
|