File tree 3 files changed +19
-21
lines changed
3 files changed +19
-21
lines changed Original file line number Diff line number Diff line change @@ -11,17 +11,17 @@ This rule warns whenever a single file contains multiple named exports or assign
11
11
### Valid
12
12
13
13
``` js
14
- // Default export is adjacent to named export -> ok
14
+ // Default export statement is adjacent to named export -> ok
15
15
export default function test () {}
16
- // A single named export -> ok
16
+ // A single named export statement -> ok
17
17
export const valid = true
18
18
```
19
19
20
20
``` js
21
21
const first = true
22
22
const second = true
23
23
24
- // A single named export -> ok
24
+ // A single named export statement -> ok
25
25
export {
26
26
first ,
27
27
second ,
@@ -39,13 +39,13 @@ module.exports = {
39
39
### Invalid
40
40
41
41
``` js
42
- // Multiple named exports -> not ok!
42
+ // Multiple named export statements -> not ok!
43
43
export const first = true
44
44
export const second = true
45
45
```
46
46
47
47
``` js
48
- // Default export is not adjacent to the named export -> not ok!
48
+ // Default export is not adjacent to the named export statement -> not ok!
49
49
export default {}
50
50
const first = true
51
51
export { first }
Original file line number Diff line number Diff line change 1
1
const meta = { }
2
+ /* eslint-disable max-len */
2
3
const errors = {
3
- ExportNamedDeclaration :
4
- 'Multiple named export declarations; consolidate all named exports into a single statement' ,
5
- ExportDefaultDeclaration :
6
- 'Default export declaration should be adjacent to named export' ,
7
- MemberExpression :
8
- 'Multiple CommonJS exports; consolidate all exports into a single assignment to ' +
9
- '`module.exports`' ,
4
+ ExportNamedDeclaration : 'Multiple named export declarations; consolidate all named exports into a single statement' ,
5
+ ExportDefaultDeclaration : 'Default export declaration should be adjacent to named export' ,
6
+ MemberExpression : 'Multiple CommonJS exports; consolidate all exports into a single assignment to `module.exports`' ,
10
7
}
8
+ /* eslint-enable max-len */
11
9
12
10
/**
13
11
* Check if two nodes are adjacent (only whitespace between them)
@@ -85,7 +83,8 @@ function create(context) {
85
83
return
86
84
}
87
85
88
- return void exports . named . add ( node )
86
+ exports . named . add ( node )
87
+ return
89
88
}
90
89
91
90
if ( node . object . name === 'exports' ) {
@@ -94,7 +93,8 @@ function create(context) {
94
93
return
95
94
}
96
95
97
- return void exports . named . add ( node )
96
+ exports . named . add ( node )
97
+ return
98
98
}
99
99
} ,
100
100
Original file line number Diff line number Diff line change @@ -2,15 +2,13 @@ import { test } from '../utils'
2
2
import { RuleTester } from 'eslint'
3
3
import rule from 'rules/group-exports'
4
4
5
+ /* eslint-disable max-len */
5
6
const errors = {
6
- named :
7
- 'Multiple named export declarations; consolidate all named exports into a single statement' ,
8
- default :
9
- 'Default export declaration should be adjacent to named export' ,
10
- commonjs :
11
- 'Multiple CommonJS exports; consolidate all exports into a single assignment to ' +
12
- '`module.exports`' ,
7
+ named : 'Multiple named export declarations; consolidate all named exports into a single statement' ,
8
+ default : 'Default export declaration should be adjacent to named export' ,
9
+ commonjs : 'Multiple CommonJS exports; consolidate all exports into a single assignment to `module.exports`' ,
13
10
}
11
+ /* eslint-enable max-len */
14
12
const ruleTester = new RuleTester ( )
15
13
16
14
ruleTester . run ( 'group-exports' , rule , {
You can’t perform that action at this time.
0 commit comments