Skip to content

Commit 62e7638

Browse files
committed
[Fix] no-object-type-as-default-prop: enable rule for components with many parameters
1 parent a944aa5 commit 62e7638

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/rules/no-object-type-as-default-prop.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const messages = {
3030
function hasUsedObjectDestructuringSyntax(params) {
3131
return (
3232
params != null
33-
&& params.length === 1
33+
&& params.length >= 1
3434
&& params[0].type === 'ObjectPattern'
3535
);
3636
}

tests/lib/rules/no-object-type-as-default-prop.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ ruleTester.run('no-object-type-as-default-prop', rule, {
143143
return null;
144144
};
145145
`,
146+
`
147+
const Foo = ({bar = 1}, context) => {
148+
return null;
149+
};
150+
`,
146151
`
147152
export default function NotAComponent({foo = {}}) {}
148153
`
@@ -183,6 +188,24 @@ ruleTester.run('no-object-type-as-default-prop', rule, {
183188
}
184189
`,
185190
errors: expectedViolations,
191+
},
192+
{
193+
code: `
194+
const Foo = ({
195+
a = {},
196+
b = ['one', 'two'],
197+
c = /regex/i,
198+
d = () => {},
199+
e = function() {},
200+
f = class {},
201+
g = new Thing(),
202+
h = <Thing />,
203+
i = Symbol('foo')
204+
}, context) => {
205+
return null;
206+
}
207+
`,
208+
errors: expectedViolations,
186209
}
187210
)),
188211
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy