Skip to content

Commit 160f4ef

Browse files
authored
Support arbitrary module namespace names with <script setup> (#142)
1 parent 25c6847 commit 160f4ef

File tree

8 files changed

+1124
-7
lines changed

8 files changed

+1124
-7
lines changed

Diff for: src/ast/nodes.ts

+1
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ export interface ESLintIdentifier extends HasLocation, HasParent {
392392
interface ESLintLiteralBase extends HasLocation, HasParent {
393393
type: "Literal"
394394
value: string | boolean | null | number | RegExp | bigint
395+
raw: string
395396
regex?: {
396397
pattern: string
397398
flags: string

Diff for: src/script-setup/index.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,9 @@ function getScriptSetupCodeBlocks(
637637
const exportedToken = tokens[localTokenIndex + 2]
638638
checkToken(
639639
exportedToken,
640-
(spec.exported as ESLintIdentifier).name,
640+
spec.exported.type === "Identifier"
641+
? spec.exported.name
642+
: spec.exported.raw,
641643
)
642644
restoreTokens.push(exportedToken)
643645
processAppend(
@@ -693,12 +695,6 @@ function getScriptSetupCodeBlocks(
693695
) {
694696
const spec = body.specifiers[index]
695697
const local = locals[index]
696-
if (
697-
(spec.local as ESLintIdentifier).name !==
698-
local.name
699-
) {
700-
return null
701-
}
702698
map.set(spec, local)
703699
}
704700

0 commit comments

Comments
 (0)