File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 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 {
118118
119119 if (
120120 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>"
123124 ) {
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+ }
127131 }
128132
129133 return parseAsSvelte ( code , svelteConfig , parserOptions ) ;
You can’t perform that action at this time.
0 commit comments