-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: drop javascript-natural-sort dep #28
Conversation
Minor problem: localeCompare appears to always interleave capital & lowercase letters. I don't know how to do both numeric-sort AND case-sensitive at the same time using pure locale-compare.
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I'm in favor of relying on native JS apis when possible, but I have some concern that the behavior here could be different from javascript-natural-sort, and we could introduce some unintentional breaking changes.
I think we can use the relevant test cases from https://github.com/Bill4Time/javascript-natural-sort/blob/master/unit-tests.html to minimize that chance, but since I don't think this fixes #23, and is really just a dependency cleanup, let's hold off on merging it until we're ready to release v4, which I think will be relatively soon. What do you think?
caseFirst: 'lower', | ||
}; | ||
|
||
return left.localeCompare(b, 'en', sortOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking out loud. Are we certain we always want to sort by english locale? I think so, because otherwise users working together on a shared project in different locales could cause formatting churn.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the time when I wrote this, I thought that we could hardcode ‘en’ because I was only considering detecting locale relevant here for currency, dates, and numeric separators. Of those, I only cared about the numeric separators: 1,000.00 vs 1.000,00 — and I arbitrarily assumed that those (separators) were irrelevant for js module names, and irrelevant for file names. (Implying we only really care about sorting short integers at the beginning or end of file names)
Further research shows that the locale actually affects how accented characters sort related to lower/uppercase letters.
I think it’d be fair to argue one of the following
- that our opinionated library could assume that those are unsupported, because file names / to limit complexity
- that our opinionated library only looks at your node’s default locale (risks “doesn’t work the same on my machine”)
- must have an additional locale parameter in config. :(
@IanVS Yes, I’m suggesting we target this for the breaking release. In that case, we don’t even need to add a large test suite. If we can decide how to resolve this topic: #28 (comment) then we can add a few targeted tests, and say deeper testing belongs to Intl.Collator. (Principle: Don’t write exhaustive tests verifying your OS or framework is doing what its contract offers — unless its mission critical). |
@IanVS — note: either #23 was already fine, because modern NodeJS uses modern V8 which has Stable Sort now, or JavaScript-natural-sort wasn’t stable, in which case this ticket does fix #23. Within any chunk, tie breaking should have a deterministic outcome once when you use a stable sorting algorithm with a defined comparator (edge cases exist, but don’t apply here). So… either this ticket fixes #23, or #23 is moot, but either way, I support shipping this with no-options in the breaking release. (Caveat locale decision). |
I don't think that stable sorting fixes issue #23. For example, if you add this test case to this branch's
The order in which the imports were originally defined determines what order they are placed in (which is what it means to have a stable sort). This is not what we want, however. We want a deterministic sort. Given two imports, in any order, they should always have the same final order. Maybe we are not agreeing on what it means to be |
Ah! That indeed is our difference. |
Given that we've cleared up the confusion over #23, I think we can close out this PR. But, let me know if you disagree and we can discuss further. Thanks for your work on this, and sorry for the miscommunication. |
Given that you and @blutorange believe the best option is to avoid dictating the order of imports differing only by case sensitivity, I think it's worth re-visiting this. |
@IanVS I pushed an update to this that made it compatible with |
Whoops, sorry I hadn't seen that you pushed that. Let's finish the option cleanup and then come back to this afterwards, if that's cool with you? |
However you prefer works for me. Was just trying to be helpful :P For what it's worth, I think it's just a trivial conflict if you want to fold this PR in and forget about it! |
Alright, in that case I'll check it out now, thanks. |
# Conflicts: # src/utils/get-sorted-nodes-group.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for bearing with me on this one. Glad we can finally get this cleanup in.
…#156) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@ianvs/prettier-plugin-sort-imports](https://github.com/ianvs/prettier-plugin-sort-imports) | [`^3.7.2` -> `^4.0.0`](https://renovatebot.com/diffs/npm/@ianvs%2fprettier-plugin-sort-imports/3.7.2/4.0.0) | [![age](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.0/compatibility-slim/3.7.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.0/confidence-slim/3.7.2)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>ianvs/prettier-plugin-sort-imports</summary> ### [`v4.0.0`](https://github.com/IanVS/prettier-plugin-sort-imports/releases/tag/v4.0.0) [Compare Source](https://github.com/ianvs/prettier-plugin-sort-imports/compare/v3.7.2...v4.0.0) #### What's Changed This new release focuses on simplifying the plugin options, shipping more useful defaults, handling comments around import statements more reliably, and improving Vue and TypeScript compatibility. We also are targeting Node 16 syntax with our build, though older versions may continue to work (untested). See the full [migration guide](https://github.com/IanVS/prettier-plugin-sort-imports/blob/next/docs/MIGRATION.md#migrating-from-v3xx-to-v4xx) for details of the breaking changes. ##### ⬆️ Breaking Changes - Build for Node 16+ ([IanVS/prettier-plugin-sort-imports#59) - Remove `importOrderBuiltinModulesToTop` (always true) ([IanVS/prettier-plugin-sort-imports#60) - Remove `importOrderSeparation` option ([IanVS/prettier-plugin-sort-imports#62) - Remove `importOrderCaseInsensitive` option ([IanVS/prettier-plugin-sort-imports#63) - Remove `importOrderGroupNamespaceSpecifiers` option ([IanVS/prettier-plugin-sort-imports#64) - Remove `importOrderSortSpecifiers` option ([IanVS/prettier-plugin-sort-imports#65) - Remove `importOrderMergeDuplicateImports` option (always on) ([IanVS/prettier-plugin-sort-imports#66) - Replace `importOrderCombineTypeAndValueImports` with `importOrderTypeScriptVersion` ([IanVS/prettier-plugin-sort-imports#67) - Improve default sort order ([IanVS/prettier-plugin-sort-imports#83) ##### 🐛 Bug Fixes - Fix behavior around comments embedded in imports ([IanVS/prettier-plugin-sort-imports#71) - Preserve trailing comments on specifiers ([IanVS/prettier-plugin-sort-imports#80) - Preserve comments and blank lines at top-of-file (in [IanVS/prettier-plugin-sort-imports#82) - Prevent comment gap when re-arranging first import ([IanVS/prettier-plugin-sort-imports#85) - Fix: Top-of-file Comments get duplicated when moving runtime code ([IanVS/prettier-plugin-sort-imports#88) - Vue: Sort both script and setup script ([IanVS/prettier-plugin-sort-imports#90) - Vue and TypeScript: Use correct parser plugins ([IanVS/prettier-plugin-sort-imports#91) ##### ⚡️ Features - Add `<BUILTIN_MODULES>` Special Word ([IanVS/prettier-plugin-sort-imports#86) - Allow Explicit Separator after Top-of-file-comments ([IanVS/prettier-plugin-sort-imports#92) - Support babel-ts parser ([IanVS/prettier-plugin-sort-imports#97) ##### 🛠️ Repo Maintenance - Update dependencies, jest -> vitest ([IanVS/prettier-plugin-sort-imports#59) - Check formatting in CI ([IanVS/prettier-plugin-sort-imports#61) - Update to latest versions of Github Actions ([IanVS/prettier-plugin-sort-imports#73) - Add some more tests for comments ([IanVS/prettier-plugin-sort-imports#77) ##### 🧳 Dependencies - Drop javascript-natural-sort dependency ([IanVS/prettier-plugin-sort-imports#28) - Drop lodash.clone dependency ([IanVS/prettier-plugin-sort-imports#74) - Upgrade Babel to 7.21 ([IanVS/prettier-plugin-sort-imports#72) **Full Changelog**: IanVS/prettier-plugin-sort-imports@v3.7.2...v4.0.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 12am and before 5am every weekday,every weekend" in timezone Asia/Kolkata, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/timelessco/browser-js-library-template).
…#109) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@ianvs/prettier-plugin-sort-imports](https://github.com/ianvs/prettier-plugin-sort-imports) | [`^3.7.2` -> `^4.0.0`](https://renovatebot.com/diffs/npm/@ianvs%2fprettier-plugin-sort-imports/3.7.2/4.0.0) | [![age](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.0/compatibility-slim/3.7.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.0/confidence-slim/3.7.2)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>ianvs/prettier-plugin-sort-imports</summary> ### [`v4.0.0`](https://github.com/IanVS/prettier-plugin-sort-imports/releases/tag/v4.0.0) [Compare Source](https://github.com/ianvs/prettier-plugin-sort-imports/compare/v3.7.2...v4.0.0) #### What's Changed This new release focuses on simplifying the plugin options, shipping more useful defaults, handling comments around import statements more reliably, and improving Vue and TypeScript compatibility. We also are targeting Node 16 syntax with our build, though older versions may continue to work (untested). See the full [migration guide](https://github.com/IanVS/prettier-plugin-sort-imports/blob/next/docs/MIGRATION.md#migrating-from-v3xx-to-v4xx) for details of the breaking changes. ##### ⬆️ Breaking Changes - Build for Node 16+ ([IanVS/prettier-plugin-sort-imports#59) - Remove `importOrderBuiltinModulesToTop` (always true) ([IanVS/prettier-plugin-sort-imports#60) - Remove `importOrderSeparation` option ([IanVS/prettier-plugin-sort-imports#62) - Remove `importOrderCaseInsensitive` option ([IanVS/prettier-plugin-sort-imports#63) - Remove `importOrderGroupNamespaceSpecifiers` option ([IanVS/prettier-plugin-sort-imports#64) - Remove `importOrderSortSpecifiers` option ([IanVS/prettier-plugin-sort-imports#65) - Remove `importOrderMergeDuplicateImports` option (always on) ([IanVS/prettier-plugin-sort-imports#66) - Replace `importOrderCombineTypeAndValueImports` with `importOrderTypeScriptVersion` ([IanVS/prettier-plugin-sort-imports#67) - Improve default sort order ([IanVS/prettier-plugin-sort-imports#83) ##### 🐛 Bug Fixes - Fix behavior around comments embedded in imports ([IanVS/prettier-plugin-sort-imports#71) - Preserve trailing comments on specifiers ([IanVS/prettier-plugin-sort-imports#80) - Preserve comments and blank lines at top-of-file (in [IanVS/prettier-plugin-sort-imports#82) - Prevent comment gap when re-arranging first import ([IanVS/prettier-plugin-sort-imports#85) - Fix: Top-of-file Comments get duplicated when moving runtime code ([IanVS/prettier-plugin-sort-imports#88) - Vue: Sort both script and setup script ([IanVS/prettier-plugin-sort-imports#90) - Vue and TypeScript: Use correct parser plugins ([IanVS/prettier-plugin-sort-imports#91) ##### ⚡️ Features - Add `<BUILTIN_MODULES>` Special Word ([IanVS/prettier-plugin-sort-imports#86) - Allow Explicit Separator after Top-of-file-comments ([IanVS/prettier-plugin-sort-imports#92) - Support babel-ts parser ([IanVS/prettier-plugin-sort-imports#97) ##### 🛠️ Repo Maintenance - Update dependencies, jest -> vitest ([IanVS/prettier-plugin-sort-imports#59) - Check formatting in CI ([IanVS/prettier-plugin-sort-imports#61) - Update to latest versions of Github Actions ([IanVS/prettier-plugin-sort-imports#73) - Add some more tests for comments ([IanVS/prettier-plugin-sort-imports#77) ##### 🧳 Dependencies - Drop javascript-natural-sort dependency ([IanVS/prettier-plugin-sort-imports#28) - Drop lodash.clone dependency ([IanVS/prettier-plugin-sort-imports#74) - Upgrade Babel to 7.21 ([IanVS/prettier-plugin-sort-imports#72) **Full Changelog**: IanVS/prettier-plugin-sort-imports@v3.7.2...v4.0.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 12am and before 5am every weekday,every weekend" in timezone Asia/Kolkata, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/timelessco/browser-js-website-template).
…#122) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@ianvs/prettier-plugin-sort-imports](https://github.com/ianvs/prettier-plugin-sort-imports) | [`^3.7.2` -> `^4.0.0`](https://renovatebot.com/diffs/npm/@ianvs%2fprettier-plugin-sort-imports/3.7.2/4.0.0) | [![age](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.0/compatibility-slim/3.7.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.0/confidence-slim/3.7.2)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>ianvs/prettier-plugin-sort-imports</summary> ### [`v4.0.0`](https://github.com/IanVS/prettier-plugin-sort-imports/releases/tag/v4.0.0) [Compare Source](https://github.com/ianvs/prettier-plugin-sort-imports/compare/v3.7.2...v4.0.0) #### What's Changed This new release focuses on simplifying the plugin options, shipping more useful defaults, handling comments around import statements more reliably, and improving Vue and TypeScript compatibility. We also are targeting Node 16 syntax with our build, though older versions may continue to work (untested). See the full [migration guide](https://github.com/IanVS/prettier-plugin-sort-imports/blob/next/docs/MIGRATION.md#migrating-from-v3xx-to-v4xx) for details of the breaking changes. ##### ⬆️ Breaking Changes - Build for Node 16+ ([IanVS/prettier-plugin-sort-imports#59) - Remove `importOrderBuiltinModulesToTop` (always true) ([IanVS/prettier-plugin-sort-imports#60) - Remove `importOrderSeparation` option ([IanVS/prettier-plugin-sort-imports#62) - Remove `importOrderCaseInsensitive` option ([IanVS/prettier-plugin-sort-imports#63) - Remove `importOrderGroupNamespaceSpecifiers` option ([IanVS/prettier-plugin-sort-imports#64) - Remove `importOrderSortSpecifiers` option ([IanVS/prettier-plugin-sort-imports#65) - Remove `importOrderMergeDuplicateImports` option (always on) ([IanVS/prettier-plugin-sort-imports#66) - Replace `importOrderCombineTypeAndValueImports` with `importOrderTypeScriptVersion` ([IanVS/prettier-plugin-sort-imports#67) - Improve default sort order ([IanVS/prettier-plugin-sort-imports#83) ##### 🐛 Bug Fixes - Fix behavior around comments embedded in imports ([IanVS/prettier-plugin-sort-imports#71) - Preserve trailing comments on specifiers ([IanVS/prettier-plugin-sort-imports#80) - Preserve comments and blank lines at top-of-file (in [IanVS/prettier-plugin-sort-imports#82) - Prevent comment gap when re-arranging first import ([IanVS/prettier-plugin-sort-imports#85) - Fix: Top-of-file Comments get duplicated when moving runtime code ([IanVS/prettier-plugin-sort-imports#88) - Vue: Sort both script and setup script ([IanVS/prettier-plugin-sort-imports#90) - Vue and TypeScript: Use correct parser plugins ([IanVS/prettier-plugin-sort-imports#91) ##### ⚡️ Features - Add `<BUILTIN_MODULES>` Special Word ([IanVS/prettier-plugin-sort-imports#86) - Allow Explicit Separator after Top-of-file-comments ([IanVS/prettier-plugin-sort-imports#92) - Support babel-ts parser ([IanVS/prettier-plugin-sort-imports#97) ##### 🛠️ Repo Maintenance - Update dependencies, jest -> vitest ([IanVS/prettier-plugin-sort-imports#59) - Check formatting in CI ([IanVS/prettier-plugin-sort-imports#61) - Update to latest versions of Github Actions ([IanVS/prettier-plugin-sort-imports#73) - Add some more tests for comments ([IanVS/prettier-plugin-sort-imports#77) ##### 🧳 Dependencies - Drop javascript-natural-sort dependency ([IanVS/prettier-plugin-sort-imports#28) - Drop lodash.clone dependency ([IanVS/prettier-plugin-sort-imports#74) - Upgrade Babel to 7.21 ([IanVS/prettier-plugin-sort-imports#72) **Full Changelog**: IanVS/prettier-plugin-sort-imports@v3.7.2...v4.0.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 12am and before 5am every weekday,every weekend" in timezone Asia/Kolkata, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/timelessco/js-bottomsheet).
…#79) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@ianvs/prettier-plugin-sort-imports](https://github.com/ianvs/prettier-plugin-sort-imports) | [`3.7.2` -> `4.0.0`](https://renovatebot.com/diffs/npm/@ianvs%2fprettier-plugin-sort-imports/3.7.2/4.0.0) | [![age](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.0/compatibility-slim/3.7.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.0/confidence-slim/3.7.2)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>ianvs/prettier-plugin-sort-imports</summary> ### [`v4.0.0`](https://github.com/IanVS/prettier-plugin-sort-imports/releases/tag/v4.0.0) [Compare Source](https://github.com/ianvs/prettier-plugin-sort-imports/compare/v3.7.2...v4.0.0) #### What's Changed This new release focuses on simplifying the plugin options, shipping more useful defaults, handling comments around import statements more reliably, and improving Vue and TypeScript compatibility. We also are targeting Node 16 syntax with our build, though older versions may continue to work (untested). See the full [migration guide](https://github.com/IanVS/prettier-plugin-sort-imports/blob/next/docs/MIGRATION.md#migrating-from-v3xx-to-v4xx) for details of the breaking changes. ##### ⬆️ Breaking Changes - Build for Node 16+ ([IanVS/prettier-plugin-sort-imports#59) - Remove `importOrderBuiltinModulesToTop` (always true) ([IanVS/prettier-plugin-sort-imports#60) - Remove `importOrderSeparation` option ([IanVS/prettier-plugin-sort-imports#62) - Remove `importOrderCaseInsensitive` option ([IanVS/prettier-plugin-sort-imports#63) - Remove `importOrderGroupNamespaceSpecifiers` option ([IanVS/prettier-plugin-sort-imports#64) - Remove `importOrderSortSpecifiers` option ([IanVS/prettier-plugin-sort-imports#65) - Remove `importOrderMergeDuplicateImports` option (always on) ([IanVS/prettier-plugin-sort-imports#66) - Replace `importOrderCombineTypeAndValueImports` with `importOrderTypeScriptVersion` ([IanVS/prettier-plugin-sort-imports#67) - Improve default sort order ([IanVS/prettier-plugin-sort-imports#83) ##### 🐛 Bug Fixes - Fix behavior around comments embedded in imports ([IanVS/prettier-plugin-sort-imports#71) - Preserve trailing comments on specifiers ([IanVS/prettier-plugin-sort-imports#80) - Preserve comments and blank lines at top-of-file (in [IanVS/prettier-plugin-sort-imports#82) - Prevent comment gap when re-arranging first import ([IanVS/prettier-plugin-sort-imports#85) - Fix: Top-of-file Comments get duplicated when moving runtime code ([IanVS/prettier-plugin-sort-imports#88) - Vue: Sort both script and setup script ([IanVS/prettier-plugin-sort-imports#90) - Vue and TypeScript: Use correct parser plugins ([IanVS/prettier-plugin-sort-imports#91) ##### ⚡️ Features - Add `<BUILTIN_MODULES>` Special Word ([IanVS/prettier-plugin-sort-imports#86) - Allow Explicit Separator after Top-of-file-comments ([IanVS/prettier-plugin-sort-imports#92) - Support babel-ts parser ([IanVS/prettier-plugin-sort-imports#97) ##### 🛠️ Repo Maintenance - Update dependencies, jest -> vitest ([IanVS/prettier-plugin-sort-imports#59) - Check formatting in CI ([IanVS/prettier-plugin-sort-imports#61) - Update to latest versions of Github Actions ([IanVS/prettier-plugin-sort-imports#73) - Add some more tests for comments ([IanVS/prettier-plugin-sort-imports#77) ##### 🧳 Dependencies - Drop javascript-natural-sort dependency ([IanVS/prettier-plugin-sort-imports#28) - Drop lodash.clone dependency ([IanVS/prettier-plugin-sort-imports#74) - Upgrade Babel to 7.21 ([IanVS/prettier-plugin-sort-imports#72) **Full Changelog**: IanVS/prettier-plugin-sort-imports@v3.7.2...v4.0.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 12am and before 5am on saturday" in timezone Asia/Kolkata, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/timelessco/node-ts-library-template).
…#71) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@ianvs/prettier-plugin-sort-imports](https://github.com/ianvs/prettier-plugin-sort-imports) | [`3.7.2` -> `4.0.2`](https://renovatebot.com/diffs/npm/@ianvs%2fprettier-plugin-sort-imports/3.7.2/4.0.2) | [![age](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.2/compatibility-slim/3.7.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.2/confidence-slim/3.7.2)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>ianvs/prettier-plugin-sort-imports</summary> ### [`v4.0.2`](https://github.com/IanVS/prettier-plugin-sort-imports/releases/tag/v4.0.2) [Compare Source](https://github.com/ianvs/prettier-plugin-sort-imports/compare/v4.0.1...v4.0.2) #### What's Changed - Account for missing filepath by [@​IanVS](https://github.com/IanVS) in [IanVS/prettier-plugin-sort-imports#104 **Full Changelog**: IanVS/prettier-plugin-sort-imports@v4.0.1...v4.0.2 ### [`v4.0.1`](https://github.com/IanVS/prettier-plugin-sort-imports/releases/tag/v4.0.1) [Compare Source](https://github.com/ianvs/prettier-plugin-sort-imports/compare/v4.0.0...v4.0.1) #### What's Changed - Fix cli in Install section by [@​torn4dom4n](https://github.com/torn4dom4n) in [IanVS/prettier-plugin-sort-imports#99 - Fix dollar sign ($) issue in Vue SFC by [@​istiak-tridip](https://github.com/istiak-tridip) in [IanVS/prettier-plugin-sort-imports#101 #### New Contributors - [@​torn4dom4n](https://github.com/torn4dom4n) made their first contribution in [IanVS/prettier-plugin-sort-imports#99 - [@​istiak-tridip](https://github.com/istiak-tridip) made their first contribution in [IanVS/prettier-plugin-sort-imports#101 **Full Changelog**: IanVS/prettier-plugin-sort-imports@v4.0.0...v4.0.1 ### [`v4.0.0`](https://github.com/IanVS/prettier-plugin-sort-imports/releases/tag/v4.0.0) [Compare Source](https://github.com/ianvs/prettier-plugin-sort-imports/compare/v3.7.2...v4.0.0) #### What's Changed This new release focuses on simplifying the plugin options, shipping more useful defaults, handling comments around import statements more reliably, and improving Vue and TypeScript compatibility. We also are targeting Node 16 syntax with our build, though older versions may continue to work (untested). See the full [migration guide](https://github.com/IanVS/prettier-plugin-sort-imports/blob/next/docs/MIGRATION.md#migrating-from-v3xx-to-v4xx) for details of the breaking changes. ##### ⬆️ Breaking Changes - Build for Node 16+ ([IanVS/prettier-plugin-sort-imports#59) - Remove `importOrderBuiltinModulesToTop` (always true) ([IanVS/prettier-plugin-sort-imports#60) - Remove `importOrderSeparation` option ([IanVS/prettier-plugin-sort-imports#62) - Remove `importOrderCaseInsensitive` option ([IanVS/prettier-plugin-sort-imports#63) - Remove `importOrderGroupNamespaceSpecifiers` option ([IanVS/prettier-plugin-sort-imports#64) - Remove `importOrderSortSpecifiers` option ([IanVS/prettier-plugin-sort-imports#65) - Remove `importOrderMergeDuplicateImports` option (always on) ([IanVS/prettier-plugin-sort-imports#66) - Replace `importOrderCombineTypeAndValueImports` with `importOrderTypeScriptVersion` ([IanVS/prettier-plugin-sort-imports#67) - Improve default sort order ([IanVS/prettier-plugin-sort-imports#83) ##### 🐛 Bug Fixes - Fix behavior around comments embedded in imports ([IanVS/prettier-plugin-sort-imports#71) - Preserve trailing comments on specifiers ([IanVS/prettier-plugin-sort-imports#80) - Preserve comments and blank lines at top-of-file (in [IanVS/prettier-plugin-sort-imports#82) - Prevent comment gap when re-arranging first import ([IanVS/prettier-plugin-sort-imports#85) - Fix: Top-of-file Comments get duplicated when moving runtime code ([IanVS/prettier-plugin-sort-imports#88) - Vue: Sort both script and setup script ([IanVS/prettier-plugin-sort-imports#90) - Vue and TypeScript: Use correct parser plugins ([IanVS/prettier-plugin-sort-imports#91) ##### ⚡️ Features - Add `<BUILTIN_MODULES>` Special Word ([IanVS/prettier-plugin-sort-imports#86) - Allow Explicit Separator after Top-of-file-comments ([IanVS/prettier-plugin-sort-imports#92) - Support babel-ts parser ([IanVS/prettier-plugin-sort-imports#97) ##### 🛠️ Repo Maintenance - Update dependencies, jest -> vitest ([IanVS/prettier-plugin-sort-imports#59) - Check formatting in CI ([IanVS/prettier-plugin-sort-imports#61) - Update to latest versions of Github Actions ([IanVS/prettier-plugin-sort-imports#73) - Add some more tests for comments ([IanVS/prettier-plugin-sort-imports#77) ##### 🧳 Dependencies - Drop javascript-natural-sort dependency ([IanVS/prettier-plugin-sort-imports#28) - Drop lodash.clone dependency ([IanVS/prettier-plugin-sort-imports#74) - Upgrade Babel to 7.21 ([IanVS/prettier-plugin-sort-imports#72) **Full Changelog**: IanVS/prettier-plugin-sort-imports@v3.7.2...v4.0.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 12am and before 5am on saturday" in timezone Asia/Kolkata, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/timelessco/node-js-library-template).
…#36) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@ianvs/prettier-plugin-sort-imports](https://github.com/ianvs/prettier-plugin-sort-imports) | [`3.7.2` -> `4.0.2`](https://renovatebot.com/diffs/npm/@ianvs%2fprettier-plugin-sort-imports/3.7.2/4.0.2) | [![age](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.2/compatibility-slim/3.7.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.2/confidence-slim/3.7.2)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>ianvs/prettier-plugin-sort-imports</summary> ### [`v4.0.2`](https://github.com/IanVS/prettier-plugin-sort-imports/releases/tag/v4.0.2) [Compare Source](https://github.com/ianvs/prettier-plugin-sort-imports/compare/v4.0.1...v4.0.2) #### What's Changed - Account for missing filepath by [@​IanVS](https://github.com/IanVS) in [IanVS/prettier-plugin-sort-imports#104 **Full Changelog**: IanVS/prettier-plugin-sort-imports@v4.0.1...v4.0.2 ### [`v4.0.1`](https://github.com/IanVS/prettier-plugin-sort-imports/releases/tag/v4.0.1) [Compare Source](https://github.com/ianvs/prettier-plugin-sort-imports/compare/v4.0.0...v4.0.1) #### What's Changed - Fix cli in Install section by [@​torn4dom4n](https://github.com/torn4dom4n) in [IanVS/prettier-plugin-sort-imports#99 - Fix dollar sign ($) issue in Vue SFC by [@​istiak-tridip](https://github.com/istiak-tridip) in [IanVS/prettier-plugin-sort-imports#101 #### New Contributors - [@​torn4dom4n](https://github.com/torn4dom4n) made their first contribution in [IanVS/prettier-plugin-sort-imports#99 - [@​istiak-tridip](https://github.com/istiak-tridip) made their first contribution in [IanVS/prettier-plugin-sort-imports#101 **Full Changelog**: IanVS/prettier-plugin-sort-imports@v4.0.0...v4.0.1 ### [`v4.0.0`](https://github.com/IanVS/prettier-plugin-sort-imports/releases/tag/v4.0.0) [Compare Source](https://github.com/ianvs/prettier-plugin-sort-imports/compare/v3.7.2...v4.0.0) ##### What's Changed This new release focuses on simplifying the plugin options, shipping more useful defaults, handling comments around import statements more reliably, and improving Vue and TypeScript compatibility. We also are targeting Node 16 syntax with our build, though older versions may continue to work (untested). See the full [migration guide](https://github.com/IanVS/prettier-plugin-sort-imports/blob/next/docs/MIGRATION.md#migrating-from-v3xx-to-v4xx) for details of the breaking changes. ##### ⬆️ Breaking Changes - Build for Node 16+ ([IanVS/prettier-plugin-sort-imports#59) - Remove `importOrderBuiltinModulesToTop` (always true) ([IanVS/prettier-plugin-sort-imports#60) - Remove `importOrderSeparation` option ([IanVS/prettier-plugin-sort-imports#62) - Remove `importOrderCaseInsensitive` option ([IanVS/prettier-plugin-sort-imports#63) - Remove `importOrderGroupNamespaceSpecifiers` option ([IanVS/prettier-plugin-sort-imports#64) - Remove `importOrderSortSpecifiers` option ([IanVS/prettier-plugin-sort-imports#65) - Remove `importOrderMergeDuplicateImports` option (always on) ([IanVS/prettier-plugin-sort-imports#66) - Replace `importOrderCombineTypeAndValueImports` with `importOrderTypeScriptVersion` ([IanVS/prettier-plugin-sort-imports#67) - Improve default sort order ([IanVS/prettier-plugin-sort-imports#83) ##### 🐛 Bug Fixes - Fix behavior around comments embedded in imports ([IanVS/prettier-plugin-sort-imports#71) - Preserve trailing comments on specifiers ([IanVS/prettier-plugin-sort-imports#80) - Preserve comments and blank lines at top-of-file (in [IanVS/prettier-plugin-sort-imports#82) - Prevent comment gap when re-arranging first import ([IanVS/prettier-plugin-sort-imports#85) - Fix: Top-of-file Comments get duplicated when moving runtime code ([IanVS/prettier-plugin-sort-imports#88) - Vue: Sort both script and setup script ([IanVS/prettier-plugin-sort-imports#90) - Vue and TypeScript: Use correct parser plugins ([IanVS/prettier-plugin-sort-imports#91) ##### ⚡️ Features - Add `<BUILTIN_MODULES>` Special Word ([IanVS/prettier-plugin-sort-imports#86) - Allow Explicit Separator after Top-of-file-comments ([IanVS/prettier-plugin-sort-imports#92) - Support babel-ts parser ([IanVS/prettier-plugin-sort-imports#97) ##### 🛠️ Repo Maintenance - Update dependencies, jest -> vitest ([IanVS/prettier-plugin-sort-imports#59) - Check formatting in CI ([IanVS/prettier-plugin-sort-imports#61) - Update to latest versions of Github Actions ([IanVS/prettier-plugin-sort-imports#73) - Add some more tests for comments ([IanVS/prettier-plugin-sort-imports#77) ##### 🧳 Dependencies - Drop javascript-natural-sort dependency ([IanVS/prettier-plugin-sort-imports#28) - Drop lodash.clone dependency ([IanVS/prettier-plugin-sort-imports#74) - Upgrade Babel to 7.21 ([IanVS/prettier-plugin-sort-imports#72) **Full Changelog**: IanVS/prettier-plugin-sort-imports@v3.7.2...v4.0.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on Monday" in timezone Asia/Kolkata, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/timelessco/bookmark-tags).
…#161) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@ianvs/prettier-plugin-sort-imports](https://github.com/ianvs/prettier-plugin-sort-imports) | [`3.7.2` -> `4.0.2`](https://renovatebot.com/diffs/npm/@ianvs%2fprettier-plugin-sort-imports/3.7.2/4.0.2) | [![age](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.2/compatibility-slim/3.7.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@ianvs%2fprettier-plugin-sort-imports/4.0.2/confidence-slim/3.7.2)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>ianvs/prettier-plugin-sort-imports</summary> ### [`v4.0.2`](https://github.com/IanVS/prettier-plugin-sort-imports/releases/tag/v4.0.2) [Compare Source](https://github.com/ianvs/prettier-plugin-sort-imports/compare/v4.0.1...v4.0.2) #### What's Changed - Account for missing filepath by [@​IanVS](https://github.com/IanVS) in [IanVS/prettier-plugin-sort-imports#104 **Full Changelog**: IanVS/prettier-plugin-sort-imports@v4.0.1...v4.0.2 ### [`v4.0.1`](https://github.com/IanVS/prettier-plugin-sort-imports/releases/tag/v4.0.1) [Compare Source](https://github.com/ianvs/prettier-plugin-sort-imports/compare/v4.0.0...v4.0.1) #### What's Changed - Fix cli in Install section by [@​torn4dom4n](https://github.com/torn4dom4n) in [IanVS/prettier-plugin-sort-imports#99 - Fix dollar sign ($) issue in Vue SFC by [@​istiak-tridip](https://github.com/istiak-tridip) in [IanVS/prettier-plugin-sort-imports#101 #### New Contributors - [@​torn4dom4n](https://github.com/torn4dom4n) made their first contribution in [IanVS/prettier-plugin-sort-imports#99 - [@​istiak-tridip](https://github.com/istiak-tridip) made their first contribution in [IanVS/prettier-plugin-sort-imports#101 **Full Changelog**: IanVS/prettier-plugin-sort-imports@v4.0.0...v4.0.1 ### [`v4.0.0`](https://github.com/IanVS/prettier-plugin-sort-imports/releases/tag/v4.0.0) [Compare Source](https://github.com/ianvs/prettier-plugin-sort-imports/compare/v3.7.2...v4.0.0) #### What's Changed This new release focuses on simplifying the plugin options, shipping more useful defaults, handling comments around import statements more reliably, and improving Vue and TypeScript compatibility. We also are targeting Node 16 syntax with our build, though older versions may continue to work (untested). See the full [migration guide](https://github.com/IanVS/prettier-plugin-sort-imports/blob/next/docs/MIGRATION.md#migrating-from-v3xx-to-v4xx) for details of the breaking changes. ##### ⬆️ Breaking Changes - Build for Node 16+ ([IanVS/prettier-plugin-sort-imports#59) - Remove `importOrderBuiltinModulesToTop` (always true) ([IanVS/prettier-plugin-sort-imports#60) - Remove `importOrderSeparation` option ([IanVS/prettier-plugin-sort-imports#62) - Remove `importOrderCaseInsensitive` option ([IanVS/prettier-plugin-sort-imports#63) - Remove `importOrderGroupNamespaceSpecifiers` option ([IanVS/prettier-plugin-sort-imports#64) - Remove `importOrderSortSpecifiers` option ([IanVS/prettier-plugin-sort-imports#65) - Remove `importOrderMergeDuplicateImports` option (always on) ([IanVS/prettier-plugin-sort-imports#66) - Replace `importOrderCombineTypeAndValueImports` with `importOrderTypeScriptVersion` ([IanVS/prettier-plugin-sort-imports#67) - Improve default sort order ([IanVS/prettier-plugin-sort-imports#83) ##### 🐛 Bug Fixes - Fix behavior around comments embedded in imports ([IanVS/prettier-plugin-sort-imports#71) - Preserve trailing comments on specifiers ([IanVS/prettier-plugin-sort-imports#80) - Preserve comments and blank lines at top-of-file (in [IanVS/prettier-plugin-sort-imports#82) - Prevent comment gap when re-arranging first import ([IanVS/prettier-plugin-sort-imports#85) - Fix: Top-of-file Comments get duplicated when moving runtime code ([IanVS/prettier-plugin-sort-imports#88) - Vue: Sort both script and setup script ([IanVS/prettier-plugin-sort-imports#90) - Vue and TypeScript: Use correct parser plugins ([IanVS/prettier-plugin-sort-imports#91) ##### ⚡️ Features - Add `<BUILTIN_MODULES>` Special Word ([IanVS/prettier-plugin-sort-imports#86) - Allow Explicit Separator after Top-of-file-comments ([IanVS/prettier-plugin-sort-imports#92) - Support babel-ts parser ([IanVS/prettier-plugin-sort-imports#97) ##### 🛠️ Repo Maintenance - Update dependencies, jest -> vitest ([IanVS/prettier-plugin-sort-imports#59) - Check formatting in CI ([IanVS/prettier-plugin-sort-imports#61) - Update to latest versions of Github Actions ([IanVS/prettier-plugin-sort-imports#73) - Add some more tests for comments ([IanVS/prettier-plugin-sort-imports#77) ##### 🧳 Dependencies - Drop javascript-natural-sort dependency ([IanVS/prettier-plugin-sort-imports#28) - Drop lodash.clone dependency ([IanVS/prettier-plugin-sort-imports#74) - Upgrade Babel to 7.21 ([IanVS/prettier-plugin-sort-imports#72) **Full Changelog**: IanVS/prettier-plugin-sort-imports@v3.7.2...v4.0.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on Monday" in timezone Asia/Kolkata, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/timelessco/next-ts-app).
This PR removes our reliance on natural-sort, an npm package last updated 9 years ago!
Instead this uses
String.localeCompare(…)
which is a built-in method supported on all Node versions we target. Further this is a standard String api, so some shim implementation will be present even if the user isn't running on Node! (eg.deno
or other runtimes)Original PR Description Below
Minor problem: localeCompare appears to always interleave capital & lowercase letters.I don't know how to do both numeric-sort AND case-sensitive (classic
Array.sort()
mode) at the same time using pure locale-compare.This is how I was forced to replicate the original case-sensitive sort:
prettier-plugin-sort-imports/src/natural-sort/index.ts
Lines 14 to 16 in 5f07e19
Relates to: #23 (comment)