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 fixer for dot-notation (fixes #7014) #7054

Merged
merged 1 commit into from Sep 7, 2016

Conversation

not-an-aardvark
Copy link
Member

What issue does this pull request address?
#7014

What changes did you make? (Give an overview)

This adds a fixer for the dot-notation rule, as described in #7014. It does not make any fix if the original code contains comments in the property-brackets, or between the dot and the property name.

foo[/* comment */ "bar"] // not fixed
foo. /* comment */ while // also not fixed

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

Nothing in particular.
#7014 has not been marked as accepted yet, so this PR should not be merged before that happens.

@mention-bot
Copy link

@not-an-aardvark, thanks for your PR! By analyzing the annotation information on this pull request, we identified @michaelficarra, @gyandeeps and @nzakas to be potential reviewers

@eslintbot
Copy link

LGTM

@kaicataldo kaicataldo added the evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion label Sep 3, 2016
@mysticatea
Copy link
Member

LGTM but would like someone else to verify.


return fixer.replaceTextRange(
[leftBracket.range[0], rightBracket.range[1]],
`${textBeforeProperty}.${node.property.value}${textAfterProperty}`
Copy link
Member

Choose a reason for hiding this comment

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

This appears to replace a[  'b'  ] with a  .b  . This behaviour is not tested, and I don't think it's desirable. I would just use `.${node.property.value}` instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point; this was originally there to ensure that comments didn't get deleted, but the rule now doesn't do the fix if there are comments anyway.

Copy link
Member

Choose a reason for hiding this comment

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

Can you please add a test, then, that the spacing is not preserved?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added one here.

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

1 similar comment
@michaelficarra
Copy link
Member

LGTM

@ilyavolodin
Copy link
Member

LGTM. Thanks for PR!

@ilyavolodin ilyavolodin merged commit 645dda5 into eslint:master Sep 7, 2016
@not-an-aardvark not-an-aardvark deleted the issue7014 branch September 7, 2016 18:47
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 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 Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants