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
[6.5.0] no-useless-rename
with babel-eslint
crash at rest properties
#12335
[6.5.0] no-useless-rename
with babel-eslint
crash at rest properties
#12335
Comments
Thanks for this issue. Can you minimize your code example to help us ensure which part caused the bug? Thanks. |
It looks like this line is throwing an error on this node:
Do you mind checking to see if the same error occurs with the default parser? It might be some difference between Espree and babel-eslint. |
The problem is the spread operator here i think The following code causes the error import * as React from 'react';
class CustomButton extends React.Component {
render() {
const { ...otherProps } = this.props;
return (
<div
{...otherProps}
/>
);
}
}
export default CustomButton; The following code does not cause an error: import * as React from 'react';
class CustomButton extends React.Component {
render() {
return (
<div
{...this.props.otherProps}
/>
);
}
}
export default CustomButton; |
I'd rather not swap my parser around but this is the most simplified example I can produce |
same error, when change |
I think the issue is with this section of the no-useless-rename code, if babel-eslint is still using ExperimentalRestProperty. The code is fine for espree. With babel-eslint (at least version 9 in ASTExplorer), the code uses ExperimentalRestProperty, so it does not meet the condition in line 100 and thus bail out via Not sure if babel-eslint@10 or babel-eslint@11 would run into the same problem. Similarly, I don't think espree should be broken-- @douxc If you think that line crashes while using the default parser, please provide more information about your configuration so we have a better idea of how to reproduce that. Thanks! |
I've tested with different parsers. Here is result:
|
no-useless-rename
doesn't work when upgrading from 6.4.0 to 6.5.0
Please note I wasn’t experiencing problems in 6.4.0 |
The root cause is that
|
no-useless-rename
doesn't work when upgrading from 6.4.0 to 6.5.0no-useless-rename
with babel-eslint
crash at rest properties
I had the same issue and adding the eslint rule Is a fix scheduled for this? |
I have the same thing. With this code: const key = (property.key.type === "Identifier" && property.key.name) || (property.key.type === "Literal" && property.key.value);
const renamedKey = property.value.type === "AssignmentPattern" ? property.value.left.name : property.value.name;
if (key === renamedKey) {
reportError(property, property.key, property.value, "Destructuring assignment");
} and temporarily changed it in node-modules to this: if (property.key) {
const key = (property.key.type === "Identifier" && property.key.name) || (property.key.type === "Literal" && property.key.value);
const renamedKey = property.value.type === "AssignmentPattern" ? property.value.left.name : property.value.name;
if (key === renamedKey) {
reportError(property, property.key, property.value, "Destructuring assignment");
}
} Error is:
Line of code complaining about is: handleSwipe ({ evt, ...info }) { |
Hi @kopax, if we can identify an easy fix, there's a possibility it could get into a patch release early this coming week. Otherwise, the next release will be in about 2 weeks (close to October 11th). Please see our README for more information. A PR would be welcome. I think adding a check for Just as a general reminder for everyone: This project, like most open-source projects, is 100% volunteer-run and the maintainers can only do so much by themselves. I appreciate the great discussion and the quick report of the issue, and I also appreciate everyone's patience as we figure out how best to fix this. |
An option is also |
This is a bug in babel-eslint. I’m not opposed to adding a temporary fix to the rule, but it should be fixed by babel-eslint. I’ll take a look later today and see if we can get it patched there. |
Off topic: @kaicataldo Maybe it can be done at babel/babel-eslint#785 . |
@g-plane Yes, that should fix it! Whipping up a PR to fix this on our end in the meantime. |
Instead of disabling the entire {
"no-useless-rename": [1, { "ignoreDestructuring": true }]
} |
@dspacejs This has been fixed in v6.5.1. |
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
babel eslint
Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
./node_modules/.bin/eslint --ext .js --ext .jsx .
What did you expect to happen?
Everything to lint fine as it does in
6.4.0
What actually happened? Please include the actual, raw output from ESLint.
Are you willing to submit a pull request to fix this bug?
No
The text was updated successfully, but these errors were encountered: