-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Conversation
@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 |
LGTM |
LGTM but would like someone else to verify. |
|
||
return fixer.replaceTextRange( | ||
[leftBracket.range[0], rightBracket.range[1]], | ||
`${textBeforeProperty}.${node.property.value}${textAfterProperty}` |
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 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.
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.
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.
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.
Can you please add a test, then, that the spacing is not preserved?
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.
Added one here.
8be38f0
to
0aa69ab
Compare
LGTM |
0aa69ab
to
f28a97c
Compare
LGTM |
1 similar comment
LGTM |
LGTM. Thanks for PR! |
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.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.