Skip to content

Commit

Permalink
Add support for prettier-plugin-sort-imports (#241)
Browse files Browse the repository at this point in the history
* Update plugins.js

* Update README

* Update tests and peer deps

* Update Prettier

* Update changelog

---------

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
  • Loading branch information
VladimirMikulic and thecrypticace committed Jan 12, 2024
1 parent 4338bd0 commit 1fa24c2
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 6 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Nothing yet!
### Added

- Add support for `prettier-plugin-sort-imports` ([#241](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/241))

## [0.5.11] - 2024-01-05

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ This plugin uses Prettier APIs that can only be used by one plugin at a time, ma
- `prettier-plugin-organize-imports`
- `prettier-plugin-style-order`
- `prettier-plugin-svelte`
- `prettier-plugin-sort-imports`

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

Expand Down
25 changes: 21 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@
"license-checker": "^25.0.1",
"line-column": "^1.0.2",
"marko": "^5.31.18",
"prettier": "^3.1",
"prettier": "^3.2",
"prettier-plugin-astro": "^0.12.2",
"prettier-plugin-css-order": "^2.0.0",
"prettier-plugin-import-sort": "^0.0.7",
"prettier-plugin-jsdoc": "^1.0.1",
"prettier-plugin-marko": "^3.1.1",
"prettier-plugin-organize-attributes": "^1.0.0",
"prettier-plugin-organize-imports": "^3.2.4",
"prettier-plugin-sort-imports": "^1.8.1",
"prettier-plugin-style-order": "^0.2.2",
"prettier-plugin-svelte": "^3.1.2",
"recast": "0.20.5",
Expand All @@ -74,6 +75,7 @@
"prettier-plugin-marko": "*",
"prettier-plugin-organize-attributes": "*",
"prettier-plugin-organize-imports": "*",
"prettier-plugin-sort-imports": "*",
"prettier-plugin-style-order": "*",
"prettier-plugin-svelte": "*"
},
Expand Down Expand Up @@ -111,6 +113,9 @@
"prettier-plugin-organize-imports": {
"optional": true
},
"prettier-plugin-sort-imports": {
"optional": true
},
"prettier-plugin-style-order": {
"optional": true
},
Expand Down
1 change: 1 addition & 0 deletions src/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ async function loadCompatiblePlugins() {
'prettier-plugin-jsdoc',
'prettier-plugin-organize-attributes',
'prettier-plugin-style-order',
'prettier-plugin-sort-imports',
]

// Load all the available compatible plugins up front
Expand Down
29 changes: 29 additions & 0 deletions tests/plugins.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,35 @@ let tests = [
],
},
},
{
versions: [3],
plugins: ['prettier-plugin-sort-imports'],
options: {
sortingMethod: 'alphabetical',
},
tests: {
babel: [
[
`import './three'\nimport '@two/file'\nimport '@one/file'`,
`import './three'\nimport '@one/file'\nimport '@two/file'`,
],
],
typescript: [
[
`import './three'\nimport '@two/file'\nimport '@one/file'`,
`import './three'\nimport '@one/file'\nimport '@two/file'`,
],
],

// This plugin does not support babel-ts
'babel-ts': [
[
`import './three'\nimport '@two/file'\nimport '@one/file'`,
`import './three'\nimport '@two/file'\nimport '@one/file'`,
],
],
},
},
{
versions: [2, 3],
plugins: ['prettier-plugin-organize-imports'],
Expand Down

0 comments on commit 1fa24c2

Please sign in to comment.