New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent noisy destructuring on function parameter #97
Prevent noisy destructuring on function parameter #97
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Fryuni, there are some valid cases that I see no problem in allowing:
const foo = ({bar}) => bar;
const foo = (bar, {quz}) => quz;
We should completely disallow multiline restructuring in arguments. Everything else is acceptable to me, provided it doesn't exceed the max line length.
@marcospassos I personally see these as a problem: const foo = ({some, value}, {yet, another, value}) => {}; I feel like the meaning of the parameters is lost, but I'm not entirely against it. I'll remove the single parameter restriction and the option to allow single line since we'll always have it enabled |
I see your point, but I prefer to allow it since I can't even remember an example of a function that takes two objects. In general, we always declare options as the last parameter, reason why I'm against only allowing destructuring on the first parameter (i.e. |
Co-authored-by: Marcos Passos <marcospassos@users.noreply.github.com>
…rameter-destructuring
Summary
As requested by @marcospassos, this new rule prevents noisy destructing on function parameters.
It allows restructuring in the function parameter if the function has only one parameter and the entire destruction is in a single line.
Any other destructing in a function parameter is not allowed.
Examples on the docs
Checklist