@@ -14,29 +14,38 @@ module.exports = {
14
14
create : function ( context ) {
15
15
function checkSpecifiers ( key , type , node ) {
16
16
// ignore local exports and type imports/exports
17
- if ( node . source == null || node . importKind === 'type' ||
18
- node . importKind === 'typeof' || node . exportKind === 'type' ) {
17
+ if (
18
+ node . source == null
19
+ || node . importKind === 'type'
20
+ || node . importKind === 'typeof'
21
+ || node . exportKind === 'type'
22
+ ) {
19
23
return ;
20
24
}
21
25
22
- if ( ! node . specifiers
23
- . some ( function ( im ) { return im . type === type ; } ) ) {
26
+ if ( ! node . specifiers . some ( ( im ) => im . type === type ) ) {
24
27
return ; // no named imports/exports
25
28
}
26
29
27
30
const imports = Exports . get ( node . source . value , context ) ;
28
- if ( imports == null ) return ;
31
+ if ( imports == null ) {
32
+ return ;
33
+ }
29
34
30
35
if ( imports . errors . length ) {
31
36
imports . reportErrors ( context , node ) ;
32
37
return ;
33
38
}
34
39
35
40
node . specifiers . forEach ( function ( im ) {
36
- if ( im . type !== type ) return ;
41
+ if ( im . type !== type ) {
42
+ return ;
43
+ }
37
44
38
45
// ignore type imports
39
- if ( im . importKind === 'type' || im . importKind === 'typeof' ) return ;
46
+ if ( im . importKind === 'type' || im . importKind === 'typeof' ) {
47
+ return ;
48
+ }
40
49
41
50
const deepLookup = imports . hasDeep ( im [ key ] . name ) ;
42
51
@@ -46,27 +55,18 @@ module.exports = {
46
55
. map ( i => path . relative ( path . dirname ( context . getPhysicalFilename ? context . getPhysicalFilename ( ) : context . getFilename ( ) ) , i . path ) )
47
56
. join ( ' -> ' ) ;
48
57
49
- context . report ( im [ key ] ,
50
- `${ im [ key ] . name } not found via ${ deepPath } ` ) ;
58
+ context . report ( im [ key ] , `${ im [ key ] . name } not found via ${ deepPath } ` ) ;
51
59
} else {
52
- context . report ( im [ key ] ,
53
- im [ key ] . name + ' not found in \'' + node . source . value + '\'' ) ;
60
+ context . report ( im [ key ] , im [ key ] . name + ' not found in \'' + node . source . value + '\'' ) ;
54
61
}
55
62
}
56
63
} ) ;
57
64
}
58
65
59
66
return {
60
- 'ImportDeclaration' : checkSpecifiers . bind ( null
61
- , 'imported'
62
- , 'ImportSpecifier'
63
- ) ,
67
+ ImportDeclaration : checkSpecifiers . bind ( null , 'imported' , 'ImportSpecifier' ) ,
64
68
65
- 'ExportNamedDeclaration' : checkSpecifiers . bind ( null
66
- , 'local'
67
- , 'ExportSpecifier'
68
- ) ,
69
+ ExportNamedDeclaration : checkSpecifiers . bind ( null , 'local' , 'ExportSpecifier' ) ,
69
70
} ;
70
-
71
71
} ,
72
72
} ;
0 commit comments