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

[New] 'destructuring-assigment' : add 'useContext' rule in SFC #2787

Closed

Conversation

ed-jinyoung-park
Copy link
Contributor

resolve issue #2309

  1. delete rule about variable happens to be named context

  2. set rule on useContext with options: always and options: never

  • make contextSet to detect any renamed variable that is being assigned by useContext

@ljharb ljharb changed the title [New] 'destrcuturing-assigment' : add 'useContext' rule in SFC [New] 'destructuring-assigment' : add 'useContext' rule in SFC Sep 5, 2020
Comment on lines 196 to 203
}, {
code: `const MyComponent = (props, { color }) => (
<div id={props.id} className={props.className} />
);`,
options: ['never'],
errors: [
{message: 'Must never use destructuring context assignment in SFC argument'}
]
Copy link
Member

Choose a reason for hiding this comment

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

why is this test changed? this implies it's a breaking change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think that case is legacy context assignment which is not used in current react version.
sorry for change without any comments.

Copy link
Member

Choose a reason for hiding this comment

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

This plugin supports all react versions; nothing can be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'm sorry. actually i want to ask about that. my mistake. then should I edit and make new PR?

plus, const destructuringContext = node.params && node.params[1] && node.params[1].type === 'ObjectPattern';should be added in function handleStatelessComponent(node) right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ljharb
i did revive test cases which i deleted and rules associated. please check again

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

Successfully merging this pull request may close these issues.

None yet

2 participants