From cf78530d842ffc1b394e6e98ec9c28b5fbfee13a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Mon, 6 Sep 2021 17:10:32 +0200 Subject: [PATCH] feat(no-unnecessary-act): add to React config by default (#468) BREAKING CHANGE: `no-unnecessary-act` is now enabled by default in the React config (with `isStrict` set to `true`) --- README.md | 2 +- lib/configs/react.ts | 1 + lib/rules/no-unnecessary-act.ts | 2 +- tests/__snapshots__/index.test.ts.snap | 6 ++++++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3b7cf571..8fc62d0c 100644 --- a/README.md +++ b/README.md @@ -199,7 +199,7 @@ To enable this configuration use the `extends` property in your | [`testing-library/no-node-access`](./docs/rules/no-node-access.md) | Disallow direct Node access | | ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/no-promise-in-fire-event`](./docs/rules/no-promise-in-fire-event.md) | Disallow the use of promises passed to a `fireEvent` method | | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/no-render-in-setup`](./docs/rules/no-render-in-setup.md) | Disallow the use of `render` in testing frameworks setup functions | | | -| [`testing-library/no-unnecessary-act`](./docs/rules/no-unnecessary-act.md) | Disallow wrapping Testing Library utils or empty callbacks in `act` | | | +| [`testing-library/no-unnecessary-act`](./docs/rules/no-unnecessary-act.md) | Disallow wrapping Testing Library utils or empty callbacks in `act` | | ![react-badge][] | | [`testing-library/no-wait-for-empty-callback`](./docs/rules/no-wait-for-empty-callback.md) | Disallow empty callbacks for `waitFor` and `waitForElementToBeRemoved` | | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/no-wait-for-multiple-assertions`](./docs/rules/no-wait-for-multiple-assertions.md) | Disallow the use of multiple `expect` calls inside `waitFor` | | | | [`testing-library/no-wait-for-side-effects`](./docs/rules/no-wait-for-side-effects.md) | Disallow the use of side effects in `waitFor` | | | diff --git a/lib/configs/react.ts b/lib/configs/react.ts index b788c414..1c8b3b4b 100644 --- a/lib/configs/react.ts +++ b/lib/configs/react.ts @@ -13,6 +13,7 @@ export = { 'testing-library/no-dom-import': ['error', 'react'], 'testing-library/no-node-access': 'error', 'testing-library/no-promise-in-fire-event': 'error', + 'testing-library/no-unnecessary-act': ['error', { isStrict: true }], 'testing-library/no-wait-for-empty-callback': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-screen-queries': 'error', diff --git a/lib/rules/no-unnecessary-act.ts b/lib/rules/no-unnecessary-act.ts index 4f4f68d4..8fc06f67 100644 --- a/lib/rules/no-unnecessary-act.ts +++ b/lib/rules/no-unnecessary-act.ts @@ -27,7 +27,7 @@ export default createTestingLibraryRule({ recommendedConfig: { dom: false, angular: false, - react: false, + react: ['error', { isStrict: true }], vue: false, }, }, diff --git a/tests/__snapshots__/index.test.ts.snap b/tests/__snapshots__/index.test.ts.snap index 68187baf..bd21457f 100644 --- a/tests/__snapshots__/index.test.ts.snap +++ b/tests/__snapshots__/index.test.ts.snap @@ -54,6 +54,12 @@ Object { ], "testing-library/no-node-access": "error", "testing-library/no-promise-in-fire-event": "error", + "testing-library/no-unnecessary-act": Array [ + "error", + Object { + "isStrict": true, + }, + ], "testing-library/no-wait-for-empty-callback": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error",