Skip to content

Commit

Permalink
[eslint] Correct comments and add another test (facebook#17220)
Browse files Browse the repository at this point in the history
  • Loading branch information
dprgarner committed Nov 9, 2019
1 parent 37e3554 commit 54a180a
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,17 +303,17 @@ const tests = {
}
`,
`
// Similarly, this is valid because "use"-prefixed functions called in
// the callbacks of unrecognised functions are not assumed to be hooks.
// This is valid because "use"-prefixed functions called in
// unnamed function arguments are not assumed to be hooks.
React.unknownFunction((foo, bar) => {
if (foo) {
useNotAHook(bar)
}
});
`,
`
// Similarly, this is valid because "use"-prefixed functions called in
// the callbacks of unrecognised functions are not assumed to be hooks.
// This is valid because "use"-prefixed functions called in
// unnamed function arguments are not assumed to be hooks.
unknownFunction(function(foo, bar) {
if (foo) {
useNotAHook(bar)
Expand Down Expand Up @@ -818,6 +818,16 @@ const tests = {
`,
errors: [conditionalError('useCustomHook')],
},
{
code: `
// This is invalid because "use"-prefixed functions used in named
// functions are assumed to be hooks.
React.unknownFunction(function notAComponent(foo, bar) {
useProbablyAHook(bar)
});
`,
errors: [functionError('useProbablyAHook', 'notAComponent')],
},
{
code: `
// Invalid because it's dangerous.
Expand Down

0 comments on commit 54a180a

Please sign in to comment.