-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 the default eslint react hooks config to the wordpress eslint package #14995
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.
LGTM 👍
That said, what's the status of changelogs at the moment, does this PR require it?
Edit: If so please add it, if not merge away 🎉
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.
Nice 👍
@ntwb I already have a CHANGELOG entry |
@@ -11,6 +11,22 @@ import { __ } from '@wordpress/i18n'; | |||
import { Notice } from '@wordpress/components'; | |||
import { useEffect } from '@wordpress/element'; | |||
|
|||
function ContrastCheckerMessage( { tinyBackgroundColor, tinyTextColor, backgroundColor, textColor } ) { |
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.
Out of curiosity, what ESLint rule was triggered which enforced this refactor? I'm wondering what is the lesson learned.
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.
The reason is that you can't use hooks after "early returns"
@@ -24,5 +25,7 @@ module.exports = { | |||
'react/no-children-prop': 'off', | |||
'react/prop-types': 'off', | |||
'react/react-in-jsx-scope': 'off', | |||
'react-hooks/rules-of-hooks': 'error', |
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.
Interesting, they don't provide the recommended preset.
@@ -24,5 +25,7 @@ module.exports = { | |||
'react/no-children-prop': 'off', | |||
'react/prop-types': 'off', | |||
'react/react-in-jsx-scope': 'off', | |||
'react-hooks/rules-of-hooks': 'error', | |||
'react-hooks/exhaustive-deps': 'warn', |
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.
I'm hesitant on the need of this one as we already have a valid use-case for extra deps, but I'm merging and we can try and see if it feels constraining.
"_originalInput": "#666", | ||
"_r": 102, | ||
"_roundA": 1, | ||
"_tc_id": 2, |
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.
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.
yes, these snapshots are not that useful I think.
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.
See #19169
closes #14676
This PR adds the default eslint config for react hooks (See https://reactjs.org/docs/hooks-rules.html) to the WordPress eslint config.
URLPopoverAtLink
component. It's our use-case is legitimate though so I was wondering if we should remove the second rule (the warning) added here. cc @aduth