Skip to content

Commit d730eec

Browse files
committed
try to fix
1 parent e1a4d15 commit d730eec

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/parser/index.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,20 @@ type ParseResult = {
115115
export function parseForESLint(code: string, options?: any): ParseResult {
116116
const svelteConfig = resolveSvelteConfigFromOption(options);
117117
const parserOptions = normalizeParserOptions(options);
118+
const svelteParseContext =
119+
resolveSvelteParseContextForSvelteScript(svelteConfig);
118120

119121
if (
122+
svelteParseContext.runes &&
120123
parserOptions.filePath &&
121-
(parserOptions.filePath.endsWith(".svelte.js") ||
122-
parserOptions.filePath.endsWith(".svelte.ts"))
124+
!parserOptions.filePath.endsWith(".svelte") &&
125+
// If no `filePath` is set in ESLint, "<input>" will be specified.
126+
parserOptions.filePath !== "<input>"
123127
) {
124-
const svelteParseContext =
125-
resolveSvelteParseContextForSvelteScript(svelteConfig);
126-
return parseAsScript(code, parserOptions, svelteParseContext);
128+
const trimmed = code.trim();
129+
if (!trimmed.startsWith("<") && !trimmed.endsWith(">")) {
130+
return parseAsScript(code, parserOptions, svelteParseContext);
131+
}
127132
}
128133

129134
return parseAsSvelte(code, svelteConfig, parserOptions);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy