File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -115,15 +115,20 @@ type ParseResult = {
115115export 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 ) ;
You can’t perform that action at this time.
0 commit comments