Skip to content

Commit 00061e0

Browse files
authored
Fixed lint errors (#303)
* chore: Localized ignore directives * chore: Fixed lint errors * chore: Added changeset
1 parent 36b481c commit 00061e0

4 files changed

Lines changed: 42 additions & 34 deletions

File tree

.changeset/better-tires-wait.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@codemod-utils/ast-template-tag": minor
3+
---
4+
5+
Fixed lint errors

packages/ast/template-tag/src/-private/content-tag/get-template.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
21
import { MARKER } from './marker.js';
32

43
export function getTemplate(expression: unknown): string | undefined {
@@ -9,14 +8,17 @@ export function getTemplate(expression: unknown): string | undefined {
98

109
if (
1110
// @ts-expect-error: Incorrect type
11+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1212
expression.callee.type !== 'Identifier' ||
1313
// @ts-expect-error: Incorrect type
14+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1415
expression.callee.name !== MARKER
1516
) {
1617
return;
1718
}
1819

1920
// @ts-expect-error: Incorrect type
21+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
2022
const template = expression.arguments[0].quasis[0].value.raw as string;
2123

2224
return template;

packages/ast/template-tag/src/-private/to-ecma.ts

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
21
import { AST } from '@codemod-utils/ast-javascript';
32

43
import { getTemplate, preprocessor } from './content-tag.js';
@@ -13,15 +12,6 @@ type Marker = {
1312
};
1413
};
1514

16-
function getMarker(nodeValue: unknown): Marker {
17-
return {
18-
// @ts-expect-error: Incorrect type
19-
code: AST.print(nodeValue),
20-
// @ts-expect-error: Incorrect type
21-
end: nodeValue.loc.end,
22-
};
23-
}
24-
2515
function sortMarkers(a: Marker, b: Marker): number {
2616
if (a.end.line > b.end.line) {
2717
return -1;
@@ -49,36 +39,44 @@ export function findMarkers(file: string): Marker[] {
4939
const markers: Marker[] = [];
5040

5141
traverse(code, {
52-
visitCallExpression(node) {
53-
const template = getTemplate(node.value);
42+
visitCallExpression(path) {
43+
const template = getTemplate(path.node);
5444

5545
if (template === undefined) {
56-
this.traverse(node);
46+
this.traverse(path);
5747

5848
return false;
5949
}
6050

61-
markers.push(getMarker(node.value));
51+
markers.push({
52+
code: AST.print(path.node),
53+
// @ts-expect-error: Incorrect type
54+
end: path.node.loc!.end,
55+
});
6256

6357
return false;
6458
},
6559

66-
visitExportDefaultDeclaration(node) {
67-
const template = getTemplate(node.value.declaration);
60+
visitExportDefaultDeclaration(path) {
61+
const template = getTemplate(path.node.declaration);
6862

6963
if (template === undefined) {
70-
this.traverse(node);
64+
this.traverse(path);
7165

7266
return false;
7367
}
7468

75-
markers.push(getMarker(node.value));
69+
markers.push({
70+
code: AST.print(path.node),
71+
// @ts-expect-error: Incorrect type
72+
end: path.node.loc!.end,
73+
});
7674

7775
return false;
7876
},
7977

80-
visitStaticBlock(node) {
81-
const bodyNode = node.value.body[0];
78+
visitStaticBlock(path) {
79+
const bodyNode = path.node.body[0]!;
8280

8381
if (bodyNode.type !== 'ExpressionStatement') {
8482
return false;
@@ -90,7 +88,11 @@ export function findMarkers(file: string): Marker[] {
9088
return false;
9189
}
9290

93-
markers.push(getMarker(node.value));
91+
markers.push({
92+
code: AST.print(path.node),
93+
// @ts-expect-error: Incorrect type
94+
end: path.node.loc!.end,
95+
});
9496

9597
return false;
9698
},

packages/ast/template-tag/src/-private/to-template-tag.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
21
import { AST } from '@codemod-utils/ast-javascript';
32

43
import { getTemplate, MARKER } from './content-tag.js';
@@ -11,34 +10,34 @@ export function removeMarkers(file: string): string {
1110
const traverse = AST.traverse(true);
1211

1312
const ast = traverse(file, {
14-
visitCallExpression(node) {
15-
const template = getTemplate(node.value);
13+
visitCallExpression(path) {
14+
const template = getTemplate(path.node);
1615

1716
if (template === undefined) {
18-
this.traverse(node);
17+
this.traverse(path);
1918

2019
return false;
2120
}
2221

2322
return `<template>${template}</template>`;
2423
},
2524

26-
visitExportDefaultDeclaration(node) {
27-
const template = getTemplate(node.value.declaration);
25+
visitExportDefaultDeclaration(path) {
26+
const template = getTemplate(path.node.declaration);
2827

2928
if (template === undefined) {
30-
this.traverse(node);
29+
this.traverse(path);
3130

3231
return false;
3332
}
3433

3534
return `<template>${template}</template>`;
3635
},
3736

38-
visitImportDeclaration(node) {
37+
visitImportDeclaration(path) {
3938
if (
40-
node.value.source.type !== 'StringLiteral' ||
41-
node.value.source.value !== '@ember/template-compiler'
39+
path.node.source.type !== 'StringLiteral' ||
40+
path.node.source.value !== '@ember/template-compiler'
4241
) {
4342
return false;
4443
}
@@ -47,8 +46,8 @@ export function removeMarkers(file: string): string {
4746
return null;
4847
},
4948

50-
visitStaticBlock(node) {
51-
const bodyNode = node.value.body[0];
49+
visitStaticBlock(path) {
50+
const bodyNode = path.node.body[0]!;
5251

5352
if (bodyNode.type !== 'ExpressionStatement') {
5453
return false;

0 commit comments

Comments
 (0)