-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Changes from all commits
80d4c3c
05d6145
7a458cf
5dee706
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,27 @@ ruleTester.run("no-useless-rename", rule, { | |
{ code: "export {foo as bar, baz as qux};", parserOptions: { ecmaVersion: 6, sourceType: "module" } }, | ||
{ code: "export {foo as bar} from 'foo';", parserOptions: { ecmaVersion: 6, sourceType: "module" } }, | ||
{ code: "export {foo as bar, baz as qux} from 'foo';", parserOptions: { ecmaVersion: 6, sourceType: "module" } }, | ||
{ | ||
code: "const {...stuff} = myObject;", | ||
parserOptions: { | ||
ecmaFeatures: { experimentalObjectRestSpread: true }, | ||
ecmaVersion: 6 | ||
} | ||
}, | ||
{ | ||
code: "const {foo, ...stuff} = myObject;", | ||
parserOptions: { | ||
ecmaFeatures: { experimentalObjectRestSpread: true }, | ||
ecmaVersion: 6 | ||
} | ||
}, | ||
{ | ||
code: "const {foo: bar, ...stuff} = myObject;", | ||
parserOptions: { | ||
ecmaFeatures: { experimentalObjectRestSpread: true }, | ||
ecmaVersion: 6 | ||
} | ||
}, | ||
|
||
// { ignoreDestructuring: true } | ||
{ | ||
|
@@ -238,6 +259,33 @@ ruleTester.run("no-useless-rename", rule, { | |
parserOptions: { ecmaVersion: 6 }, | ||
errors: ["Destructuring assignment foo unnecessarily renamed.", "Destructuring assignment bar unnecessarily renamed."] | ||
}, | ||
{ | ||
code: "const {foo: foo, ...stuff} = myObject;", | ||
output: "const {foo, ...stuff} = myObject;", | ||
parserOptions: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||
ecmaFeatures: { experimentalObjectRestSpread: true }, | ||
ecmaVersion: 6 | ||
}, | ||
errors: ["Destructuring assignment foo unnecessarily renamed."] | ||
}, | ||
{ | ||
code: "const {foo: foo, bar: baz, ...stuff} = myObject;", | ||
output: "const {foo, bar: baz, ...stuff} = myObject;", | ||
parserOptions: { | ||
ecmaFeatures: { experimentalObjectRestSpread: true }, | ||
ecmaVersion: 6 | ||
}, | ||
errors: ["Destructuring assignment foo unnecessarily renamed."] | ||
}, | ||
{ | ||
code: "const {foo: foo, bar: bar, ...stuff} = myObject;", | ||
output: "const {foo, bar, ...stuff} = myObject;", | ||
parserOptions: { | ||
ecmaFeatures: { experimentalObjectRestSpread: true }, | ||
ecmaVersion: 6 | ||
}, | ||
errors: ["Destructuring assignment foo unnecessarily renamed.", "Destructuring assignment bar unnecessarily renamed."] | ||
}, | ||
{ | ||
code: "import {foo as foo} from 'foo';", | ||
output: "import {foo} from 'foo';", | ||
|
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.