Skip to content

Commit 18505fb

Browse files
committed
Update docs
1 parent 99bf63f commit 18505fb

File tree

2 files changed

+49
-4
lines changed

2 files changed

+49
-4
lines changed

README.md

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,53 @@ Enforce a convention in the order of `import` statements, inspired by [isort](ht
44

55
1. Node standard modules
66
2. Framework modules
7-
3. Third-party modules
8-
4. First-party modules
7+
3. External modules
8+
4. Internal modules
99
5. Explicitly local modules
1010

1111
This plugin includes an additional group for “style” imports where the import source ends in `.css` or other style format. Imports are sorted alphabetically, except for local modules, which are sorted by the number of `.` segements in the path first, then alphabetically.
1212

1313
## Usage
1414

15+
Install the plugin, and ESLint if is not already.
16+
17+
```sh
18+
npm install --save-dev eslint eslint-plugin-import-sorting
19+
```
20+
21+
Include the plugin in the `plugins` key of your ESLint config and enable the rule.
22+
23+
```js
24+
// eslint.config.js
25+
26+
import importSortingPlugin from 'eslint-plugin-import-sorting'
27+
28+
export default [
29+
{
30+
plugins: {
31+
'import-sorting': importSortingPlugin,
32+
},
33+
rules: {
34+
'import-sorting/order': 'warn',
35+
},
36+
},
37+
]
38+
```
39+
40+
<details>
41+
<summary>Legacy config example</summary>
42+
1543
```js
16-
rules: {
17-
'import-sorting/order': 'error',
44+
// .eslintrc.js
45+
46+
module.exports = {
47+
plugins: ['import-sorting'],
48+
rules: {
49+
'import-sorting/order': 'warn',
50+
},
1851
}
1952
```
2053

54+
</details>
55+
2156
See the [order](https://github.com/stormwarning/eslint-plugin-import-sorting/blob/main/docs/rules/order.md) rule docs for more configuration options.

docs/rules/order.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44

55
Enforce a convention in the order of `import` statements.
66

7+
The grouping order is as follows:
8+
9+
1. Unassigned imports (only grouped, existing order is preserved)
10+
2. Node/Bun standard modules (protocol is ignored when sorting)
11+
3. Framework modules (see below)
12+
4. External modules
13+
5. Internal modules (see below)
14+
6. Explicitly local modules (paths starting with a dot segment)
15+
7. Style imports
16+
717
## Settings
818

919
The framework and internal groups can be configured by passing a RegEx

0 commit comments

Comments
 (0)