@@ -8,8 +8,8 @@ function constant(value) {
8
8
return ( ) => value
9
9
}
10
10
11
- function baseModule ( name ) {
12
- if ( isScoped ( name ) ) {
11
+ function baseModule ( name , path ) {
12
+ if ( isScoped ( name , path ) ) {
13
13
const [ scope , pkg ] = name . split ( '/' )
14
14
return `${ scope } /${ pkg } `
15
15
}
@@ -21,8 +21,8 @@ export function isAbsolute(name) {
21
21
return name . indexOf ( '/' ) === 0
22
22
}
23
23
24
- export function isBuiltIn ( name , settings ) {
25
- const base = baseModule ( name )
24
+ export function isBuiltIn ( name , settings , path ) {
25
+ const base = baseModule ( name , path )
26
26
const extras = ( settings && settings [ 'import/core-modules' ] ) || [ ]
27
27
return coreModules [ base ] || extras . indexOf ( base ) > - 1
28
28
}
@@ -39,21 +39,22 @@ function isExternalModule(name, settings, path) {
39
39
40
40
const externalModuleMainRegExp = / ^ [ \w ] ( (? ! \/ ) .) * $ /
41
41
export function isExternalModuleMain ( name , settings , path ) {
42
- return externalModuleMainRegExp . test ( name ) && isExternalPath ( path , name , settings )
42
+ return ( externalModuleMainRegExp . test ( name ) && isExternalPath ( path , name , settings ) )
43
43
}
44
44
45
45
const scopedRegExp = / ^ @ [ ^ / ] + \/ [ ^ / ] + /
46
- function isScoped ( name ) {
47
- return scopedRegExp . test ( name )
46
+ function isScoped ( name , settings , path ) {
47
+ return scopedRegExp . test ( name ) && isExternalPath ( path , name , settings )
48
48
}
49
49
50
50
const scopedMainRegExp = / ^ @ [ ^ / ] + \/ ? [ ^ / ] + $ /
51
- export function isScopedMain ( name ) {
52
- return scopedMainRegExp . test ( name )
51
+ export function isScopedMain ( name , settings , path ) {
52
+ return scopedMainRegExp . test ( name ) && isExternalPath ( path , settings , name )
53
53
}
54
54
55
55
function isInternalModule ( name , settings , path ) {
56
- return externalModuleRegExp . test ( name ) && ! isExternalPath ( path , name , settings )
56
+ const matchesScopedOrExternal = scopedRegExp . test ( name ) || externalModuleRegExp . test ( name )
57
+ return ( matchesScopedOrExternal && ! isExternalPath ( path , name , settings ) )
57
58
}
58
59
59
60
function isRelativeToParent ( name ) {
0 commit comments