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
Add prefer-destructuring-in-parameters
rule
#1045
Add prefer-destructuring-in-parameters
rule
#1045
Conversation
b85bdb0
to
b9f5126
Compare
Another question, currently - const foo = (bar, baz) => bar.x === baz.x;
+ const foo = ({x}, baz) => x === baz.x; This is a little a awkward, But if we decided allow rename, this won't be a problem, we can fix to - const foo = (bar, baz) => bar.x === baz.x;
+ const foo = ({x: xOfBar}, {x: xOfBaz}) => xOfBar === xOfBaz; |
I think this rule should have an option to only enforce it for inline arrow functions. I find it a bit opinionated to do it for all arrow functions. Constructuring many times leads to less readable code when applied to large functions. |
Are you asking whether we should trigger on the case where it needs to be renamed or are you asking whether we should allow renaming at all?
Yes, just make sure the fix follows what we enforce in
Yes, but not sure what number makes sense. Should it be configurable? |
When I decide whether to destructure or just use the object, I also think of:
While it's a nice rule, I'm not sure that it can consistently improve the readability. More like 50/50 |
Closing as this has been stale for 2 years. |
Questions:
0
/1
or just make sure the fixed code not againstno-unreadable-array-destructuring
ruleSee https://github.com/sindresorhus/eslint-plugin-unicorn/pull/1045/files#diff-e9f53b43e2668561c178de9cab0e6745a034fee9e0c5321f93c83750b6c73553R740, this case creates a lot of variables.
Did not fix codebase, since the diff is big, I want keep this PR small. But you can check changes 9887f56
Fixes #954