@samitouri / QOS-React-2 / commits / a383c46788

[ESLint] don't warn for Flow type variables (#15804)

In Exhaustive Deps check for react-hooks don't warn if the dependency is a Flow type variable.

Jordan Rome committed Jun 2, 2019 at 21:20 UTC a383c46788fb0b6b9cb3644c675cc89bf48482ae
2 files changed +15
packages/eslint-plugin-react-hooks/__tests__/ESLintRuleExhaustiveDeps-test.js
+10
@@ -1014,6 +1014,16 @@ const tests = {
1014 }
1015 `,
1016 },
1017 + // Ignore Generic Type Variables for arrow functions
1018 + {
1019 + code: `
1020 + function Example({ prop }) {
1021 + const bar = useEffect(<T>(a: T): Hello => {
1022 + prop();
1023 + }, [prop]);
1024 + }
1025 + `,
1026 + },
1027 ],
1028 invalid: [
1029 {
packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
+5
@@ -407,6 +407,11 @@ export default {
407 continue;
408 }
409
410 + // Ignore Flow type parameters
411 + if (def.type === 'TypeParameter') {
412 + continue;
413 + }
414 +
415 // Add the dependency to a map so we can make sure it is referenced
416 // again in our dependencies array. Remember whether it's static.
417 if (!dependencies.has(dependency)) {