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: no-useless-rename handles ExperimentalRestProperty (fixes #6284) #6288
Fix: no-useless-rename handles ExperimentalRestProperty (fixes #6284) #6288
Conversation
LGTM |
By analyzing the blame information on this pull request, we identified @kaicataldo and @alberto to be potential reviewers |
@@ -239,6 +260,30 @@ ruleTester.run("no-useless-rename", rule, { | |||
errors: ["Destructuring assignment foo unnecessarily renamed.", "Destructuring assignment bar unnecessarily renamed."] | |||
}, | |||
{ | |||
code: "const {foo: foo, ...stuff} = myObject;", | |||
parserOptions: { |
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.
We should check the fixed output here as well - check the other invalid tests for the output
key to see what this looks like
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.
My bad, I didn't realize the rule was fixable. I will add that in a few
hours, when I get back home. Thanks!
On May 30, 2016 3:34 PM, "Kai Cataldo" notifications@github.com wrote:
In tests/lib/rules/no-useless-rename.js
#6288 (comment):@@ -239,6 +260,30 @@ ruleTester.run("no-useless-rename", rule, {
errors: ["Destructuring assignment foo unnecessarily renamed.", "Destructuring assignment bar unnecessarily renamed."]
},
{
code: "const {foo: foo, ...stuff} = myObject;",
parserOptions: {
We should check the fixed output here as well - check the other invalid
tests for the output key to see what this looks like—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/eslint/eslint/pull/6288/files/80d4c3c664cd314b393a4b31e2878a704683645a#r65104582,
or mute the thread
https://github.com/notifications/unsubscribe/AARWeoNObAlcbU4o3J-4iSuxw4-CESFLks5qG0m3gaJpZM4Ip_rq
.
One quick comment - thanks for working on this! |
I'm sorry, I had forgotten this option at that time. |
Hmm.. I would rather check for absence of the |
To tag on to what @ilyavolodin suggested, I think I'd like to see a comment explaining why the change is there then (since it won't be explicitly guarding against |
In all honesty, I'm not sure what's best here. It doesn't help that astexplorer.net (using its babel-eslint setting) shows a SpreadProperty which has a key and value and wouldn't have caused the rule to throw. I'm not even really sure what the spec is honestly supposed to look like here. Until we get consensus on the approach to use in the rule itself, I will focus on adding |
Seems to me to be more reason to go with the approach @ilyavolodin suggested :) |
Should have mentioned I was able to reproduce the issue with babel-ESLint.
|
I did notice the upper right of astexplorer.net says "acorn-to-esprima
|
Yeah, might be. Regardless, I'm a fan of @ilyavolodin's suggestion! |
LGTM |
@kaicataldo @ilyavolodin Updated the PR per your suggestions. Please let me know if anything else needs fixing. |
@@ -87,7 +87,7 @@ module.exports = { | |||
return; | |||
} | |||
|
|||
if (properties[i].computed) { | |||
if (properties[i].computed || !properties[i].key) { |
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.
Non-blocker: I think a comment here about why this guard is needed could be helpful for future contributors
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'll add that tomorrow. Thanks! Apologies for missing that.
One small nit, but otherwise LGTM. Nice work! |
LGTM! Thanks. |
LGTM |
The AppVeyor build failure is because AppVeyor still checks multiple commits (see #6292). Please let me know if there are any other issues I'm not aware of. @kaicataldo Please let me know what you think of the comment I've added. |
The body of the comment seems fine to me - what does the TODO mean? What's preventing us from checking that now? I ask because I don't think we should push a change if we haven't check everything, and who knows when the next person will actually get to the TODO issue. |
It refers to if |
I see - thanks for explaining. My inclination would be to remove the TODO line |
@kaicataldo Can do- remove without replacement? |
That's my preference - I think it raises more questions than answers |
Sorry - what I really meant is do you have a better way of expressing it? That's my preference - I think it raises more questions than answers — |
My vote is to remove it entirely and cross that bridge if and when we get to it. Others might have a different opinion though! |
@ilyavolodin Thoughts on how to handle the last comment issue here? |
I'm fine with removing that comment all together. We don't really create any specific code-path in our rules for |
@ilyavolodin So you believe no comment is necessary at all, even beyond removing the TODO? (Sorry for being dense, I just really want to make sure I'm understanding correctly.) It'd be great to get consensus on this... |
Sorry, I meant to remove TODO comment. The rest of the comments are fine. |
LGTM |
Okay, I've removed the TODO. Let me know if there's anything else I need to do. |
LGTM, thanks! |
LGTM |
I had a couple of options here-- either compare the type explicitly, or just look for the absence of a
key
property. I went with the former to be safe, but I can certainly amend to the latter if people think that is better.At this point I've only handled destructuring-- not sure yet if this is an issue in import or export. I'll investigate that and update this PR if needed. (EDIT: Seems those use a
*
token instead. In addition, that seems to be standard ES2015. So I assume we're good-- speak up if I missed something.)