From 9c1762eb4a51130d6a8cfc63cba46225312092e8 Mon Sep 17 00:00:00 2001 From: Ricky Hanlon Date: Mon, 29 Jan 2024 11:46:56 -0500 Subject: [PATCH] Add lint tests that should fail --- .../__tests__/ESLintRulesOfHooks-test.js | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js b/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js index f392cf61989bd..b30f522bf1903 100644 --- a/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js +++ b/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js @@ -521,6 +521,39 @@ const tests = { } `, }, + { + code: normalizeIndent` + export const notAComponent = () => { + return () => { + useState(); + } + } + `, + // TODO: this should error but doesn't. + // errors: [functionError('use', 'notAComponent')], + }, + { + code: normalizeIndent` + export default () => { + if (isVal) { + useState(0); + } + } + `, + // TODO: this should error but doesn't. + // errors: [genericError('useState')], + }, + { + code: normalizeIndent` + function notAComponent() { + return new Promise.then(() => { + useState(); + }); + } + `, + // TODO: this should error but doesn't. + // errors: [genericError('useState')], + }, ], invalid: [ {