@@ -20,6 +20,11 @@ import {
20
20
} from "../parser/parser-object" ;
21
21
import { sortedLastIndex } from "../utils" ;
22
22
23
+ const TS_PARSER_NAMES = [
24
+ "@typescript-eslint/parser" ,
25
+ "typescript-eslint-parser-for-extra-files" ,
26
+ ] ;
27
+
23
28
export class ScriptsSourceCode {
24
29
private raw : string ;
25
30
@@ -241,18 +246,18 @@ export class Context {
241
246
isTSESLintParserObject ( parserValue ) ) ;
242
247
}
243
248
const parserName = parserValue ;
244
- if ( parserName === "@typescript-eslint/parser" ) {
249
+ if ( TS_PARSER_NAMES . includes ( parserName ) ) {
245
250
return ( this . state . isTypeScript = true ) ;
246
251
}
247
- if ( parserName . includes ( "@typescript-eslint/parser" ) ) {
252
+ if ( TS_PARSER_NAMES . some ( ( nm ) => parserName . includes ( nm ) ) ) {
248
253
let targetPath = parserName ;
249
254
while ( targetPath ) {
250
255
const pkgPath = path . join ( targetPath , "package.json" ) ;
251
256
if ( fs . existsSync ( pkgPath ) ) {
252
257
try {
253
- return ( this . state . isTypeScript =
254
- JSON . parse ( fs . readFileSync ( pkgPath , "utf-8" ) ) ?. name ===
255
- "@typescript-eslint/parser" ) ;
258
+ return ( this . state . isTypeScript = TS_PARSER_NAMES . includes (
259
+ JSON . parse ( fs . readFileSync ( pkgPath , "utf-8" ) ) ?. name
260
+ ) ) ;
256
261
} catch {
257
262
return ( this . state . isTypeScript = false ) ;
258
263
}
0 commit comments