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

Teach sort-comp rule about getters and setters. #1311

Merged
merged 2 commits into from Jul 21, 2017
Merged

Teach sort-comp rule about getters and setters. #1311

merged 2 commits into from Jul 21, 2017

Conversation

RDGthree
Copy link
Contributor

@RDGthree RDGthree commented Jul 20, 2017

We wanted to be able to sort our getters and setters and it was mentioned in an issue, so I implemented it. This PR allows getters and setters to be sorted by adding the keywords getters and/or setters to the sort-comp rule.

Fixes #100

@danieljvdm
Copy link

This is a phenomenal pull request. Phenomenal.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Thanks, this looks great! A few comments; plus it'll need tests, but then this should be a great semver-minor.

@@ -136,6 +136,24 @@ module.exports = {
}
}

if (method.getter) {
for (i = 0, j = methodsOrder.length; i < j; i++) {
Copy link
Member

Choose a reason for hiding this comment

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

var getterIndex = methodsOrder.indexOf('getters');
if (getterIndex > 0) { indexes.push(getterIndex); }

}

if (method.setter) {
for (i = 0, j = methodsOrder.length; i < j; i++) {
Copy link
Member

Choose a reason for hiding this comment

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

var setterIndex = methodsOrder.indexOf('setters');
if (setterIndex > 0) { indexes.push(setterIndex); }

@RDGthree
Copy link
Contributor Author

Updated!

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

LGTM, well done!

break;
}
const staticIndex = methodsOrder.indexOf('static-methods');
if (staticIndex >= 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for cleaning these others up too :-) I didn't realize you were following an existing pattern.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem! Easy change.

@ljharb
Copy link
Member

ljharb commented Jul 20, 2017

Sorry for the inconvenience; I've just merged a refactor to start using arrow functions. Would you mind rebasing?

@RDGthree
Copy link
Contributor Author

No worries, rebased!

Copy link
Collaborator

@EvHaus EvHaus left a comment

Choose a reason for hiding this comment

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

LGTM

@ljharb ljharb merged commit 067882b into jsx-eslint:master Jul 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

4 participants