Skip to content

Commit 9b877d8

Browse files
authored
Add a quick note on how unbound imports and --fix
Having unbound imports mixed among the bound ones causes unexpected and incorrect seeming results. I spent several hours trying to fix this problem only to find it was well known!
1 parent 6304ddc commit 9b877d8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/rules/order.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,25 @@ import foo from './foo';
8080
var path = require('path');
8181
```
8282

83+
## Limitations of `--fix`
84+
85+
Unbound imports are assumed to have side effects, and will never be moved/reordered. This can cause other imports to get "stuck" around them, and the fix to fail.
86+
87+
```javascript
88+
import b from 'b'
89+
import 'format.css'; // This will prevent --fix from working.
90+
import a from 'a'
91+
```
92+
93+
As a workaround, move unbound imports to be entirely above and below bound ones.
94+
95+
```javascript
96+
import 'format1.css'; // OK
97+
import b from 'b'
98+
import a from 'a'
99+
import 'format2.css'; // OK
100+
```
101+
83102
## Options
84103

85104
This rule supports the following options:

0 commit comments

Comments
 (0)