react icon indicating copy to clipboard operation
react copied to clipboard

Bug: eslint-plugin-react-hooks documentation might be misleading

Open StyleShit opened this issue 1 month ago • 0 comments

Splits from https://github.com/WordPress/gutenberg/issues/61598 & https://github.com/WordPress/gutenberg/pull/61599

The current explanation about "additionalHooks" under react-hooks/exhaustive-deps might be misleading. The regex in the example catches more than needed.

This:

"additionalHooks": "(useMyCustomHook|useMyOtherCustomHook)"

Will catch also things like this:

function App() {
	const data1 = useMyCustomHook2();
	const data2 = useMyOtherCustomHookTest();

	// ...
}

This might be the reason why Gutenberg used the same approach (which caused the bug mentioned above): https://github.com/WordPress/gutenberg/blob/2df566c771dba22eec2841081a00963a2e56658c/packages/eslint-plugin/configs/react.js#L37-L42

StyleShit avatar May 12 '24 19:05 StyleShit