Skip to content
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: require-array-sort-compare + toSorted #8052

Merged
merged 2 commits into from Dec 12, 2023

Conversation

Zamiell
Copy link
Contributor

@Zamiell Zamiell commented Dec 12, 2023

PR Checklist

Overview

A simple PR that just expands the rule to check for both sort and toSorted (instead of just checking for sort).
For context, when the rule was originally created, toSorted didn't exist, as this is a new array method.

@typescript-eslint
Copy link
Contributor

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.

Copy link

netlify bot commented Dec 12, 2023

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 51dea59
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/65787b379f257b000881fbee
😎 Deploy Preview https://deploy-preview-8052--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 90 (🔴 down 7 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 98 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

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]":
Copy link
Member

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...

Copy link
Contributor Author

@Zamiell Zamiell Dec 12, 2023

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

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a 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! ✨

@JoshuaKGoldberg
Copy link
Member

CI failures are unrelated. :shipit:

@JoshuaKGoldberg JoshuaKGoldberg merged commit c9661c8 into typescript-eslint:main Dec 12, 2023
46 of 59 checks passed
@JoshuaKGoldberg
Copy link
Member

SHOOT meant to rename the PR to feat(eslint-plugin):. Sigh.

@Zamiell Zamiell deleted the to-sorted branch December 12, 2023 16:30
@Josh-Cena
Copy link
Member

@Zamiell @JoshuaKGoldberg There's a test failure with this PR because the doc description wasn't updated. One of you want to follow-up?

@Zamiell
Copy link
Contributor Author

Zamiell commented Dec 13, 2023

can you direct me to the file (or preferably, the line) that you want me to update?

@Josh-Cena
Copy link
Member

Josh-Cena commented Dec 13, 2023

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 description front matter of require-array-sort-compare.md

@JoshuaKGoldberg
Copy link
Member

Zamiell JoshuaKGoldberg There's a test failure with this PR because the doc description wasn't updated. One of you want to follow-up?

Huh, brain fart on my end missing this. Thanks for the catch!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: [require-array-sort-compare] Does not work with Array.toSorted
4 participants