Skip to content
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

[DO NOT MERGE] Auto fix prefer-destructuring-in-parameters on codebase #1046

Conversation

fisker
Copy link
Collaborator

@fisker fisker commented Jan 21, 2021

Changes a lot, I'd like to fix codebase after #1045 get merged.

@@ -98,8 +98,8 @@ const create = context => {
const member = source.getText(node.property);

// Member might already be destructured
const destructuredMember = destructurings.find(property =>
property.key.name === member
const destructuredMember = destructurings.find(({key}) =>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with destructuring is that you lose some readability information. It's no longer clear when you read this that key is the key of a property...

scope.block &&
scope.block.type === 'ArrowFunctionExpression' &&
(scope.thisFound || scope.childScopes.some(scope => isArrowFunctionWithThis(scope)));
const isReactHook = ({block}) =>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's no longer possible to infer from the function what type it supports (that it supports a scope...

Comment on lines +100 to +104
const isArrowFunctionWithThis = ({type, block, thisFound, childScopes}) =>
type === 'function' &&
block &&
block.type === 'ArrowFunctionExpression' &&
(thisFound || childScopes.some(scope => isArrowFunctionWithThis(scope)));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the previous version was more readable, and not much longer.

Base automatically changed from master to main January 23, 2021 11:04
@sindresorhus
Copy link
Owner

Gonna close this for now as it's uncertain what we'll do with this rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants