Skip to content

Commit c4a07f0

Browse files
committed
1 parent ffc695e commit c4a07f0

1 file changed

Lines changed: 22 additions & 24 deletions

File tree

docs/rules/order.md

Lines changed: 22 additions & 24 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:
@@ -180,7 +199,8 @@ Example:
180199
### `pathGroupsExcludedImportTypes: [array]`
181200

182201
This defines import types that are not handled by configured pathGroups.
183-
This is mostly needed when you want to handle path groups that look like external imports.
202+
203+
If you have added path groups with patterns that look like `"builtin"` or `"external"` imports, you have to remove this group (`"builtin"` and/or `"external"`) from the default exclusion list (e.g., `["builtin", "external", "object"]`, etc) to sort these path groups correctly.
184204

185205
Example:
186206

@@ -202,29 +222,7 @@ Example:
202222
}
203223
```
204224

205-
You can also use `patterns`(e.g., `react`, `react-router-dom`, etc).
206-
207-
Example:
208-
209-
```json
210-
{
211-
"import-x/order": [
212-
"error",
213-
{
214-
"pathGroups": [
215-
{
216-
"pattern": "react",
217-
"group": "builtin",
218-
"position": "before"
219-
}
220-
],
221-
"pathGroupsExcludedImportTypes": ["react"]
222-
}
223-
]
224-
}
225-
```
226-
227-
The default value is `["builtin", "external", "object"]`.
225+
[Import Type](https://github.com/un-ts/eslint-plugin-import-x/blob/ea7c13eb9b18357432e484b25dfa4451eca69c5b/src/utils/import-type.ts#L145) is resolved as a fixed string in predefined set, it can't be a `patterns` (e.g., `react`, `react-router-dom`, etc).
228226

229227
### `newlines-between: [ignore|always|always-and-inside-groups|never]`
230228

0 commit comments

Comments
 (0)