Skip to content

Commit cc7d421

Browse files
authored
Add lint tests that should fail (#28147)
These though fail. Anon default export: #21181 Promise callbacks: #26186 Returning anon functions: #22520
1 parent 971b62f commit cc7d421

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js

+33
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,39 @@ const tests = {
521521
}
522522
`,
523523
},
524+
{
525+
code: normalizeIndent`
526+
export const notAComponent = () => {
527+
return () => {
528+
useState();
529+
}
530+
}
531+
`,
532+
// TODO: this should error but doesn't.
533+
// errors: [functionError('use', 'notAComponent')],
534+
},
535+
{
536+
code: normalizeIndent`
537+
export default () => {
538+
if (isVal) {
539+
useState(0);
540+
}
541+
}
542+
`,
543+
// TODO: this should error but doesn't.
544+
// errors: [genericError('useState')],
545+
},
546+
{
547+
code: normalizeIndent`
548+
function notAComponent() {
549+
return new Promise.then(() => {
550+
useState();
551+
});
552+
}
553+
`,
554+
// TODO: this should error but doesn't.
555+
// errors: [genericError('useState')],
556+
},
524557
],
525558
invalid: [
526559
{

0 commit comments

Comments
 (0)