Skip to content

Commit f3e505b

Browse files
mi-na-botljharb
authored andcommitted
[Docs] order: 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 7a28ba2 commit f3e505b

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
1414
- [`no-unused-modules`]: add console message to help debug [#2866]
1515
- [Refactor] `ExportMap`: make procedures static instead of monkeypatching exportmap ([#2982], thanks [@soryy708])
1616
- [Refactor] `ExportMap`: separate ExportMap instance from its builder logic ([#2985], thanks [@soryy708])
17+
- [Docs] `order`: Add a quick note on how unbound imports and --fix ([#2640], thanks [@minervabot])
1718

1819
## [2.29.1] - 2023-12-14
1920

@@ -1130,6 +1131,7 @@ for info on changes for earlier releases.
11301131
[#2735]: https://github.com/import-js/eslint-plugin-import/pull/2735
11311132
[#2699]: https://github.com/import-js/eslint-plugin-import/pull/2699
11321133
[#2664]: https://github.com/import-js/eslint-plugin-import/pull/2664
1134+
[#2640]: https://github.com/import-js/eslint-plugin-import/pull/2640
11331135
[#2613]: https://github.com/import-js/eslint-plugin-import/pull/2613
11341136
[#2608]: https://github.com/import-js/eslint-plugin-import/pull/2608
11351137
[#2605]: https://github.com/import-js/eslint-plugin-import/pull/2605
@@ -1846,6 +1848,7 @@ for info on changes for earlier releases.
18461848
[@mgwalker]: https://github.com/mgwalker
18471849
[@mhmadhamster]: https://github.com/MhMadHamster
18481850
[@MikeyBeLike]: https://github.com/MikeyBeLike
1851+
[@minervabot]: https://github.com/minervabot
18491852
[@mpint]: https://github.com/mpint
18501853
[@mplewis]: https://github.com/mplewis
18511854
[@mrmckeb]: https://github.com/mrmckeb

docs/rules/order.md

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

80+
## Limitations of `--fix`
81+
82+
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.
83+
84+
```javascript
85+
import b from 'b'
86+
import 'format.css'; // This will prevent --fix from working.
87+
import a from 'a'
88+
```
89+
90+
As a workaround, move unbound imports to be entirely above or below bound ones.
91+
92+
```javascript
93+
import 'format1.css'; // OK
94+
import b from 'b'
95+
import a from 'a'
96+
import 'format2.css'; // OK
97+
```
98+
8099
## Options
81100

82101
This rule supports the following options:

0 commit comments

Comments
 (0)