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: no-useless-rename also reports default values (fixes #12301) #12322
Conversation
3a00488
to
18b41ed
Compare
18b41ed
to
9905f36
Compare
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.
LGTM, thanks!
I agree this should be semver-minor.
lib/rules/no-useless-rename.js
Outdated
@@ -85,7 +90,9 @@ module.exports = { | |||
const properties = node.properties; | |||
|
|||
for (let i = 0; i < properties.length; i++) { |
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.
Do we use the index anymore, outside of the next line? If not, should this be turned into a for-of loop?
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.
Updated! Did some further refactoring while I was at it. The code looks a bit simpler now!
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.
LGTM, thank you!
9905f36
to
c6da1e4
Compare
*/ | ||
if (properties[i].computed || !properties[i].key) { | ||
if (property.shorthand || property.type === "RestElement" || property.computed) { |
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.
Looks like there are already tests covering the property.type === "RestElement"
change on this line.
if (properties[i].key.type === "Identifier" && properties[i].key.name === properties[i].value.name || | ||
properties[i].key.type === "Literal" && properties[i].key.value === properties[i].value.name) { | ||
reportError(properties[i], properties[i].key, properties[i].value, "Destructuring assignment"); | ||
const key = (property.key.type === "Identifier" && property.key.name) || (property.key.type === "Literal" && property.key.value); |
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.
Some change here seems to break!
Failing line: https://github.com/nuxt/nuxt.js/blob/13331a02b4d5ef37932f42a845ca1754fb834243/packages/webpack/src/builder.js#L169
(just informational! I'll try to reproduce it better and make PR or Issue)
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.
Please track this issue: #12335 .
What is the purpose of this pull request? (put an "X" next to item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[x] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
fixes #12301
What changes did you make? (Give an overview)
This updates
no-useless-rename
to check destructured assignments with default values. I think this should be considered a semver-minor bug fix, since it feels like an oversight that this rule doesn't already check this case.Is there anything you'd like reviewers to focus on?
Are reviewers in agreement that this should be default behavior and not behind an option?