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

Fix: sort-keys in an object that contains spread (fixes #10261) #10495

Merged
merged 1 commit into from
Jul 8, 2018

Conversation

katerberg
Copy link
Contributor

What is the purpose of this pull request? (put an "X" next to item)

[ ] Documentation update
[X] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)
I caused the linter to ignore any key-ordering in an object that contains a spread operator. Previously, it would verify that any keys that were not themselves spread operators were in the correct order, but this caused issues when the spread operator was between other keys as illustrated in https://eslint.org/docs/developer-guide/contributing/pull-requests

Is there anything you'd like reviewers to focus on?
This is my first pull request to this project, so any feedback would be welcomed. Since this does remove a test, I would also like to have a second set of eyes verify that the original test was indeed accidental and should have been reversed.

@jsf-clabot
Copy link

jsf-clabot commented Jun 21, 2018

CLA assistant check
All committers have signed the CLA.

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Jun 21, 2018
@katerberg katerberg force-pushed the master branch 3 times, most recently from f354459 to 90c92b4 Compare June 21, 2018 04:04
Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

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

Code changes LGTM, thanks!

Just two suggestions:

  1. Could the commit message mention the sort-keys rule by name? This will allow it to automatically link to the rule docs in our changelog and release notes.
  2. I think it would be good to add an extra example to the sort-keys rule docs about how object spread means no errors will be reported. Would you mind looking into that? Let us know if you need guidance.

Thanks for contributing!

@platinumazure
Copy link
Member

@katerberg Friendly ping... Did you have any questions about my review, and/or is there anything else I can do to help? Thanks!

@platinumazure platinumazure added bug ESLint is working incorrectly rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jun 25, 2018
@ljharb
Copy link
Sponsor Contributor

ljharb commented Jun 25, 2018

Hmm, why would we ignore all sorting? I'd think that the keys would be split up into groups - with a spread as the boundary - and each group would be individually sorted.

@katerberg
Copy link
Contributor Author

@platinumazure I'm still going to do this, but have had a busy weekend. Hoping to get to it next weekend.

@ljharb That would be reasonable as well. Do you and @platinumazure agree that it should be the behavior? If so, I can change the PR to match those goals.

@platinumazure
Copy link
Member

@katerberg I'm okay with trying to report on sorting keys in the "groups" before and after the object rest property node, if that seems feasible to you.

I can't remember if the rule currently does autofix or not, but if it does, I'll note that rules do not always have to autofix if they autofix in other cases: Users know that autofix is not guaranteed. So basically, I'm suggesting not to bite off too much with this bugfix. Incremental improvements are totally okay here. Thanks again for contributing!

@katerberg
Copy link
Contributor Author

Sounds good. I'll likely keep it as it is for now and make an issue to add the grouped alphabetizing as a separate PR. It looks like autofix is off for this rule on purpose: #10324

@katerberg katerberg force-pushed the master branch 2 times, most recently from dac2702 to 01ca9fa Compare June 26, 2018 02:42
@katerberg
Copy link
Contributor Author

I've now added the documentation to make the fact that it ignores objects with spread operators in them and updated the commit message. Let me know if you'd like anything else!

Copy link
Member

@not-an-aardvark not-an-aardvark 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!

@kaicataldo kaicataldo changed the title Ignores all sorting in an object that contains a spread Fix: sort-keys in an object that contains spread (fixes #10261) Jul 8, 2018
@not-an-aardvark not-an-aardvark dismissed platinumazure’s stale review July 8, 2018 20:10

Comments have been addressed

@not-an-aardvark not-an-aardvark merged commit 63f36f7 into eslint:master Jul 8, 2018
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jan 5, 2019
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jan 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants