eslint-plugin-simple-import-sort
Advanced tools
Changelog
Version 12.1.1 (2024-07-02)
This release adds a short meta.docs.description
to each rule. Thanks to fisker Cheung (@fisker)!
Changelog
Version 12.1.0 (2024-04-13)
This release adds TypeScript type definitions for the plugin itself. This is useful when you use TypeScript to check your ESLint configuration. It assumes that you install @types/eslint
yourself. Thanks to @Logicer16!
Changelog
Version 12.0.0 (2024-02-10)
This release removes the support for import assignments added in version 11.0.0:
If you miss the support for import assignments, I suggest you write your own ESLint rule which moves them out of the way from the actual imports, sorting them or not.
Changelog
Version 11.0.0 (2024-02-08)
This release adds support for TypeScript import assignments (import A = B.C
and import A = require("module")
). Thanks to Szabolcs Kurdi (@szku01) and Svyatoslav Zaytsev (@MillerSvt)!
It’s only a breaking change if you use TypeScript import assignments, and only in the form that you need to autofix your files.
In other news, this release adds the meta
plugin property in preparation for ESLint Flat Config, and avoids the deprecated context.getSourceCode()
method (while still being backwards compatible).
Changelog
Version 10.0.0 (2023-01-27)
This release might move some imported items with type
around. This is a breaking formatting change (that only affects TypeScript and Flow), but only in the form of that you need to autofix your files.
In previous versions, type
specifiers came first:
import { type B, a } from "a";
export { type B, a } from "a";
Now, all specifiers are sorted alphabetically, regardless of type
:
import { a, type B } from "a";
export { a, type B } from "a";
Motivation:
You might import a class for a type annotation using:
<!-- prettier-ignore -->import {
type MyClass,
coolFunction,
} from "example";
Later, you also start instantiating that class in the same file (new MyClass()
), so you remove type
.
Previously, this resulted in a messy diff due to the class moving:
import {
- type MyClass,
coolFunction,
+ MyClass,
} from "example";
Now, the sorting with the type
keyword would be:
import {
coolFunction,
type MyClass,
} from "example";
Now there’s no reordering diff, just the type
keyword being removed:
import {
coolFunction,
- type MyClass,
+ MyClass,
} from "example";
This is consistent with [“Why sort on from
?”][sort-from].
Thanks to Jake Bailey (@jakebailey) for reporting and suggesting the fix!
Changelog
Version 9.0.0 (2023-01-16)
This version adds support for [eslint-plugin-svelte], and for declare module
in TypeScript.
More generally, imports and exports are now supported anywhere, by finding the set of parents of all imports and exports and working with those. Previously, the plugin only sorted imports and exports directly inside a Program
node. For eslint-plugin-svelte and declare module
that didn’t cut it.
This is only a breaking change if you imports or exports in declare module
in TypeScript, and only in the form of that you need to autofix your files.
Changelog
Version 8.0.0 (2022-09-03)
Node.js builtin modules prefixed with node:
are now in a separate group by default (regex: ^node:
), above the packages group. (Node.js builtins without node:
are still sorted together with npm packages like before.)
Before:
import fs from "fs";
import _ from "lodash-es";
import { rmSync } from "node:fs";
After:
import { rmSync } from "node:fs";
import fs from "fs";
import _ from "lodash-es";
This is only a breaking change if you use the node:
prefix in imports, and only in the form of that you need to autofix your files.
Changelog
Version 7.0.0 (2020-12-08)
You can now customize where type imports (import type { X } from "x"
) go, via the groups
option. Type imports have \u0000
at the end.
This is only a breaking change if you use the groups
option and your regexes care about what the last character is. If so, you now need to account for the fact that the last character of type imports is \u0000
.