diff --git a/lib/parsers/gjs-gts-parser.js b/lib/parsers/gjs-gts-parser.js
index c4f4e11eeb..fdf0d0747d 100644
--- a/lib/parsers/gjs-gts-parser.js
+++ b/lib/parsers/gjs-gts-parser.js
@@ -388,7 +388,7 @@ function convertAst(result, preprocessedResult, visitorKeys) {
if (
node.type === 'ExpressionStatement' ||
node.type === 'StaticBlock' ||
- node.type === 'TemplateLiteral' ||
+ node.type === 'TaggedTemplateExpression' ||
node.type === 'ExportDefaultDeclaration'
) {
let range = node.range;
@@ -397,7 +397,9 @@ function convertAst(result, preprocessedResult, visitorKeys) {
}
const template = templateInfos.find(
- (t) => t.templateRange[0] === range[0] && t.templateRange[1] === range[1]
+ (t) =>
+ t.templateRange[0] === range[0] &&
+ (t.templateRange[1] === range[1] || t.templateRange[1] === range[1] + 1)
);
if (!template) {
return null;
@@ -501,9 +503,9 @@ function transformForLint(code) {
jsCode = replaceRange(jsCode, tplInfo.range.start, tplInfo.range.end, replacementCode);
} else {
const tplLength = tplInfo.range.end - tplInfo.range.start;
- const spaces = tplLength - '`'.length - '`'.length - lineBreaks;
+ const spaces = tplLength - '""`'.length - '`'.length - lineBreaks;
const total = ' '.repeat(spaces) + '\n'.repeat(lineBreaks);
- const replacementCode = `\`${total}\``;
+ const replacementCode = `""\`${total}\``;
jsCode = replaceRange(jsCode, tplInfo.range.start, tplInfo.range.end, replacementCode);
}
}
diff --git a/tests/lib/rules-preprocessor/gjs-gts-parser-test.js b/tests/lib/rules-preprocessor/gjs-gts-parser-test.js
index cbd5b86b8b..fddf56b539 100644
--- a/tests/lib/rules-preprocessor/gjs-gts-parser-test.js
+++ b/tests/lib/rules-preprocessor/gjs-gts-parser-test.js
@@ -91,6 +91,10 @@ const valid = [
+
+
+
+
`,
},
{