File tree 1 file changed +10
-5
lines changed
1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -115,15 +115,20 @@ type ParseResult = {
115
115
export function parseForESLint ( code : string , options ?: any ) : ParseResult {
116
116
const svelteConfig = resolveSvelteConfigFromOption ( options ) ;
117
117
const parserOptions = normalizeParserOptions ( options ) ;
118
+ const svelteParseContext =
119
+ resolveSvelteParseContextForSvelteScript ( svelteConfig ) ;
118
120
119
121
if (
122
+ svelteParseContext . runes &&
120
123
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>"
123
127
) {
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
+ }
127
132
}
128
133
129
134
return parseAsSvelte ( code , svelteConfig , parserOptions ) ;
You can’t perform that action at this time.
0 commit comments