From b0f9c6a64b110a7e62f2e5d1818419ef0e83af8d Mon Sep 17 00:00:00 2001
From: Isaac Lee <16869656+ijlee2@users.noreply.github.com>
Date: Thu, 30 Apr 2026 17:35:20 +0200
Subject: [PATCH 1/3] chore: Localized ignore directives
---
.../template-tag/src/-private/content-tag/get-template.ts | 4 +++-
packages/ast/template-tag/src/-private/to-ecma.ts | 6 +++++-
packages/ast/template-tag/src/-private/to-template-tag.ts | 7 ++++++-
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/packages/ast/template-tag/src/-private/content-tag/get-template.ts b/packages/ast/template-tag/src/-private/content-tag/get-template.ts
index 4b3b0d90..1a683a2b 100644
--- a/packages/ast/template-tag/src/-private/content-tag/get-template.ts
+++ b/packages/ast/template-tag/src/-private/content-tag/get-template.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { MARKER } from './marker.js';
export function getTemplate(expression: unknown): string | undefined {
@@ -9,14 +8,17 @@ export function getTemplate(expression: unknown): string | undefined {
if (
// @ts-expect-error: Incorrect type
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
expression.callee.type !== 'Identifier' ||
// @ts-expect-error: Incorrect type
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
expression.callee.name !== MARKER
) {
return;
}
// @ts-expect-error: Incorrect type
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const template = expression.arguments[0].quasis[0].value.raw as string;
return template;
diff --git a/packages/ast/template-tag/src/-private/to-ecma.ts b/packages/ast/template-tag/src/-private/to-ecma.ts
index 91ad7e36..fd9b1d6c 100644
--- a/packages/ast/template-tag/src/-private/to-ecma.ts
+++ b/packages/ast/template-tag/src/-private/to-ecma.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
import { AST } from '@codemod-utils/ast-javascript';
import { getTemplate, preprocessor } from './content-tag.js';
@@ -18,6 +17,7 @@ function getMarker(nodeValue: unknown): Marker {
// @ts-expect-error: Incorrect type
code: AST.print(nodeValue),
// @ts-expect-error: Incorrect type
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
end: nodeValue.loc.end,
};
}
@@ -64,6 +64,7 @@ export function findMarkers(file: string): Marker[] {
},
visitExportDefaultDeclaration(node) {
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const template = getTemplate(node.value.declaration);
if (template === undefined) {
@@ -78,12 +79,15 @@ export function findMarkers(file: string): Marker[] {
},
visitStaticBlock(node) {
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
const bodyNode = node.value.body[0];
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (bodyNode.type !== 'ExpressionStatement') {
return false;
}
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const template = getTemplate(bodyNode.expression);
if (template === undefined) {
diff --git a/packages/ast/template-tag/src/-private/to-template-tag.ts b/packages/ast/template-tag/src/-private/to-template-tag.ts
index 5f20e9a0..391b62cb 100644
--- a/packages/ast/template-tag/src/-private/to-template-tag.ts
+++ b/packages/ast/template-tag/src/-private/to-template-tag.ts
@@ -1,4 +1,3 @@
-/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
import { AST } from '@codemod-utils/ast-javascript';
import { getTemplate, MARKER } from './content-tag.js';
@@ -24,6 +23,7 @@ export function removeMarkers(file: string): string {
},
visitExportDefaultDeclaration(node) {
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const template = getTemplate(node.value.declaration);
if (template === undefined) {
@@ -37,7 +37,9 @@ export function removeMarkers(file: string): string {
visitImportDeclaration(node) {
if (
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
node.value.source.type !== 'StringLiteral' ||
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
node.value.source.value !== '@ember/template-compiler'
) {
return false;
@@ -48,12 +50,15 @@ export function removeMarkers(file: string): string {
},
visitStaticBlock(node) {
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
const bodyNode = node.value.body[0];
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (bodyNode.type !== 'ExpressionStatement') {
return false;
}
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const template = getTemplate(bodyNode.expression);
if (template === undefined) {
From 1cb66eb2f3da2313c1e7efbe265699669b42a059 Mon Sep 17 00:00:00 2001
From: Isaac Lee <16869656+ijlee2@users.noreply.github.com>
Date: Thu, 30 Apr 2026 17:35:26 +0200
Subject: [PATCH 2/3] chore: Fixed lint errors
---
.../ast/template-tag/src/-private/to-ecma.ts | 48 +++++++++----------
.../src/-private/to-template-tag.ts | 28 +++++------
2 files changed, 34 insertions(+), 42 deletions(-)
diff --git a/packages/ast/template-tag/src/-private/to-ecma.ts b/packages/ast/template-tag/src/-private/to-ecma.ts
index fd9b1d6c..dafd797a 100644
--- a/packages/ast/template-tag/src/-private/to-ecma.ts
+++ b/packages/ast/template-tag/src/-private/to-ecma.ts
@@ -12,16 +12,6 @@ type Marker = {
};
};
-function getMarker(nodeValue: unknown): Marker {
- return {
- // @ts-expect-error: Incorrect type
- code: AST.print(nodeValue),
- // @ts-expect-error: Incorrect type
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
- end: nodeValue.loc.end,
- };
-}
-
function sortMarkers(a: Marker, b: Marker): number {
if (a.end.line > b.end.line) {
return -1;
@@ -49,52 +39,60 @@ export function findMarkers(file: string): Marker[] {
const markers: Marker[] = [];
traverse(code, {
- visitCallExpression(node) {
- const template = getTemplate(node.value);
+ visitCallExpression(path) {
+ const template = getTemplate(path.node);
if (template === undefined) {
- this.traverse(node);
+ this.traverse(path);
return false;
}
- markers.push(getMarker(node.value));
+ markers.push({
+ code: AST.print(path.node),
+ // @ts-expect-error: Incorrect type
+ end: path.node.loc!.end,
+ });
return false;
},
- visitExportDefaultDeclaration(node) {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
- const template = getTemplate(node.value.declaration);
+ visitExportDefaultDeclaration(path) {
+ const template = getTemplate(path.node.declaration);
if (template === undefined) {
- this.traverse(node);
+ this.traverse(path);
return false;
}
- markers.push(getMarker(node.value));
+ markers.push({
+ code: AST.print(path.node),
+ // @ts-expect-error: Incorrect type
+ end: path.node.loc!.end,
+ });
return false;
},
- visitStaticBlock(node) {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
- const bodyNode = node.value.body[0];
+ visitStaticBlock(path) {
+ const bodyNode = path.node.body[0]!;
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (bodyNode.type !== 'ExpressionStatement') {
return false;
}
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const template = getTemplate(bodyNode.expression);
if (template === undefined) {
return false;
}
- markers.push(getMarker(node.value));
+ markers.push({
+ code: AST.print(path.node),
+ // @ts-expect-error: Incorrect type
+ end: path.node.loc!.end,
+ });
return false;
},
diff --git a/packages/ast/template-tag/src/-private/to-template-tag.ts b/packages/ast/template-tag/src/-private/to-template-tag.ts
index 391b62cb..b00ac320 100644
--- a/packages/ast/template-tag/src/-private/to-template-tag.ts
+++ b/packages/ast/template-tag/src/-private/to-template-tag.ts
@@ -10,11 +10,11 @@ export function removeMarkers(file: string): string {
const traverse = AST.traverse(true);
const ast = traverse(file, {
- visitCallExpression(node) {
- const template = getTemplate(node.value);
+ visitCallExpression(path) {
+ const template = getTemplate(path.node);
if (template === undefined) {
- this.traverse(node);
+ this.traverse(path);
return false;
}
@@ -22,12 +22,11 @@ export function removeMarkers(file: string): string {
return `${template}`;
},
- visitExportDefaultDeclaration(node) {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
- const template = getTemplate(node.value.declaration);
+ visitExportDefaultDeclaration(path) {
+ const template = getTemplate(path.node.declaration);
if (template === undefined) {
- this.traverse(node);
+ this.traverse(path);
return false;
}
@@ -35,12 +34,10 @@ export function removeMarkers(file: string): string {
return `${template}`;
},
- visitImportDeclaration(node) {
+ visitImportDeclaration(path) {
if (
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
- node.value.source.type !== 'StringLiteral' ||
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
- node.value.source.value !== '@ember/template-compiler'
+ path.node.source.type !== 'StringLiteral' ||
+ path.node.source.value !== '@ember/template-compiler'
) {
return false;
}
@@ -49,16 +46,13 @@ export function removeMarkers(file: string): string {
return null;
},
- visitStaticBlock(node) {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
- const bodyNode = node.value.body[0];
+ visitStaticBlock(path) {
+ const bodyNode = path.node.body[0]!;
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (bodyNode.type !== 'ExpressionStatement') {
return false;
}
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
const template = getTemplate(bodyNode.expression);
if (template === undefined) {
From 6c7415d8d767b6a6c5d19c144745d0a11c141caf Mon Sep 17 00:00:00 2001
From: Isaac Lee <16869656+ijlee2@users.noreply.github.com>
Date: Thu, 30 Apr 2026 17:36:03 +0200
Subject: [PATCH 3/3] chore: Added changeset
---
.changeset/better-tires-wait.md | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 .changeset/better-tires-wait.md
diff --git a/.changeset/better-tires-wait.md b/.changeset/better-tires-wait.md
new file mode 100644
index 00000000..e6cfb9b3
--- /dev/null
+++ b/.changeset/better-tires-wait.md
@@ -0,0 +1,5 @@
+---
+"@codemod-utils/ast-template-tag": minor
+---
+
+Fixed lint errors