diff --git a/README.md b/README.md
index 0904675..07ae6b1 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
-## eslint-plugin-import-sorting
+# eslint-plugin-import-sorting
-Enforce a convention in the order of `import` statements, inspired by [isort](https://timothycrosley.github.io/isort/#how-does-isort-work)’s grouping style:
+Enforce a convention in the order of `import` statements, inspired by
+[isort](https://timothycrosley.github.io/isort/#how-does-isort-work)’s grouping style:
1. Node standard modules
2. Framework modules
@@ -8,17 +9,21 @@ Enforce a convention in the order of `import` statements, inspired by [isort](ht
4. Internal modules
5. Explicitly local modules
-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.
+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.
## Usage
-Install the plugin, and ESLint if is not already.
+Install the plugin, and ESLint if it is not already.
```sh
npm install --save-dev eslint eslint-plugin-import-sorting
```
-Include the plugin in the `plugins` key of your ESLint config and enable the rule.
+Include the plugin in the `plugins` key of your ESLint config and enable the
+rules.
```js
// eslint.config.js
@@ -31,26 +36,19 @@ export default [
'import-sorting': importSortingPlugin,
},
rules: {
- 'import-sorting/order': 'warn',
+ 'import-sorting/order': 'error',
},
},
]
```
-
- Legacy config example
+
-```js
-// .eslintrc.js
-
-module.exports = {
- plugins: ['import-sorting'],
- rules: {
- 'import-sorting/order': 'warn',
- },
-}
-```
+🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).
-
+| Name | Description | 🔧 |
+| :----------------------------------------------- | :------------------------------------------ | :- |
+| [order](docs/rules/order.md) | Consistently order `import` statements. | 🔧 |
+| [specifier-order](docs/rules/specifier-order.md) | Consistently order named import specifiers. | 🔧 |
-See the [order](https://github.com/stormwarning/eslint-plugin-import-sorting/blob/main/docs/rules/order.md) rule docs for more configuration options.
+
diff --git a/docs/rules/order.md b/docs/rules/order.md
index 2d8d305..dd6a16a 100644
--- a/docs/rules/order.md
+++ b/docs/rules/order.md
@@ -1,8 +1,8 @@
-# import-sorting/order
+# Consistently order `import` statements (`import-sorting/order`)
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
-Enforce a convention in the order of `import` statements.
+
The grouping order is as follows:
@@ -24,13 +24,17 @@ constitutes an “internal” module.
For example:
```js
-settings: {
- // Group official React packages together.
- 'import-sorting/framework-patterns': /^react(\/|-dom|-router|$)/.source,
- // Group aliased imports together.
- 'import-sorting/internal-patterns': /^~/.source,
-},
-rules: {
- 'import-sorting/order': 'error',
-},
+export default [
+ {
+ settings: {
+ // Group official React packages together.
+ 'import-sorting/framework-patterns': /^react(\/|-dom|-router|$)/.source,
+ // Group aliased imports together.
+ 'import-sorting/internal-patterns': /^~/.source,
+ },
+ rules: {
+ 'import-sorting/order': 'error',
+ },
+ },
+]
```
diff --git a/docs/rules/specifier-order.md b/docs/rules/specifier-order.md
new file mode 100644
index 0000000..5b5c98d
--- /dev/null
+++ b/docs/rules/specifier-order.md
@@ -0,0 +1,18 @@
+# Consistently order named import specifiers (`import-sorting/specifier-order`)
+
+🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
+
+
+
+Specifiers are sorted naturally, the same as imports within groups. `type`
+keywords are ignored during sorting.
+
+```js
+export default [
+ {
+ rules: {
+ 'import-sorting/specifier-order': 'error',
+ },
+ },
+]
+```
diff --git a/src/index.ts b/src/index.ts
index 318a5c0..e3371b4 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,9 +1,11 @@
import order from './rules/order.js'
+import specifierOrder from './rules/specifier-order.js'
const plugin = {
- name: 'sorting-order',
+ name: 'import-sorting',
rules: {
order,
+ 'specifier-order': specifierOrder,
},
}
diff --git a/src/rules/order.ts b/src/rules/order.ts
index d5eec7a..305deb9 100644
--- a/src/rules/order.ts
+++ b/src/rules/order.ts
@@ -38,7 +38,7 @@ export default createRule({
type: 'suggestion',
fixable: 'code',
docs: {
- description: 'Enforce a convention in the order of `import` statements.',
+ description: 'Consistently order `import` statements.',
},
messages: {
'needs-newline':