@@ -7,34 +7,27 @@ const fs = require('fs');
77
88const  log  =  require ( 'debug' ) ( 'eslint-plugin-import:parse' ) ; 
99
10- function  getBabelVisitorKeys ( parserPath )  { 
10+ function  getBabelEslintVisitorKeys ( parserPath )  { 
1111  if  ( parserPath . endsWith ( 'index.js' ) )  { 
1212    const  hypotheticalLocation  =  parserPath . replace ( 'index.js' ,  'visitor-keys.js' ) ; 
1313    if  ( fs . existsSync ( hypotheticalLocation ) )  { 
1414      const  keys  =  moduleRequire ( hypotheticalLocation ) ; 
1515      return  keys . default  ||  keys ; 
1616    } 
17-   }  else  if  ( parserPath . endsWith ( 'index.cjs' ) )  { 
18-     const  hypotheticalLocation  =  parserPath . replace ( 'index.cjs' ,  'worker/ast-info.cjs' ) ; 
19-     if  ( fs . existsSync ( hypotheticalLocation ) )  { 
20-       const  astInfo  =  moduleRequire ( hypotheticalLocation ) ; 
21-       return  astInfo . getVisitorKeys ( ) ; 
22-     } 
2317  } 
2418  return  null ; 
2519} 
2620
2721function  keysFromParser ( parserPath ,  parserInstance ,  parsedResult )  { 
22+   // Exposed by @typescript -eslint/parser and @babel/eslint-parser 
23+   if  ( parsedResult  &&  parsedResult . visitorKeys )  { 
24+     return  parsedResult . visitorKeys ; 
25+   } 
2826  if  ( / .* e s p r e e .* / . test ( parserPath ) )  { 
2927    return  parserInstance . VisitorKeys ; 
3028  } 
31-   if  ( / .* ( b a b e l - e s l i n t | @ b a b e l \/ e s l i n t - p a r s e r ) .* / . test ( parserPath ) )  { 
32-     return  getBabelVisitorKeys ( parserPath ) ; 
33-   } 
34-   if  ( / .* @ t y p e s c r i p t - e s l i n t \/ p a r s e r / . test ( parserPath ) )  { 
35-     if  ( parsedResult )  { 
36-       return  parsedResult . visitorKeys ; 
37-     } 
29+   if  ( / .* b a b e l - e s l i n t .* / . test ( parserPath ) )  { 
30+     return  getBabelEslintVisitorKeys ( parserPath ) ; 
3831  } 
3932  return  null ; 
4033} 
0 commit comments