-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: require-array-sort-compare + toSorted #8052
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
Conversation
Thanks for the PR, @Zamiell! 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. |
return { | ||
"CallExpression[arguments.length=0] > MemberExpression[property.name='sort'][computed=false]": | ||
checkSortArgument, | ||
"CallExpression[arguments.length=0] > MemberExpression[property.name='toSorted'][computed=false]": |
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] Aside: I'm glad you didn't increase the complexity of this selector 😂 I think it's at the maximum reasonable level to still be readable as-is...
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.
lol, that was because i simply do not know the selector syntax well enough to even try
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.
Love it, super straightforward and clean. Thanks! ✨
CI failures are unrelated. |
SHOOT meant to rename the PR to |
@Zamiell @JoshuaKGoldberg There's a test failure with this PR because the doc description wasn't updated. One of you want to follow-up? |
can you direct me to the file (or preferably, the line) that you want me to update? |
This is the error: Summary of all failing tests
FAIL tests/docs.test.ts (195 MB heap size)
● Validating rule docs › require-array-sort-compare.md › require-array-sort-compare.md must start with frontmatter description
expect(received).toMatchObject(expected)
- Expected - 1
+ Received + 1
Object {
"depth": 2,
- "text": "description: 'Require `Array#sort` and `Array#toSorted` calls to always provide a `compareFunction`.'",
+ "text": "description: 'Require `Array#sort` calls to always provide a `compareFunction`.'",
"type": "heading",
} So, you would edit the |
Huh, brain fart on my end missing this. Thanks for the catch! |
PR Checklist
Overview
A simple PR that just expands the rule to check for both
sort
andtoSorted
(instead of just checking forsort
).For context, when the rule was originally created,
toSorted
didn't exist, as this is a new array method.