Skip to content

Commit 30a5928

Browse files
committed
Fix: no-useless-rest-spread crashed (fixes #17)
1 parent bfb5fa7 commit 30a5928

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/rules/no-useless-rest-spread.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,9 @@ module.exports = {
115115
const parentType = node.parent.type
116116
const argumentType = node.argument.type
117117
const isArray = argumentType.startsWith("Array")
118+
const isObject = !isArray && argumentType.startsWith("Object")
118119
const isRedundant = (
119-
argumentType === parentType ||
120+
((isArray || isObject) && argumentType === parentType) ||
120121
(isArray && FUNC_TYPE.test(parentType))
121122
)
122123

tests/lib/rules/no-useless-rest-spread.js

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ ruleTester.run("no-useless-rest-spread", rule, {
3535
"foo(...{a}, ...{b})",
3636
"let list = [...{a}]",
3737
"let obj = {...[a]}",
38+
"f(...g())",
3839
],
3940
invalid: [
4041
{

0 commit comments

Comments
 (0)