You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/rules/order.md
+22-24
Original file line number
Diff line number
Diff line change
@@ -77,6 +77,25 @@ import foo from './foo'
77
77
var path =require('path')
78
78
```
79
79
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
+
importbfrom'b'
86
+
import'format.css'// This will prevent --fix from working.
87
+
importafrom'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
+
importbfrom'b'
95
+
importafrom'a'
96
+
import'format2.css'// OK
97
+
```
98
+
80
99
## Options
81
100
82
101
This rule supports the following options:
@@ -180,7 +199,8 @@ Example:
180
199
### `pathGroupsExcludedImportTypes: [array]`
181
200
182
201
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.
184
204
185
205
Example:
186
206
@@ -202,29 +222,7 @@ Example:
202
222
}
203
223
```
204
224
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).
0 commit comments