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
Update: Add "consistent" option to array-element-newline (fixes #9457) #10355
Conversation
{ 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"] }, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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)?
@platinumazure Just according to #9457 :
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. |
There was a problem hiding this 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!
This has sat long enough so I'm going to go ahead and merge. Thanks @g-plane for contributing! |
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 rulearray-element-newline
.Is there anything you'd like reviewers to focus on?