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(eslint-plugin): [member-ordering] add a required option for required vs. optional member ordering #5965

Merged
merged 15 commits into from Nov 28, 2022

Conversation

asdf93074
Copy link
Contributor

@asdf93074 asdf93074 commented Nov 10, 2022

PR Checklist

Overview

Added a new property required to SortedOrderConfig.
Added a corresponding error message id for when a rule fails because of required being set to 'first' or 'last'.

If required is 'first', then before any sorting/grouping configurations, we ensure that the members array has all its required items first and all optional items afterwards. Afterwards, we perform the remaining sorting/grouping checks on the required subset and the optional subset.

@nx-cloud
Copy link

nx-cloud bot commented Nov 10, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 17c0595. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 47 targets

Sent with 💌 from NxCloud.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @asdf93074!

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.

@netlify
Copy link

netlify bot commented Nov 10, 2022

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 17c0595
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/6384d886051118000832fa09
😎 Deploy Preview https://deploy-preview-5965--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@codecov
Copy link

codecov bot commented Nov 10, 2022

Codecov Report

Merging #5965 (17c0595) into main (becd1f8) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5965      +/-   ##
==========================================
+ Coverage   91.24%   91.27%   +0.02%     
==========================================
  Files         366      366              
  Lines       12380    12417      +37     
  Branches     3621     3631      +10     
==========================================
+ Hits        11296    11333      +37     
  Misses        774      774              
  Partials      310      310              
Flag Coverage Δ
unittest 91.27% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ackages/eslint-plugin/src/rules/member-ordering.ts 96.13% <100.00%> (+0.73%) ⬆️
packages/eslint-plugin/src/util/misc.ts 96.87% <100.00%> (+0.44%) ⬆️

…d which takes first or last as a value and adding functionality to check order based on both of these along with additional tests.
@asdf93074 asdf93074 marked this pull request as ready for review November 15, 2022 11:23
@JoshuaKGoldberg JoshuaKGoldberg changed the title feat(eslint-plugin): [member-ordering] Add a requiredFirst option to ensure that all required members are declared before all optional ones. feat(eslint-plugin): [member-ordering] Add a required option to ensure that all required members are declared before all optional ones. Nov 15, 2022
@JoshuaKGoldberg JoshuaKGoldberg changed the title feat(eslint-plugin): [member-ordering] Add a required option to ensure that all required members are declared before all optional ones. feat(eslint-plugin): [member-ordering] add a required option for required vs. optional member ordering Nov 15, 2022
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.

Thanks for sending this in @asdf93074! I'm excited to get this feature in. 🎉

There's a lot of changed code in this PR and the member-ordering rule is already a lot of lines. We should be able to trim the changes down a bit to be easier to read & review. I can take a deeper look once the refactors are done. Let me know if anything's unclear or not right!

packages/eslint-plugin/src/rules/member-ordering.ts Outdated Show resolved Hide resolved
packages/eslint-plugin/src/rules/member-ordering.ts Outdated Show resolved Hide resolved
packages/eslint-plugin/src/rules/member-ordering.ts Outdated Show resolved Hide resolved
packages/eslint-plugin/src/rules/member-ordering.ts Outdated Show resolved Hide resolved
packages/eslint-plugin/src/rules/member-ordering.ts Outdated Show resolved Hide resolved
packages/eslint-plugin/src/rules/member-ordering.ts Outdated Show resolved Hide resolved
packages/eslint-plugin/src/rules/member-ordering.ts Outdated Show resolved Hide resolved
@JoshuaKGoldberg JoshuaKGoldberg added the awaiting response Issues waiting for a reply from the OP or another party label Nov 15, 2022
@bradzacher bradzacher removed the awaiting response Issues waiting for a reply from the OP or another party label Nov 18, 2022
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.

Thanks for making the changes @asdf93074! I actually personally find this a good deal easier to read, but maybe that's just my personal preference. If another maintainer wants to weigh in that'd be good too 😄 - I'm nervous about stomping over perfectly good code. (and to be fair, yours did work quite well before too!)

Just requesting changes on a bit more testing. Otherwise this looks good to me!

@JoshuaKGoldberg JoshuaKGoldberg added the awaiting response Issues waiting for a reply from the OP or another party label Nov 19, 2022
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.

Fantastic, this is looking great. Thanks for sending this in and iterating on it with me @asdf93074! 🙌

@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented Nov 22, 2022

I'll leave this open for a bit in case another maintainer wants to poke at it or suggest an alternative API name (which we can apply ourselves if you don't want to keep receiving extra work because of our indecision 😅). But I've set a reminder to merge it this weekend if nobody requests changes, so it'll be available in our next stable version.

Edit: see #5965 (comment), will go on Monday!

@JoshuaKGoldberg JoshuaKGoldberg added 1 approval PR that a maintainer has LGTM'd - any maintainer can merge this when ready and removed awaiting response Issues waiting for a reply from the OP or another party labels Nov 22, 2022
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.

🙌

@JoshuaKGoldberg JoshuaKGoldberg merged commit 2abadc6 into typescript-eslint:main Nov 28, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 approval PR that a maintainer has LGTM'd - any maintainer can merge this when ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: [member-ordering] Port requiredFirst from eslint-plugin-typescript-sort-keys
3 participants