@@ -7,34 +7,27 @@ const fs = require('fs');
7
7
8
8
const log = require ( 'debug' ) ( 'eslint-plugin-import:parse' ) ;
9
9
10
- function getBabelVisitorKeys ( parserPath ) {
10
+ function getBabelEslintVisitorKeys ( parserPath ) {
11
11
if ( parserPath . endsWith ( 'index.js' ) ) {
12
12
const hypotheticalLocation = parserPath . replace ( 'index.js' , 'visitor-keys.js' ) ;
13
13
if ( fs . existsSync ( hypotheticalLocation ) ) {
14
14
const keys = moduleRequire ( hypotheticalLocation ) ;
15
15
return keys . default || keys ;
16
16
}
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
- }
23
17
}
24
18
return null ;
25
19
}
26
20
27
21
function keysFromParser ( parserPath , parserInstance , parsedResult ) {
22
+ // Exposed by @typescript -eslint/parser and @babel/eslint-parser
23
+ if ( parsedResult && parsedResult . visitorKeys ) {
24
+ return parsedResult . visitorKeys ;
25
+ }
28
26
if ( / .* e s p r e e .* / . test ( parserPath ) ) {
29
27
return parserInstance . VisitorKeys ;
30
28
}
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 ) ;
38
31
}
39
32
return null ;
40
33
}
0 commit comments