Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(eslint-plugin): [member-ordering] add support for getters and setters #3611

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

Merged
merged 5 commits into from
Aug 22, 2021

Conversation

gultyayev
Copy link
Contributor

@gultyayev gultyayev commented Jul 6, 2021

Fixes #929

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @gultyaev!

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. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@nx-cloud
Copy link

nx-cloud bot commented Jul 6, 2021

Nx Cloud Report

CI ran the following commands for commit 32f0474. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch

Status Command
#000000 nx run-many --target=build --all --parallel
#000000 nx run-many --target=typecheck --all --parallel

Sent with 💌 from NxCloud.

@bradzacher bradzacher added the enhancement: plugin rule option New rule option for an existing eslint-plugin rule label Jul 31, 2021
@bradzacher bradzacher changed the title feat(eslint-plugin): Add getters, setters to member-ordering rule feat(eslint-plugin): [member-ordering] add support for getters and setters Jul 31, 2021
@bradzacher bradzacher added the breaking change This change will require a new major version to be released label Jul 31, 2021
Comment on lines 5316 to 5338
{
code: `
class Foo {
@Bar
get a() {}

get b() {}

@Bar
set c() {}

set d() {}
}
`,
options: [
{
default: {
memberTypes: ['get', 'decorated-get', 'set', 'decorated-set'],
order: 'alphabetically',
},
},
],
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't correct, right?
your config has specified that the ordering should be get and then decorated-get, but the code itself has a decorated get followed by a normal get.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Don't know how I overlooked that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify - the problem was less that the test was wrong and yet it was passing fine.

Which means you haven't changed the rule correctly to handle the feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you check the code the actual test was wrong. Or at least its placement because it is in the valid section.
And checking my PR you can see updated code.

P.S. As soon as I updated the code the test started to fail which proves it right. So it was updated as well. Again because it's in the valid section.

Copy link
Contributor Author

@gultyayev gultyayev Aug 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bottom line is that now it's working correctly and if I were to leave the test unchanged I'd have to move it to the invalid section and add the expected errors so to have it passing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just added another test exactly like it was when you commented. This time to the invalid section to prove the code works correct

@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label Jul 31, 2021
@bradzacher bradzacher removed the awaiting response Issues waiting for a reply from the OP or another party label Aug 1, 2021
@gultyayev
Copy link
Contributor Author

Maybe we could move it to a patch rather than major version by leaving an old config which should work the same but in the meantime enable users to adopt this new option?

@bradzacher bradzacher added this to the 5.0.0 milestone Aug 21, 2021
@bradzacher bradzacher changed the base branch from master to v5 August 21, 2021 22:15
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm - thanks for this!

@bradzacher bradzacher merged commit 47a2222 into typescript-eslint:v5 Aug 22, 2021
bradzacher pushed a commit that referenced this pull request Sep 3, 2021
…tters (#3611)

* Getters/setters

* Fix decorated ordering

* Add test
bradzacher pushed a commit that referenced this pull request Sep 21, 2021
…tters (#3611)

* Getters/setters

* Fix decorated ordering

* Add test
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking change This change will require a new major version to be released enhancement: plugin rule option New rule option for an existing eslint-plugin rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[member-ordering] Order of getters and setters (accessors)
2 participants