@samitouri / QOS-React-1 / commits / cc7d421629

Add lint tests that should fail (#28147)

These though fail. Anon default export: https://github.com/facebook/react/issues/21181 Promise callbacks: https://github.com/facebook/react/issues/26186 Returning anon functions: https://github.com/facebook/react/issues/22520

Ricky committed Jan 29, 2024 at 12:54 UTC cc7d4216299e1d23a6e77b58d4c32ec1b8864ead
1 file changed +33
packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js
+33
@@ -521,6 +521,39 @@ const tests = {
521 }
522 `,
523 },
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 + },
557 ],
558 invalid: [
559 {