Skip to content

Commit

Permalink
Fix: no-useless-rest-spread crashed (fixes #17)
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Oct 18, 2017
1 parent bfb5fa7 commit 30a5928
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rules/no-useless-rest-spread.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ module.exports = {
const parentType = node.parent.type
const argumentType = node.argument.type
const isArray = argumentType.startsWith("Array")
const isObject = !isArray && argumentType.startsWith("Object")
const isRedundant = (
argumentType === parentType ||
((isArray || isObject) && argumentType === parentType) ||
(isArray && FUNC_TYPE.test(parentType))
)

Expand Down
1 change: 1 addition & 0 deletions tests/lib/rules/no-useless-rest-spread.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ ruleTester.run("no-useless-rest-spread", rule, {
"foo(...{a}, ...{b})",
"let list = [...{a}]",
"let obj = {...[a]}",
"f(...g())",
],
invalid: [
{
Expand Down

0 comments on commit 30a5928

Please sign in to comment.