File tree 4 files changed +23
-8
lines changed
4 files changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,12 @@ module.exports = function (context) {
19
19
return ;
20
20
}
21
21
22
- if ( ! getExports ( path ) . hasDefault ) {
22
+ var imports = getExports ( path ) ;
23
+ if ( imports . named . size === 0 && context . options [ 0 ] !== "es6-only" ) {
24
+ return ; // ignore for commonjs compatibility
25
+ }
26
+
27
+ if ( ! imports . hasDefault ) {
23
28
context . report ( defaultSpecifier , "No default export found in module." ) ;
24
29
}
25
30
}
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ module.exports = function (context) {
18
18
19
19
// if there are no exports, may be a commonjs module.
20
20
// TODO: "interop" mode that attempts to read module.exports, exports member assignments?
21
- if ( names . size === 0 && ! imports . hasDefault && context . options [ 0 ] !== "es6" ) {
21
+ if ( names . size === 0 && ! imports . hasDefault && context . options [ 0 ] !== "es6-only " ) {
22
22
return ;
23
23
}
24
24
Original file line number Diff line number Diff line change @@ -21,30 +21,40 @@ eslintTester.addRuleTest("lib/rules/default", {
21
21
code : "import foo from './default-export';" ,
22
22
filename : FILENAME
23
23
} , ecmaFeatures ) ,
24
+
24
25
assign ( {
25
26
code : "import bar from './default-export';" ,
26
27
filename : FILENAME
27
28
} , ecmaFeatures ) ,
29
+
28
30
assign ( {
29
31
code : "import CoolClass from './default-class';" ,
30
32
filename : FILENAME
31
33
} , ecmaFeatures ) ,
34
+
32
35
assign ( {
33
36
code : "import bar, { baz } from './default-export';" ,
34
37
filename : FILENAME
38
+ } , ecmaFeatures ) ,
39
+
40
+ assign ( {
41
+ code : "import bar from './common';" ,
42
+ filename : FILENAME
35
43
} , ecmaFeatures )
36
44
] ,
37
45
38
46
invalid : [
39
- // assign({
40
- // code: "import foo from './bar';",
41
- // filename: filename("foo.js"),
42
- // errors: ERRORS
43
- // }, ecmaFeatures),
44
47
assign ( {
45
48
code : "import baz from './named-exports';" ,
46
49
filename : FILENAME ,
47
50
errors : ERRORS
51
+ } , ecmaFeatures ) ,
52
+
53
+ assign ( {
54
+ code : "import bar from './common';" ,
55
+ args : [ 2 , "es6-only" ] ,
56
+ filename : FILENAME ,
57
+ errors : ERRORS
48
58
} , ecmaFeatures )
49
59
]
50
60
} ) ;
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ eslintTester.addRuleTest("lib/rules/named", {
77
77
78
78
assign ( {
79
79
code : "import { a } from './common';" ,
80
- args : [ 2 , "es6" ] ,
80
+ args : [ 2 , "es6-only " ] ,
81
81
filename : FILENAME ,
82
82
errors : ERRORS
83
83
} , ecmaFeatures ) ,
You can’t perform that action at this time.
0 commit comments