File tree 1 file changed +9
-5
lines changed
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -118,12 +118,16 @@ export function parseForESLint(code: string, options?: any): ParseResult {
118
118
119
119
if (
120
120
parserOptions . filePath &&
121
- ( parserOptions . filePath . endsWith ( ".svelte.js" ) ||
122
- parserOptions . filePath . endsWith ( ".svelte.ts" ) )
121
+ ! parserOptions . filePath . endsWith ( ".svelte" ) &&
122
+ // If no `filePath` is set in ESLint, "<input>" will be specified.
123
+ parserOptions . filePath !== "<input>"
123
124
) {
124
- const svelteParseContext =
125
- resolveSvelteParseContextForSvelteScript ( svelteConfig ) ;
126
- return parseAsScript ( code , parserOptions , svelteParseContext ) ;
125
+ const trimmed = code . trim ( ) ;
126
+ if ( ! trimmed . startsWith ( "<" ) && ! trimmed . endsWith ( ">" ) ) {
127
+ const svelteParseContext =
128
+ resolveSvelteParseContextForSvelteScript ( svelteConfig ) ;
129
+ return parseAsScript ( code , parserOptions , svelteParseContext ) ;
130
+ }
127
131
}
128
132
129
133
return parseAsSvelte ( code , svelteConfig , parserOptions ) ;
You can’t perform that action at this time.
0 commit comments