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

Update: Add "consistent" option to array-element-newline (fixes #9457) #10355

Merged
merged 1 commit into from May 28, 2018
Merged

Update: Add "consistent" option to array-element-newline (fixes #9457) #10355

merged 1 commit into from May 28, 2018

Conversation

g-plane
Copy link
Member

@g-plane g-plane commented May 16, 2018

close #9457

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

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

#9457

What changes did you make? (Give an overview)
Add a new option "consistent" for rule array-element-newline.

Is there anything you'd like reviewers to focus on?

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label May 16, 2018
{ code: "var foo = [];", options: ["consistent"] },
{ code: "var foo = [1];", options: ["consistent"] },
{ code: "var foo = [1, 2];", options: ["consistent"] },
{ code: "var foo = [1,\n2];", options: ["consistent"] },
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

hm, why is this consistent? I'd expect "consistent" to require either "every item is on the same line, along with the brackets" or "every item is on its own line, as is each bracket" - but nothing in between.

Copy link
Member

Choose a reason for hiding this comment

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

I think brackets are handled separately with array-bracket-newline. array-element-newline just deals with elements and not brackets.

Copy link
Member Author

Choose a reason for hiding this comment

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

This rule should not concern the style of brackets.

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

hm, ok - i suppose with "multiline", array-bracket-newline would work in concert with this rule and "consistent" to do what I'd expect.

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.

LGTM, thanks!

Just one question: Is it expected that autofix with consistent will always autofix to line breaks (i.e., never to one line)?

@g-plane
Copy link
Member Author

g-plane commented May 16, 2018

@platinumazure Just according to #9457 :

If implemented, the autofix would separate all elements onto a separate line if any of the elements are on a separate line. The autofix would never put all elements into a single line.

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.

Cripes, missed one thing.

Could the commit message be changed to say "(fixes #9457)"? (Yes, I know the PR text says "closes #9457", but our changelog looks nicer when commits are accurate about whether they fix or merely refer to/partially fix an issue.)

Code/tests/docs LGTM though.

@platinumazure platinumazure added enhancement This change enhances an existing feature of ESLint 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 May 16, 2018
@g-plane
Copy link
Member Author

g-plane commented May 16, 2018

Updated.

@platinumazure platinumazure changed the title Update: Add "consistent" option to array-element-newline (refs #9457) Update: Add "consistent" option to array-element-newline (fixes #9457) May 16, 2018
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.

Thanks for updating the commit message. LGTM, thanks for contributing!

@platinumazure platinumazure merged commit 9c922ce into eslint:master May 28, 2018
@platinumazure
Copy link
Member

This has sat long enough so I'm going to go ahead and merge. Thanks @g-plane for contributing!

@g-plane g-plane deleted the new-option-array-element-newline branch May 28, 2018 14:51
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Nov 26, 2018
@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 Nov 26, 2018
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 enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: Add "consistent" option to array-element-newline
4 participants