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: no-useless-rename handles ExperimentalRestProperty (fixes #6284) #6288

Merged
merged 4 commits into from Jun 1, 2016

Conversation

platinumazure
Copy link
Member

@platinumazure platinumazure commented May 30, 2016

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.)

@eslintbot
Copy link

LGTM

@mention-bot
Copy link

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: {
Copy link
Member

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

Copy link
Member Author

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
.

@kaicataldo
Copy link
Member

One quick comment - thanks for working on this!

@mysticatea
Copy link
Member

I'm sorry, I had forgotten this option at that time.
Thank you.

@ilyavolodin
Copy link
Member

Hmm.. I would rather check for absence of the key, then use experimentalRestProperty, since as the name implies, it's experimental and will change at some point in the future. Which will mean we'll have to modify this rule.

@kaicataldo
Copy link
Member

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 experimentalRestProperty).

@platinumazure
Copy link
Member Author

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 output to my test cases.

@kaicataldo
Copy link
Member

kaicataldo commented May 31, 2016

Seems to me to be more reason to go with the approach @ilyavolodin suggested :)

@platinumazure
Copy link
Member Author

Should have mentioned I was able to reproduce the issue with babel-ESLint.
I think astexplorer only shows part of what babel-ESLint does. I only
mentioned it to show my confusion in this area. I'm happy to check for lack
of key and I can amend the PR soon to include that.
On May 30, 2016 7:04 PM, "Kai Cataldo" notifications@github.com wrote:

Seems to me to be more reason to go with the approach @ilyavolodin
https://github.com/ilyavolodin suggested. It might even work for
babel-eslint users as an added bonus.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#6288 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AARWemSdbsPW32THG4TYEIxfeY1QeXpYks5qG3sVgaJpZM4Ip_rq
.

@kaicataldo
Copy link
Member

Some weirdness with babel-eslint in astexplorer - it actually incorrectly labels RestProperty as SpreadProperty, even though babylon labels it correctly. Might be a bug with babel-eslint.

screen shot 2016-05-30 at 8 32 22 pm

screen shot 2016-05-30 at 8 32 54 pm

@platinumazure
Copy link
Member Author

I did notice the upper right of astexplorer.net says "acorn-to-esprima
version 1.0.7", maybe that's a clue as to why it's inconsistent on that
site.
On May 30, 2016 7:36 PM, "Kai Cataldo" notifications@github.com wrote:

Some weirdness with babel-eslint in astexplorer - it actually incorrectly
labels RestProperty as SpreadProperty, even though babylon labels it
correctly. Might be a bug with babel-eslint.

[image: screen shot 2016-05-30 at 8 32 22 pm]
https://cloud.githubusercontent.com/assets/7041728/15660147/0f3fcb9a-26a6-11e6-9cfa-aab96ca4605f.png
[image: screen shot 2016-05-30 at 8 32 54 pm]
https://cloud.githubusercontent.com/assets/7041728/15660146/0f3aac32-26a6-11e6-8d18-c953fad7a149.png


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#6288 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AARWenJurlnGtDdXnV6x3xSBqmo6D7ruks5qG4KGgaJpZM4Ip_rq
.

@kaicataldo
Copy link
Member

Yeah, might be. Regardless, I'm a fan of @ilyavolodin's suggestion!

@eslintbot
Copy link

LGTM

@platinumazure
Copy link
Member Author

@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) {
Copy link
Member

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

Copy link
Member Author

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.

@kaicataldo
Copy link
Member

One small nit, but otherwise LGTM. Nice work!

@ilyavolodin
Copy link
Member

LGTM! Thanks.

@eslintbot
Copy link

LGTM

@platinumazure
Copy link
Member Author

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.

@kaicataldo
Copy link
Member

kaicataldo commented May 31, 2016

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.

@platinumazure
Copy link
Member Author

It refers to if babel-eslint ever sends us a SpreadProperty (they do not at the moment) or if the object rest/spread proposal hits Stage 4 and thus espree would now parse that as SpreadProperty (the proposal is in Stage 2). There is nothing to do right now.

@kaicataldo
Copy link
Member

I see - thanks for explaining. My inclination would be to remove the TODO line

@platinumazure
Copy link
Member Author

@kaicataldo Can do- remove without replacement?

@kaicataldo
Copy link
Member

That's my preference - I think it raises more questions than answers

@platinumazure
Copy link
Member Author

Sorry - what I really meant is do you have a better way of expressing it?
If not, I can remove it.
On May 31, 2016 5:41 PM, "Kai Cataldo" notifications@github.com wrote:

That's my preference - I think it raises more questions than answers


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#6288 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AARWej4tOiRKjKE5umTWTcEGsvAp-fMZks5qHLkMgaJpZM4Ip_rq
.

@kaicataldo
Copy link
Member

kaicataldo commented May 31, 2016

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!

@platinumazure
Copy link
Member Author

@ilyavolodin Thoughts on how to handle the last comment issue here?

@ilyavolodin
Copy link
Member

I'm fine with removing that comment all together. We don't really create any specific code-path in our rules for babel-eslint. If one of our rules conflicts with it, they usually clone the rule into eslint-plugin-babel and fix it.

@platinumazure
Copy link
Member Author

@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...

@ilyavolodin
Copy link
Member

Sorry, I meant to remove TODO comment. The rest of the comments are fine.

@eslintbot
Copy link

LGTM

@platinumazure
Copy link
Member Author

Okay, I've removed the TODO. Let me know if there's anything else I need to do.

@kaicataldo
Copy link
Member

LGTM, thanks!

@ilyavolodin
Copy link
Member

LGTM

@ilyavolodin ilyavolodin merged commit bb69380 into eslint:master Jun 1, 2016
@platinumazure platinumazure deleted the no-useless-rename-crash branch March 20, 2017 18:05
@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants