Skip to content

Commit

Permalink
[ESLint] don't warn for Flow type variables (facebook#15804)
Browse files Browse the repository at this point in the history
In Exhaustive Deps check for react-hooks don't warn if the dependency is
a Flow type variable.
  • Loading branch information
jordalgo authored and gaearon committed Jun 3, 2019
1 parent 5763f1d commit a383c46
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,16 @@ const tests = {
}
`,
},
// Ignore Generic Type Variables for arrow functions
{
code: `
function Example({ prop }) {
const bar = useEffect(<T>(a: T): Hello => {
prop();
}, [prop]);
}
`,
},
],
invalid: [
{
Expand Down
5 changes: 5 additions & 0 deletions packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ export default {
continue;
}

// Ignore Flow type parameters
if (def.type === 'TypeParameter') {
continue;
}

// Add the dependency to a map so we can make sure it is referenced
// again in our dependencies array. Remember whether it's static.
if (!dependencies.has(dependency)) {
Expand Down

0 comments on commit a383c46

Please sign in to comment.