Skip to content

Commit 8b73b1f

Browse files
fix: node.loc or node.value.loc in pushManualList (#104)
1 parent d3a27d5 commit 8b73b1f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/report.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,17 @@ export function pushManualList(
1414
} else {
1515
index = 0
1616
}
17-
index = node?.value.loc?.start.line + index
18-
let position: string = '[' + index + ',' + node?.value.loc?.start.column + ']'
17+
let line
18+
let column
19+
if (node?.loc) {
20+
line = node?.loc?.start.line
21+
column = node?.loc?.start.column
22+
} else {
23+
line = node?.value?.loc?.start.line
24+
column = node?.value?.loc?.start.column
25+
}
26+
index = line + index
27+
let position: string = '[' + index + ',' + column + ']'
1928

2029
const list = {
2130
path: path,

vue-transformations/manual/manual-remove-keycode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ function findNodes(context: any) {
2626
enterNode(node: Node) {
2727
if (
2828
node.type === 'VDirectiveKey' &&
29-
node.name.name === 'on' &&
29+
node?.name?.name === 'on' &&
3030
// @ts-ignore
31-
key.test(node?.argument!.name) &&
31+
key.test(node?.argument?.name) &&
3232
number.test(node?.modifiers[0]?.name)
3333
) {
3434
toFixNodes.push(node)

0 commit comments

Comments
 (0)