diff --git a/src/ast/nodes.ts b/src/ast/nodes.ts
index f8624b82..86e67990 100644
--- a/src/ast/nodes.ts
+++ b/src/ast/nodes.ts
@@ -392,6 +392,7 @@ export interface ESLintIdentifier extends HasLocation, HasParent {
interface ESLintLiteralBase extends HasLocation, HasParent {
type: "Literal"
value: string | boolean | null | number | RegExp | bigint
+ raw: string
regex?: {
pattern: string
flags: string
diff --git a/src/script-setup/index.ts b/src/script-setup/index.ts
index 59d056f1..4b5e5e30 100644
--- a/src/script-setup/index.ts
+++ b/src/script-setup/index.ts
@@ -637,7 +637,9 @@ function getScriptSetupCodeBlocks(
const exportedToken = tokens[localTokenIndex + 2]
checkToken(
exportedToken,
- (spec.exported as ESLintIdentifier).name,
+ spec.exported.type === "Identifier"
+ ? spec.exported.name
+ : spec.exported.raw,
)
restoreTokens.push(exportedToken)
processAppend(
@@ -693,12 +695,6 @@ function getScriptSetupCodeBlocks(
) {
const spec = body.specifiers[index]
const local = locals[index]
- if (
- (spec.local as ESLintIdentifier).name !==
- local.name
- ) {
- return null
- }
map.set(spec, local)
}
diff --git a/test/fixtures/ast/multiple-scripts-with-export05/ast.json b/test/fixtures/ast/multiple-scripts-with-export05/ast.json
new file mode 100644
index 00000000..6fa01d70
--- /dev/null
+++ b/test/fixtures/ast/multiple-scripts-with-export05/ast.json
@@ -0,0 +1,1070 @@
+{
+ "type": "Program",
+ "start": 8,
+ "end": 151,
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 0
+ },
+ "end": {
+ "line": 8,
+ "column": 23
+ }
+ },
+ "range": [
+ 9,
+ 150
+ ],
+ "body": [
+ {
+ "type": "ExportNamedDeclaration",
+ "start": 9,
+ "end": 30,
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 0
+ },
+ "end": {
+ "line": 2,
+ "column": 21
+ }
+ },
+ "range": [
+ 9,
+ 30
+ ],
+ "declaration": {
+ "type": "VariableDeclaration",
+ "start": 16,
+ "end": 30,
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 7
+ },
+ "end": {
+ "line": 2,
+ "column": 21
+ }
+ },
+ "range": [
+ 16,
+ 30
+ ],
+ "declarations": [
+ {
+ "type": "VariableDeclarator",
+ "start": 20,
+ "end": 30,
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 11
+ },
+ "end": {
+ "line": 2,
+ "column": 21
+ }
+ },
+ "range": [
+ 20,
+ 30
+ ],
+ "id": {
+ "type": "Identifier",
+ "start": 20,
+ "end": 25,
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 11
+ },
+ "end": {
+ "line": 2,
+ "column": 16
+ }
+ },
+ "range": [
+ 20,
+ 25
+ ],
+ "name": "count"
+ },
+ "init": {
+ "type": "Literal",
+ "start": 28,
+ "end": 30,
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 19
+ },
+ "end": {
+ "line": 2,
+ "column": 21
+ }
+ },
+ "range": [
+ 28,
+ 30
+ ],
+ "value": 42,
+ "raw": "42"
+ }
+ }
+ ],
+ "kind": "let"
+ },
+ "specifiers": [],
+ "source": null
+ },
+ {
+ "type": "ExportNamedDeclaration",
+ "start": 31,
+ "end": 58,
+ "loc": {
+ "start": {
+ "line": 3,
+ "column": 0
+ },
+ "end": {
+ "line": 3,
+ "column": 27
+ }
+ },
+ "range": [
+ 31,
+ 58
+ ],
+ "declaration": null,
+ "specifiers": [
+ {
+ "type": "ExportSpecifier",
+ "start": 39,
+ "end": 57,
+ "loc": {
+ "start": {
+ "line": 3,
+ "column": 8
+ },
+ "end": {
+ "line": 3,
+ "column": 26
+ }
+ },
+ "range": [
+ 39,
+ 57
+ ],
+ "local": {
+ "type": "Identifier",
+ "start": 39,
+ "end": 44,
+ "loc": {
+ "start": {
+ "line": 3,
+ "column": 8
+ },
+ "end": {
+ "line": 3,
+ "column": 13
+ }
+ },
+ "range": [
+ 39,
+ 44
+ ],
+ "name": "count"
+ },
+ "exported": {
+ "type": "Literal",
+ "start": 48,
+ "end": 57,
+ "loc": {
+ "start": {
+ "line": 3,
+ "column": 17
+ },
+ "end": {
+ "line": 3,
+ "column": 26
+ }
+ },
+ "range": [
+ 48,
+ 57
+ ],
+ "value": "foo-bar",
+ "raw": "\"foo-bar\""
+ }
+ }
+ ],
+ "source": null
+ },
+ {
+ "type": "VariableDeclaration",
+ "start": 84,
+ "end": 98,
+ "loc": {
+ "start": {
+ "line": 6,
+ "column": 0
+ },
+ "end": {
+ "line": 6,
+ "column": 14
+ }
+ },
+ "range": [
+ 84,
+ 98
+ ],
+ "declarations": [
+ {
+ "type": "VariableDeclarator",
+ "start": 88,
+ "end": 98,
+ "loc": {
+ "start": {
+ "line": 6,
+ "column": 4
+ },
+ "end": {
+ "line": 6,
+ "column": 14
+ }
+ },
+ "range": [
+ 88,
+ 98
+ ],
+ "id": {
+ "type": "Identifier",
+ "start": 88,
+ "end": 93,
+ "loc": {
+ "start": {
+ "line": 6,
+ "column": 4
+ },
+ "end": {
+ "line": 6,
+ "column": 9
+ }
+ },
+ "range": [
+ 88,
+ 93
+ ],
+ "name": "count"
+ },
+ "init": {
+ "type": "Literal",
+ "start": 96,
+ "end": 98,
+ "loc": {
+ "start": {
+ "line": 6,
+ "column": 12
+ },
+ "end": {
+ "line": 6,
+ "column": 14
+ }
+ },
+ "range": [
+ 96,
+ 98
+ ],
+ "value": 42,
+ "raw": "42"
+ }
+ }
+ ],
+ "kind": "let"
+ },
+ {
+ "type": "ExportNamedDeclaration",
+ "start": 99,
+ "end": 126,
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 0
+ },
+ "end": {
+ "line": 7,
+ "column": 27
+ }
+ },
+ "range": [
+ 99,
+ 126
+ ],
+ "declaration": null,
+ "specifiers": [
+ {
+ "type": "ExportSpecifier",
+ "start": 107,
+ "end": 125,
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 8
+ },
+ "end": {
+ "line": 7,
+ "column": 26
+ }
+ },
+ "range": [
+ 107,
+ 125
+ ],
+ "local": {
+ "type": "Identifier",
+ "start": 107,
+ "end": 112,
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 8
+ },
+ "end": {
+ "line": 7,
+ "column": 13
+ }
+ },
+ "range": [
+ 107,
+ 112
+ ],
+ "name": "count"
+ },
+ "exported": {
+ "type": "Literal",
+ "start": 116,
+ "end": 125,
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 17
+ },
+ "end": {
+ "line": 7,
+ "column": 26
+ }
+ },
+ "range": [
+ 116,
+ 125
+ ],
+ "value": "foo-bar",
+ "raw": "\"foo-bar\""
+ }
+ }
+ ],
+ "source": null
+ },
+ {
+ "type": "ExportNamedDeclaration",
+ "start": 127,
+ "end": 150,
+ "loc": {
+ "start": {
+ "line": 8,
+ "column": 0
+ },
+ "end": {
+ "line": 8,
+ "column": 23
+ }
+ },
+ "range": [
+ 127,
+ 150
+ ],
+ "declaration": null,
+ "specifiers": [
+ {
+ "type": "ExportSpecifier",
+ "start": 135,
+ "end": 149,
+ "loc": {
+ "start": {
+ "line": 8,
+ "column": 8
+ },
+ "end": {
+ "line": 8,
+ "column": 22
+ }
+ },
+ "range": [
+ 135,
+ 149
+ ],
+ "local": {
+ "type": "Identifier",
+ "start": 135,
+ "end": 140,
+ "loc": {
+ "start": {
+ "line": 8,
+ "column": 8
+ },
+ "end": {
+ "line": 8,
+ "column": 13
+ }
+ },
+ "range": [
+ 135,
+ 140
+ ],
+ "name": "count"
+ },
+ "exported": {
+ "type": "Identifier",
+ "start": 144,
+ "end": 149,
+ "loc": {
+ "start": {
+ "line": 8,
+ "column": 17
+ },
+ "end": {
+ "line": 8,
+ "column": 22
+ }
+ },
+ "range": [
+ 144,
+ 149
+ ],
+ "name": "count"
+ }
+ }
+ ],
+ "source": null
+ }
+ ],
+ "sourceType": "module",
+ "comments": [],
+ "tokens": [
+ {
+ "type": "Punctuator",
+ "range": [
+ 0,
+ 8
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 8
+ }
+ },
+ "value": ""
+ },
+ {
+ "type": "Punctuator",
+ "range": [
+ 69,
+ 83
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 0
+ },
+ "end": {
+ "line": 5,
+ "column": 14
+ }
+ },
+ "value": ""
+ }
+ ]
+}
\ No newline at end of file
diff --git a/test/fixtures/ast/multiple-scripts-with-export05/parser-options.json b/test/fixtures/ast/multiple-scripts-with-export05/parser-options.json
new file mode 100644
index 00000000..9f047d2c
--- /dev/null
+++ b/test/fixtures/ast/multiple-scripts-with-export05/parser-options.json
@@ -0,0 +1,4 @@
+{
+ "sourceType": "module",
+ "ecmaVersion": 2022
+}
diff --git a/test/fixtures/ast/multiple-scripts-with-export05/requirements.json b/test/fixtures/ast/multiple-scripts-with-export05/requirements.json
new file mode 100644
index 00000000..afdd18ef
--- /dev/null
+++ b/test/fixtures/ast/multiple-scripts-with-export05/requirements.json
@@ -0,0 +1,3 @@
+{
+ "eslint": ">=8.7"
+}
\ No newline at end of file
diff --git a/test/fixtures/ast/multiple-scripts-with-export05/source.vue b/test/fixtures/ast/multiple-scripts-with-export05/source.vue
new file mode 100644
index 00000000..f848b252
--- /dev/null
+++ b/test/fixtures/ast/multiple-scripts-with-export05/source.vue
@@ -0,0 +1,9 @@
+
+
diff --git a/test/fixtures/ast/multiple-scripts-with-export05/token-ranges.json b/test/fixtures/ast/multiple-scripts-with-export05/token-ranges.json
new file mode 100644
index 00000000..2a9e6963
--- /dev/null
+++ b/test/fixtures/ast/multiple-scripts-with-export05/token-ranges.json
@@ -0,0 +1,33 @@
+[
+ "",
+ ""
+]
\ No newline at end of file
diff --git a/test/fixtures/ast/multiple-scripts-with-export05/tree.json b/test/fixtures/ast/multiple-scripts-with-export05/tree.json
new file mode 100644
index 00000000..0637a088
--- /dev/null
+++ b/test/fixtures/ast/multiple-scripts-with-export05/tree.json
@@ -0,0 +1 @@
+[]
\ No newline at end of file