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: ignore aligning single line in key-spacing (fixes #11414) #12652

Merged
merged 3 commits into from Dec 20, 2019
Merged

Fix: ignore aligning single line in key-spacing (fixes #11414) #12652

merged 3 commits into from Dec 20, 2019

Conversation

yeonjuan
Copy link
Member

@yeonjuan yeonjuan commented Dec 7, 2019

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)
fix #11414
make it ignore aligning single line properties.

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 Dec 7, 2019
@kaicataldo kaicataldo added accepted There is consensus among the team that this change meets the criteria for inclusion autofix This change is related to ESLint's autofixing capabilities bug ESLint is working incorrectly rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Dec 10, 2019
Copy link
Member

@kaicataldo kaicataldo 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 working on this!

lib/rules/key-spacing.js Show resolved Hide resolved
tests/lib/rules/key-spacing.js Show resolved Hide resolved
Copy link
Member

@kaicataldo kaicataldo left a comment

Choose a reason for hiding this comment

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

I'm not sure this fixes the problem in full (see comments). That being said, I recognize that the behavior I'm suggesting below is a lot more work. I would be fine with landing this as-is because it's passing through the options and does seem like an improvement 👍

output: [
"var obj = {",
" foo : 1,",
" 'bar' : 2, baz : 3, longlonglong: 4",
Copy link
Member

Choose a reason for hiding this comment

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

I understand why this is the way it is, but I wonder if this actually makes sense?

Feels like it should be:

var obj = {
    foo  : 1,
    'bar': 2, baz: 3, longlonglong: 4
};

or

var obj = {
    foo: 1, 'bar'       : 2,
    baz: 3, longlonglong: 4
};

output: [
"var obj = {",
" foo : 1,",
" 'bar' : 2, baz : 3,",
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as above.

Copy link
Member Author

Choose a reason for hiding this comment

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

@kaicataldo
Yes, I agree :) Can I work on that in different PR?.

Copy link
Member

@btmills btmills left a comment

Choose a reason for hiding this comment

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

Also fine landing as-is. Thanks for delving into this rule, @yeonjuan!

@btmills btmills merged commit c5c7086 into eslint:master Dec 20, 2019
@yeonjuan yeonjuan deleted the fix-only-single-line branch January 3, 2020 14:50
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jun 19, 2020
@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 Jun 19, 2020
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 autofix This change is related to ESLint's autofixing capabilities 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.

key-spacing + align: 'value' + jsx objects becomes ugly sometimes
3 participants