Skip to content

Commit 1fa24c2

Browse files
Add support for prettier-plugin-sort-imports (#241)
* Update plugins.js * Update README * Update tests and peer deps * Update Prettier * Update changelog --------- Co-authored-by: Jordan Pittman <[email protected]>
1 parent 4338bd0 commit 1fa24c2

File tree

6 files changed

+61
-6
lines changed

6 files changed

+61
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
### Added
11+
12+
- Add support for `prettier-plugin-sort-imports` ([#241](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/241))
1113

1214
## [0.5.11] - 2024-01-05
1315

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ This plugin uses Prettier APIs that can only be used by one plugin at a time, ma
157157
- `prettier-plugin-organize-imports`
158158
- `prettier-plugin-style-order`
159159
- `prettier-plugin-svelte`
160+
- `prettier-plugin-sort-imports`
160161

161162
One limitation with this approach is that `prettier-plugin-tailwindcss` *must* be loaded last.
162163

package-lock.json

Lines changed: 21 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,15 @@
4545
"license-checker": "^25.0.1",
4646
"line-column": "^1.0.2",
4747
"marko": "^5.31.18",
48-
"prettier": "^3.1",
48+
"prettier": "^3.2",
4949
"prettier-plugin-astro": "^0.12.2",
5050
"prettier-plugin-css-order": "^2.0.0",
5151
"prettier-plugin-import-sort": "^0.0.7",
5252
"prettier-plugin-jsdoc": "^1.0.1",
5353
"prettier-plugin-marko": "^3.1.1",
5454
"prettier-plugin-organize-attributes": "^1.0.0",
5555
"prettier-plugin-organize-imports": "^3.2.4",
56+
"prettier-plugin-sort-imports": "^1.8.1",
5657
"prettier-plugin-style-order": "^0.2.2",
5758
"prettier-plugin-svelte": "^3.1.2",
5859
"recast": "0.20.5",
@@ -74,6 +75,7 @@
7475
"prettier-plugin-marko": "*",
7576
"prettier-plugin-organize-attributes": "*",
7677
"prettier-plugin-organize-imports": "*",
78+
"prettier-plugin-sort-imports": "*",
7779
"prettier-plugin-style-order": "*",
7880
"prettier-plugin-svelte": "*"
7981
},
@@ -111,6 +113,9 @@
111113
"prettier-plugin-organize-imports": {
112114
"optional": true
113115
},
116+
"prettier-plugin-sort-imports": {
117+
"optional": true
118+
},
114119
"prettier-plugin-style-order": {
115120
"optional": true
116121
},

src/plugins.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ async function loadCompatiblePlugins() {
171171
'prettier-plugin-jsdoc',
172172
'prettier-plugin-organize-attributes',
173173
'prettier-plugin-style-order',
174+
'prettier-plugin-sort-imports',
174175
]
175176

176177
// Load all the available compatible plugins up front

tests/plugins.test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,35 @@ let tests = [
6363
],
6464
},
6565
},
66+
{
67+
versions: [3],
68+
plugins: ['prettier-plugin-sort-imports'],
69+
options: {
70+
sortingMethod: 'alphabetical',
71+
},
72+
tests: {
73+
babel: [
74+
[
75+
`import './three'\nimport '@two/file'\nimport '@one/file'`,
76+
`import './three'\nimport '@one/file'\nimport '@two/file'`,
77+
],
78+
],
79+
typescript: [
80+
[
81+
`import './three'\nimport '@two/file'\nimport '@one/file'`,
82+
`import './three'\nimport '@one/file'\nimport '@two/file'`,
83+
],
84+
],
85+
86+
// This plugin does not support babel-ts
87+
'babel-ts': [
88+
[
89+
`import './three'\nimport '@two/file'\nimport '@one/file'`,
90+
`import './three'\nimport '@two/file'\nimport '@one/file'`,
91+
],
92+
],
93+
},
94+
},
6695
{
6796
versions: [2, 3],
6897
plugins: ['prettier-plugin-organize-imports'],

0 commit comments

Comments
 (0)