Skip to content

Commit

Permalink
[Fix] no-object-type-as-default-prop: enable rule for components wi…
Browse files Browse the repository at this point in the history
…th many parameters
  • Loading branch information
JulienR1 committed Jun 13, 2024
1 parent a944aa5 commit 62e7638
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/no-object-type-as-default-prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const messages = {
function hasUsedObjectDestructuringSyntax(params) {
return (
params != null
&& params.length === 1
&& params.length >= 1
&& params[0].type === 'ObjectPattern'
);
}
Expand Down
23 changes: 23 additions & 0 deletions tests/lib/rules/no-object-type-as-default-prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ ruleTester.run('no-object-type-as-default-prop', rule, {
return null;
};
`,
`
const Foo = ({bar = 1}, context) => {
return null;
};
`,
`
export default function NotAComponent({foo = {}}) {}
`
Expand Down Expand Up @@ -183,6 +188,24 @@ ruleTester.run('no-object-type-as-default-prop', rule, {
}
`,
errors: expectedViolations,
},
{
code: `
const Foo = ({
a = {},
b = ['one', 'two'],
c = /regex/i,
d = () => {},
e = function() {},
f = class {},
g = new Thing(),
h = <Thing />,
i = Symbol('foo')
}, context) => {
return null;
}
`,
errors: expectedViolations,
}
)),
});

0 comments on commit 62e7638

Please sign in to comment.