-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(eslint-plugin): [sort-type-constituents] support case sensitive sorting #8760
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
feat(eslint-plugin): [sort-type-constituents] support case sensitive sorting #8760
Conversation
Thanks for the PR, @jsfm01! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Hi @JoshuaKGoldberg |
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.
Pretty sweet change, very clean. Nicely done! 👏
A couple of requests that I hope won't be too painful to either implement or disagree with?
packages/eslint-plugin/tests/rules/sort-type-constituents.test.ts
Outdated
Show resolved
Hide resolved
…/github.com/up201304504/typescript-eslint into feature/4602-support-case-sensitive-sorting
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8760 +/- ##
==========================================
- Coverage 88.04% 87.37% -0.67%
==========================================
Files 410 255 -155
Lines 14183 12505 -1678
Branches 4135 3926 -209
==========================================
- Hits 12487 10926 -1561
+ Misses 1391 1304 -87
+ Partials 305 275 -30
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
create( | ||
context, | ||
[{ checkIntersections, checkUnions, caseSensitive, groupOrder }], | ||
) { | ||
const collator = new Intl.Collator('en', { | ||
sensitivity: 'base', |
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.
[Non-actionable] I tried switching this to 'accent'
, 'case'
, and 'variant'
instead of the manual caseSensitiveSort
function. Nothing passed all the tests. 🤷
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.
When the sensitive case is true, it follows the Unicode code points, no matter the collator sensitivity. If the collator sensitivity is set to 'case', for instance, the sorting would still be case-sensitive, but diacritics and accents would be treated as insignificant. The “accent”, doesn’t distinguish the capital letters, for instance, a = A. I believe we should keep as ‘base’.
Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
PR Checklist
Overview
New case sensitive sorting option:
{ "rules": { "@typescript-eslint/sort-type-constituents": [ "error", { "caseSensitive": true } ] } }
New option will help make this rule consistent with other sorting-related rules.