-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
The guide says:
The following patterns are not considered warnings:
/*eslint destructuring/in-params: ["error", { "max-params" : 1}]*/ function t1({a}) {} function t2(a, b) { const {c} = a; const {d} = b; } const t3 = ({a}) => a;
But this is also valid:
function t3({ a, b, c, d, e}) {}
I would expect to be able to set the maximum number of destructured variables, so that one is forced to rewrite t3 as follows:
function t3(params) {
const { a, b, c, d, e} = params;
}
This is a common issue with functional React components, where someone starts with a few parameters destructured in the function signature:
const MyReactComponent: FC<MyReactComponentProps> = ({ aProp, orTwo }) => {
...
}
Then over time, as different people keep adding features to that component, they put and more props into the function signature that becomes a multi-line monstrosity eventually, without bothering to move the destructuring to a function body.
It would be very handy to have a rule that allows up to a certain number of variables in the destructuting block.
Is there already a way to do it?
Metadata
Metadata
Assignees
Labels
No labels