@@ -8,26 +8,6 @@ const log = require('debug')('eslint-plugin-import:resolver:node');
8
8
9
9
exports . interfaceVersion = 2 ;
10
10
11
- exports . resolve = function ( source , file , config ) {
12
- log ( 'Resolving:' , source , 'from:' , file ) ;
13
- let resolvedPath ;
14
-
15
- if ( isCoreModule ( source ) ) {
16
- log ( 'resolved to core' ) ;
17
- return { found : true , path : null } ;
18
- }
19
-
20
- try {
21
- const cachedFilter = function ( pkg , dir ) { return packageFilter ( pkg , dir , config ) ; } ;
22
- resolvedPath = resolve ( source , opts ( file , config , cachedFilter ) ) ;
23
- log ( 'Resolved to:' , resolvedPath ) ;
24
- return { found : true , path : resolvedPath } ;
25
- } catch ( err ) {
26
- log ( 'resolve threw error:' , err ) ;
27
- return { found : false } ;
28
- }
29
- } ;
30
-
31
11
function opts ( file , config , packageFilter ) {
32
12
return Object . assign ( { // more closely matches Node (#333)
33
13
// plus 'mjs' for native modules! (#939)
@@ -64,3 +44,23 @@ function packageFilter(pkg, dir, config) {
64
44
}
65
45
return pkg ;
66
46
}
47
+
48
+ exports . resolve = function ( source , file , config ) {
49
+ log ( 'Resolving:' , source , 'from:' , file ) ;
50
+ let resolvedPath ;
51
+
52
+ if ( isCoreModule ( source ) ) {
53
+ log ( 'resolved to core' ) ;
54
+ return { found : true , path : null } ;
55
+ }
56
+
57
+ try {
58
+ const cachedFilter = function ( pkg , dir ) { return packageFilter ( pkg , dir , config ) ; } ;
59
+ resolvedPath = resolve ( source , opts ( file , config , cachedFilter ) ) ;
60
+ log ( 'Resolved to:' , resolvedPath ) ;
61
+ return { found : true , path : resolvedPath } ;
62
+ } catch ( err ) {
63
+ log ( 'resolve threw error:' , err ) ;
64
+ return { found : false } ;
65
+ }
66
+ } ;
0 commit comments