-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Eslint: extend plugin:react-hooks/recommended #4498
base: master
Are you sure you want to change the base?
Eslint: extend plugin:react-hooks/recommended #4498
Conversation
…out suspicious hooks
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@dominikdosoudil let's create a separate PR to rename these functions. I believe the problem is with I suggest:
|
@layershifter That sounds good, however this step will still affect a lot of files as the If that's ok with you, I'll follow the steps and mention the individual PRs here. |
Indeed, but if PRs will be sliced by files' location i.e. all ( |
Can I suggest another approach which would avoid the last big bang? We might create aliases for /**
+ * @deprecated
* Props where only the prop key is used in the className.
* @param {*} val A props value
* @param {string} key A props key
*
* @example
* <Label tag />
* <div class="ui tag label"></div>
*/
export const useKeyOnly = (val, key) => val && key
+ export const getKeyOnly = useKeyOnly; Step 2 - incrementally replace the function name in individual files to make PR less big: export {
- useKeyOnly,
+ getKeyOnly,
- useKeyOrValueAndKey,
+ getKeyOrValueAndKey,
// etc.
} from './classNameBuilders' Step 3 - remove the original functions and inline the aliases: /**
- * @deprecated
* Props where only the prop key is used in the className.
* @param {*} val A props value
* @param {string} key A props key
*
* @example
* <Label tag />
* <div class="ui tag label"></div>
*/
- export const useKeyOnly = (val, key) => val && key
-
- export const getKeyOnly = useKeyOnly;
+ export const getKeyOnly = (val, key) => val && key This way, there should not be the large number of changes in imports after finally renaming the functions in their declarations. |
@dominikdosoudil yeah, that's actually was my proposal 🐱 Sorry if I was unclear :) ^ that would avoid deprecations with the same result, but your proposal is even better :) |
Step 1: #4500 aliases |
@dominikdosoudil it's merged 😉 |
After merging #4505, there will be few warnings and one remaining error:
caused by if (process.env.NODE_ENV !== 'production') {
React.useEffect(() => {
...
}, [exclusive, activeIndex])
} I think that it might be ignored because we are smarter than eslint here and we know that NODE_ENV won't probably change during runtime. |
The only problem is that there are few internal functions that have prefix "use" and eslint thinks that they are hooks.
Should the code be refactored along with this PR or it is just ok that some false positive errors would pop up with accepting this PR?