Skip to content

Commit 5eccaa8

Browse files
authored
Change AST (#7)
* Change AST * update
1 parent b948a8b commit 5eccaa8

File tree

70 files changed

+18870
-19680
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+18870
-19680
lines changed

src/context/script.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { ESLintExtendedProgram } from "../parser"
33
import { traverseNodes } from "../traverse"
44
import type { TSESTree } from "@typescript-eslint/types"
55
import { ParseError } from "../errors"
6-
import type { AstroRootFragment } from "../ast"
6+
import type { AstroProgram, AstroRootFragment } from "../ast"
77

88
export class ScriptContext {
99
private readonly ctx: Context
@@ -79,6 +79,14 @@ export class ScriptContext {
7979
)
8080
}
8181

82+
// Process for Astro
83+
const rootFragment = ((result.ast as AstroProgram).body[
84+
result.ast.body.length - 1
85+
] = last.expression as unknown as AstroRootFragment)
86+
delete (rootFragment as any).closingFragment
87+
delete (rootFragment as any).openingFragment
88+
rootFragment.type = "AstroRootFragment"
89+
8290
// remap locations
8391

8492
const traversed = new Set<TSESTree.Node>()
@@ -112,12 +120,6 @@ export class ScriptContext {
112120
this.remapLocation(token)
113121
}
114122

115-
// Process for Astro
116-
delete (last.expression as any).closingFragment
117-
delete (last.expression as any).openingFragment
118-
;(last.expression as unknown as AstroRootFragment).type =
119-
"AstroRootFragment"
120-
121123
let restoreNodeProcesses = this.restoreNodeProcesses
122124
for (const node of traversed) {
123125
restoreNodeProcesses = restoreNodeProcesses.filter(

0 commit comments

Comments
 (0)