From f9f9adde5129953ddfa3bd057dd58b98423d91bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Mon, 6 Sep 2021 10:10:36 +0200 Subject: [PATCH 01/16] chore: bump supported node version (#463) BREAKING CHANGE: Requires Node@^12.22.x || ^14.17.x || >=16.x --- .github/workflows/pipeline.yml | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index dd771bb2..893fcfe9 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -29,7 +29,7 @@ jobs: - name: Use Node uses: actions/setup-node@v2 with: - node-version: 14 + node-version: 16 - name: Install dependencies uses: bahmutov/npm-install@v1 @@ -51,7 +51,7 @@ jobs: strategy: matrix: - node: [10.12, 10, '12.0', 12, 14, 16] + node: [12.22.0, 12, 14.17.0, 14, '16.0', 16] eslint: [7.5, 7] steps: @@ -96,7 +96,7 @@ jobs: - name: Use Node uses: actions/setup-node@v2 with: - node-version: 14 + node-version: 16 - name: Install dependencies uses: bahmutov/npm-install@v1 diff --git a/package.json b/package.json index 979b9b4e..e7adbe47 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "eslint": "^7.5.0" }, "engines": { - "node": "^10.12.0 || >=12.0.0", + "node": "^12.22.0 || ^14.17.0 || >=16.0.0", "npm": ">=6" }, "license": "MIT" From dff67455b6a2896b8b15f12190cff3a7592a156e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Mon, 6 Sep 2021 10:23:23 +0200 Subject: [PATCH 02/16] chore: update dependencies (#464) --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index e7adbe47..694c3ea6 100644 --- a/package.json +++ b/package.json @@ -46,10 +46,10 @@ }, "devDependencies": { "@babel/eslint-plugin": "^7.14.5", - "@commitlint/cli": "^12.1.4", - "@commitlint/config-conventional": "^12.1.4", + "@commitlint/cli": "^13.1.0", + "@commitlint/config-conventional": "^13.1.0", "@types/jest": "^27.0.1", - "@types/node": "^10.17.60", + "@types/node": "^12.20.23", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "cpy-cli": "^3.1.1", From 0338bc36e72f24353d60c8393e022561049571c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Mon, 6 Sep 2021 17:09:41 +0200 Subject: [PATCH 03/16] feat(no-debug): rename to `no-debugging-utils` (#469) BREAKING CHANGE: `no-debug` is now called `no-debugging-utils` --- CONTRIBUTING.md | 10 +++++----- README.md | 4 ++-- docs/rules/{no-debug.md => no-debugging-utils.md} | 4 ++-- lib/configs/angular.ts | 2 +- lib/configs/react.ts | 2 +- lib/configs/vue.ts | 2 +- lib/rules/{no-debug.ts => no-debugging-utils.ts} | 2 +- tests/__snapshots__/index.test.ts.snap | 6 +++--- .../{no-debug.test.ts => no-debugging-utils.test.ts} | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) rename docs/rules/{no-debug.md => no-debugging-utils.md} (91%) rename lib/rules/{no-debug.ts => no-debugging-utils.ts} (99%) rename tests/lib/rules/{no-debug.test.ts => no-debugging-utils.test.ts} (99%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 11044860..6d92df51 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -44,7 +44,7 @@ If you ever need to update a snapshot, you can run `npm run test:update` Based on [ESLint's Rule Naming Conventions](https://eslint.org/docs/developer-guide/working-with-rules#rule-naming-conventions), you must follow these rules: -- If your rule is disallowing something, prefix it with `no-` such as `no-debug` +- If your rule is disallowing something, prefix it with `no-` such as `no-debugging-utils` for disallowing `debug()`. - If your rule is suggesting to prefer a way of doing something, among other ways, you can **optionally** prefix it with `prefer-`. For example, `prefer-screen-queries` suggests to use `screen.getByText()` from imported `screen` rather @@ -57,11 +57,11 @@ Based on [ESLint's Rule Naming Conventions](https://eslint.org/docs/developer-gu ## Adding new rules In the [same way as ESLint](https://eslint.org/docs/developer-guide/working-with-rules), -each rule has three files named with its identifier (e.g. `no-debug`): +each rule has three files named with its identifier (e.g. `no-debugging-utils`): -- in the `lib/rules` directory: a source file (e.g. `no-debug.ts`) -- in the `tests/lib/rules` directory: a test file (e.g. `no-debug.ts`) -- in the `docs/rules` directory: a Markdown documentation file (e.g. `no-debug.md`) +- in the `lib/rules` directory: a source file (e.g. `no-debugging-utils.ts`) +- in the `tests/lib/rules` directory: a test file (e.g. `no-debugging-utils.ts`) +- in the `docs/rules` directory: a Markdown documentation file (e.g. `no-debugging-utils.md`) Additionally, you need to do a couple of extra things: diff --git a/README.md b/README.md index e7fbd779..569777fa 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Then configure the rules you want to use within `rules` property of your `.eslin "rules": { "testing-library/await-async-query": "error", "testing-library/no-await-sync-query": "error", - "testing-library/no-debug": "warn", + "testing-library/no-debugging-utils": "warn", "testing-library/no-dom-import": "off" } } @@ -195,7 +195,7 @@ To enable this configuration use the `extends` property in your | [`testing-library/no-await-sync-events`](./docs/rules/no-await-sync-events.md) | Disallow unnecessary `await` for sync events | | | | [`testing-library/no-await-sync-query`](./docs/rules/no-await-sync-query.md) | Disallow unnecessary `await` for sync queries | | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/no-container`](./docs/rules/no-container.md) | Disallow the use of `container` methods | | ![angular-badge][] ![react-badge][] ![vue-badge][] | -| [`testing-library/no-debug`](./docs/rules/no-debug.md) | Disallow the use of debugging utilities like `debug` | | ![angular-badge][] ![react-badge][] ![vue-badge][] | +| [`testing-library/no-debugging-utils`](./docs/rules/no-debugging-utils.md) | Disallow the use of debugging utilities like `debug` | | ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/no-dom-import`](./docs/rules/no-dom-import.md) | Disallow importing from DOM Testing Library | 🔧 | ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/no-manual-cleanup`](./docs/rules/no-manual-cleanup.md) | Disallow the use of `cleanup` | | | | [`testing-library/no-node-access`](./docs/rules/no-node-access.md) | Disallow direct Node access | | ![angular-badge][] ![react-badge][] ![vue-badge][] | diff --git a/docs/rules/no-debug.md b/docs/rules/no-debugging-utils.md similarity index 91% rename from docs/rules/no-debug.md rename to docs/rules/no-debugging-utils.md index 9ae030dd..7737eb9f 100644 --- a/docs/rules/no-debug.md +++ b/docs/rules/no-debugging-utils.md @@ -1,4 +1,4 @@ -# Disallow the use of debugging utilities like `debug` (`testing-library/no-debug`) +# Disallow the use of debugging utilities (`testing-library/no-debugging-utils`) Just like `console.log` statements pollutes the browser's output, debug statements also pollutes the tests if one of your teammates forgot to remove it. `debug` statements should be used when you actually want to debug your tests but should not be pushed to the codebase. @@ -41,7 +41,7 @@ You can control which debugging utils are checked for with the `utilsToCheckFor` ```json { - "testing-library/no-debug": [ + "testing-library/no-debugging-utils": [ "error", { "utilsToCheckFor": { diff --git a/lib/configs/angular.ts b/lib/configs/angular.ts index 671b496b..ab1060b1 100644 --- a/lib/configs/angular.ts +++ b/lib/configs/angular.ts @@ -9,7 +9,7 @@ export = { 'testing-library/await-async-utils': 'error', 'testing-library/no-await-sync-query': 'error', 'testing-library/no-container': 'error', - 'testing-library/no-debug': 'error', + 'testing-library/no-debugging-utils': 'error', 'testing-library/no-dom-import': ['error', 'angular'], 'testing-library/no-node-access': 'error', 'testing-library/no-promise-in-fire-event': 'error', diff --git a/lib/configs/react.ts b/lib/configs/react.ts index b2161875..b788c414 100644 --- a/lib/configs/react.ts +++ b/lib/configs/react.ts @@ -9,7 +9,7 @@ export = { 'testing-library/await-async-utils': 'error', 'testing-library/no-await-sync-query': 'error', 'testing-library/no-container': 'error', - 'testing-library/no-debug': 'error', + 'testing-library/no-debugging-utils': 'error', 'testing-library/no-dom-import': ['error', 'react'], 'testing-library/no-node-access': 'error', 'testing-library/no-promise-in-fire-event': 'error', diff --git a/lib/configs/vue.ts b/lib/configs/vue.ts index 046bb774..9cb7b0a2 100644 --- a/lib/configs/vue.ts +++ b/lib/configs/vue.ts @@ -10,7 +10,7 @@ export = { 'testing-library/await-fire-event': 'error', 'testing-library/no-await-sync-query': 'error', 'testing-library/no-container': 'error', - 'testing-library/no-debug': 'error', + 'testing-library/no-debugging-utils': 'error', 'testing-library/no-dom-import': ['error', 'vue'], 'testing-library/no-node-access': 'error', 'testing-library/no-promise-in-fire-event': 'error', diff --git a/lib/rules/no-debug.ts b/lib/rules/no-debugging-utils.ts similarity index 99% rename from lib/rules/no-debug.ts rename to lib/rules/no-debugging-utils.ts index a0808154..3f382b5e 100644 --- a/lib/rules/no-debug.ts +++ b/lib/rules/no-debugging-utils.ts @@ -21,7 +21,7 @@ type DebugUtilsToCheckFor = Partial< Record >; -export const RULE_NAME = 'no-debug'; +export const RULE_NAME = 'no-debugging-utils'; export type MessageIds = 'noDebug'; type Options = [{ utilsToCheckFor?: DebugUtilsToCheckFor }]; diff --git a/tests/__snapshots__/index.test.ts.snap b/tests/__snapshots__/index.test.ts.snap index d154465d..68187baf 100644 --- a/tests/__snapshots__/index.test.ts.snap +++ b/tests/__snapshots__/index.test.ts.snap @@ -11,7 +11,7 @@ Object { "testing-library/await-async-utils": "error", "testing-library/no-await-sync-query": "error", "testing-library/no-container": "error", - "testing-library/no-debug": "error", + "testing-library/no-debugging-utils": "error", "testing-library/no-dom-import": Array [ "error", "angular", @@ -47,7 +47,7 @@ Object { "testing-library/await-async-utils": "error", "testing-library/no-await-sync-query": "error", "testing-library/no-container": "error", - "testing-library/no-debug": "error", + "testing-library/no-debugging-utils": "error", "testing-library/no-dom-import": Array [ "error", "react", @@ -70,7 +70,7 @@ Object { "testing-library/await-fire-event": "error", "testing-library/no-await-sync-query": "error", "testing-library/no-container": "error", - "testing-library/no-debug": "error", + "testing-library/no-debugging-utils": "error", "testing-library/no-dom-import": Array [ "error", "vue", diff --git a/tests/lib/rules/no-debug.test.ts b/tests/lib/rules/no-debugging-utils.test.ts similarity index 99% rename from tests/lib/rules/no-debug.test.ts rename to tests/lib/rules/no-debugging-utils.test.ts index aabbfb61..56814597 100644 --- a/tests/lib/rules/no-debug.test.ts +++ b/tests/lib/rules/no-debugging-utils.test.ts @@ -1,4 +1,4 @@ -import rule, { RULE_NAME } from '../../../lib/rules/no-debug'; +import rule, { RULE_NAME } from '../../../lib/rules/no-debugging-utils'; import { createRuleTester } from '../test-utils'; const ruleTester = createRuleTester(); From 8c4620362d08cc2eae4a4d89379da3efd0009e74 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 04/16] 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 569777fa..aa1085ee 100644 --- a/README.md +++ b/README.md @@ -201,7 +201,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", From 887e48914ccdbd28815ba03e12a3784622be1794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Wed, 13 Oct 2021 18:47:11 +0200 Subject: [PATCH 05/16] feat(no-render-in-setup): add to Angular, React & Vue configs by default (#481) BREAKING CHANGE: `no-render-in-setup` is now enabled by default in the Angular, React & Vue configs --- README.md | 2 +- lib/configs/angular.ts | 1 + lib/configs/react.ts | 1 + lib/configs/vue.ts | 1 + lib/rules/no-render-in-setup.ts | 6 +++--- tests/__snapshots__/index.test.ts.snap | 3 +++ 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index aa1085ee..3b710fef 100644 --- a/README.md +++ b/README.md @@ -200,7 +200,7 @@ To enable this configuration use the `extends` property in your | [`testing-library/no-manual-cleanup`](./docs/rules/no-manual-cleanup.md) | Disallow the use of `cleanup` | | | | [`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-render-in-setup`](./docs/rules/no-render-in-setup.md) | Disallow the use of `render` in testing frameworks setup functions | | ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`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` | | | diff --git a/lib/configs/angular.ts b/lib/configs/angular.ts index ab1060b1..606ce334 100644 --- a/lib/configs/angular.ts +++ b/lib/configs/angular.ts @@ -13,6 +13,7 @@ export = { 'testing-library/no-dom-import': ['error', 'angular'], 'testing-library/no-node-access': 'error', 'testing-library/no-promise-in-fire-event': 'error', + 'testing-library/no-render-in-setup': 'error', 'testing-library/no-wait-for-empty-callback': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-screen-queries': 'error', diff --git a/lib/configs/react.ts b/lib/configs/react.ts index 1c8b3b4b..33be2846 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-render-in-setup': 'error', 'testing-library/no-unnecessary-act': ['error', { isStrict: true }], 'testing-library/no-wait-for-empty-callback': 'error', 'testing-library/prefer-find-by': 'error', diff --git a/lib/configs/vue.ts b/lib/configs/vue.ts index 9cb7b0a2..e8129940 100644 --- a/lib/configs/vue.ts +++ b/lib/configs/vue.ts @@ -14,6 +14,7 @@ export = { 'testing-library/no-dom-import': ['error', 'vue'], 'testing-library/no-node-access': 'error', 'testing-library/no-promise-in-fire-event': 'error', + 'testing-library/no-render-in-setup': 'error', '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-render-in-setup.ts b/lib/rules/no-render-in-setup.ts index e5c7f437..89db8ef6 100644 --- a/lib/rules/no-render-in-setup.ts +++ b/lib/rules/no-render-in-setup.ts @@ -53,9 +53,9 @@ export default createTestingLibraryRule({ category: 'Best Practices', recommendedConfig: { dom: false, - angular: false, - react: false, - vue: false, + angular: 'error', + react: 'error', + vue: 'error', }, }, messages: { diff --git a/tests/__snapshots__/index.test.ts.snap b/tests/__snapshots__/index.test.ts.snap index bd21457f..339d0be4 100644 --- a/tests/__snapshots__/index.test.ts.snap +++ b/tests/__snapshots__/index.test.ts.snap @@ -18,6 +18,7 @@ Object { ], "testing-library/no-node-access": "error", "testing-library/no-promise-in-fire-event": "error", + "testing-library/no-render-in-setup": "error", "testing-library/no-wait-for-empty-callback": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error", @@ -54,6 +55,7 @@ Object { ], "testing-library/no-node-access": "error", "testing-library/no-promise-in-fire-event": "error", + "testing-library/no-render-in-setup": "error", "testing-library/no-unnecessary-act": Array [ "error", Object { @@ -83,6 +85,7 @@ Object { ], "testing-library/no-node-access": "error", "testing-library/no-promise-in-fire-event": "error", + "testing-library/no-render-in-setup": "error", "testing-library/no-wait-for-empty-callback": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error", From 8fb3b64f218c78ef6f37298990c314bd788a98ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Wed, 13 Oct 2021 19:00:21 +0200 Subject: [PATCH 06/16] feat(no-wait-for-multiple-assertions): add to all configs by default (#483) BREAKING CHANGE: `no-wait-for-multiple-assertions` is now enabled by default in all configs --- README.md | 2 +- lib/configs/angular.ts | 1 + lib/configs/dom.ts | 1 + lib/configs/react.ts | 1 + lib/configs/vue.ts | 1 + lib/rules/no-wait-for-multiple-assertions.ts | 8 ++++---- tests/__snapshots__/index.test.ts.snap | 4 ++++ 7 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3b710fef..08b58577 100644 --- a/README.md +++ b/README.md @@ -203,7 +203,7 @@ To enable this configuration use the `extends` property in your | [`testing-library/no-render-in-setup`](./docs/rules/no-render-in-setup.md) | Disallow the use of `render` in testing frameworks setup functions | | ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`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-multiple-assertions`](./docs/rules/no-wait-for-multiple-assertions.md) | Disallow the use of multiple `expect` calls inside `waitFor` | | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/no-wait-for-side-effects`](./docs/rules/no-wait-for-side-effects.md) | Disallow the use of side effects in `waitFor` | | | | [`testing-library/no-wait-for-snapshot`](./docs/rules/no-wait-for-snapshot.md) | Ensures no snapshot is generated inside of a `waitFor` call | | | | [`testing-library/prefer-explicit-assert`](./docs/rules/prefer-explicit-assert.md) | Suggest using explicit assertions rather than standalone queries | | | diff --git a/lib/configs/angular.ts b/lib/configs/angular.ts index 606ce334..6a87c5ae 100644 --- a/lib/configs/angular.ts +++ b/lib/configs/angular.ts @@ -15,6 +15,7 @@ export = { 'testing-library/no-promise-in-fire-event': 'error', 'testing-library/no-render-in-setup': 'error', 'testing-library/no-wait-for-empty-callback': 'error', + 'testing-library/no-wait-for-multiple-assertions': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-screen-queries': 'error', 'testing-library/render-result-naming-convention': 'error', diff --git a/lib/configs/dom.ts b/lib/configs/dom.ts index 261cde83..7ed01a78 100644 --- a/lib/configs/dom.ts +++ b/lib/configs/dom.ts @@ -10,6 +10,7 @@ export = { 'testing-library/no-await-sync-query': 'error', 'testing-library/no-promise-in-fire-event': 'error', 'testing-library/no-wait-for-empty-callback': 'error', + 'testing-library/no-wait-for-multiple-assertions': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-screen-queries': 'error', }, diff --git a/lib/configs/react.ts b/lib/configs/react.ts index 33be2846..13ce9685 100644 --- a/lib/configs/react.ts +++ b/lib/configs/react.ts @@ -16,6 +16,7 @@ export = { 'testing-library/no-render-in-setup': 'error', 'testing-library/no-unnecessary-act': ['error', { isStrict: true }], 'testing-library/no-wait-for-empty-callback': 'error', + 'testing-library/no-wait-for-multiple-assertions': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-screen-queries': 'error', 'testing-library/render-result-naming-convention': 'error', diff --git a/lib/configs/vue.ts b/lib/configs/vue.ts index e8129940..d5d6b70d 100644 --- a/lib/configs/vue.ts +++ b/lib/configs/vue.ts @@ -16,6 +16,7 @@ export = { 'testing-library/no-promise-in-fire-event': 'error', 'testing-library/no-render-in-setup': 'error', 'testing-library/no-wait-for-empty-callback': 'error', + 'testing-library/no-wait-for-multiple-assertions': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-screen-queries': 'error', 'testing-library/render-result-naming-convention': 'error', diff --git a/lib/rules/no-wait-for-multiple-assertions.ts b/lib/rules/no-wait-for-multiple-assertions.ts index 86499e89..171dd290 100644 --- a/lib/rules/no-wait-for-multiple-assertions.ts +++ b/lib/rules/no-wait-for-multiple-assertions.ts @@ -19,10 +19,10 @@ export default createTestingLibraryRule({ 'Disallow the use of multiple `expect` calls inside `waitFor`', category: 'Best Practices', recommendedConfig: { - dom: false, - angular: false, - react: false, - vue: false, + dom: 'error', + angular: 'error', + react: 'error', + vue: 'error', }, }, messages: { diff --git a/tests/__snapshots__/index.test.ts.snap b/tests/__snapshots__/index.test.ts.snap index 339d0be4..4333d287 100644 --- a/tests/__snapshots__/index.test.ts.snap +++ b/tests/__snapshots__/index.test.ts.snap @@ -20,6 +20,7 @@ Object { "testing-library/no-promise-in-fire-event": "error", "testing-library/no-render-in-setup": "error", "testing-library/no-wait-for-empty-callback": "error", + "testing-library/no-wait-for-multiple-assertions": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error", "testing-library/render-result-naming-convention": "error", @@ -35,6 +36,7 @@ Object { "testing-library/no-await-sync-query": "error", "testing-library/no-promise-in-fire-event": "error", "testing-library/no-wait-for-empty-callback": "error", + "testing-library/no-wait-for-multiple-assertions": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error", }, @@ -63,6 +65,7 @@ Object { }, ], "testing-library/no-wait-for-empty-callback": "error", + "testing-library/no-wait-for-multiple-assertions": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error", "testing-library/render-result-naming-convention": "error", @@ -87,6 +90,7 @@ Object { "testing-library/no-promise-in-fire-event": "error", "testing-library/no-render-in-setup": "error", "testing-library/no-wait-for-empty-callback": "error", + "testing-library/no-wait-for-multiple-assertions": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error", "testing-library/render-result-naming-convention": "error", From 4cfb3cfff57fe44772cf57d383f8c5664e07ec92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Thu, 14 Oct 2021 00:10:44 +0200 Subject: [PATCH 07/16] chore: bump dev dependencies (#497) --- package.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 694c3ea6..e9edaadd 100644 --- a/package.json +++ b/package.json @@ -46,10 +46,10 @@ }, "devDependencies": { "@babel/eslint-plugin": "^7.14.5", - "@commitlint/cli": "^13.1.0", - "@commitlint/config-conventional": "^13.1.0", - "@types/jest": "^27.0.1", - "@types/node": "^12.20.23", + "@commitlint/cli": "^13.2.1", + "@commitlint/config-conventional": "^13.2.0", + "@types/jest": "^27.0.2", + "@types/node": "^16.10.6", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "cpy-cli": "^3.1.1", @@ -64,13 +64,13 @@ "eslint-plugin-promise": "^5.1.0", "husky": "^7.0.2", "is-ci": "^3.0.0", - "jest": "^27.1.0", - "lint-staged": "^11.1.2", - "prettier": "2.3.2", - "semantic-release": "^17.4.7", + "jest": "^27.2.5", + "lint-staged": "^11.2.3", + "prettier": "2.4.1", + "semantic-release": "^18.0.0", "ts-jest": "27.0.5", - "ts-node": "^10.2.1", - "typescript": "^4.4.2" + "ts-node": "^10.3.0", + "typescript": "^4.4.4" }, "peerDependencies": { "eslint": "^7.5.0" From 0b35c14aa1572b5cfc97a329ceb716ff758071c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Thu, 14 Oct 2021 00:25:05 +0200 Subject: [PATCH 08/16] feat(no-wait-for-side-effects): add to all configs by default (#484) BREAKING CHANGE: `no-wait-for-side-effects` is now enabled by default in all configs --- README.md | 2 +- lib/configs/angular.ts | 1 + lib/configs/dom.ts | 1 + lib/configs/react.ts | 1 + lib/configs/vue.ts | 1 + lib/rules/no-wait-for-side-effects.ts | 8 ++++---- tests/__snapshots__/index.test.ts.snap | 4 ++++ 7 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 08b58577..76f4b8ae 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,7 @@ To enable this configuration use the `extends` property in your | [`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` | | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | -| [`testing-library/no-wait-for-side-effects`](./docs/rules/no-wait-for-side-effects.md) | Disallow the use of side effects in `waitFor` | | | +| [`testing-library/no-wait-for-side-effects`](./docs/rules/no-wait-for-side-effects.md) | Disallow the use of side effects in `waitFor` | | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/no-wait-for-snapshot`](./docs/rules/no-wait-for-snapshot.md) | Ensures no snapshot is generated inside of a `waitFor` call | | | | [`testing-library/prefer-explicit-assert`](./docs/rules/prefer-explicit-assert.md) | Suggest using explicit assertions rather than standalone queries | | | | [`testing-library/prefer-find-by`](./docs/rules/prefer-find-by.md) | Suggest using `find(All)By*` query instead of `waitFor` + `get(All)By*` to wait for elements | 🔧 | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | diff --git a/lib/configs/angular.ts b/lib/configs/angular.ts index 6a87c5ae..8d51b982 100644 --- a/lib/configs/angular.ts +++ b/lib/configs/angular.ts @@ -16,6 +16,7 @@ export = { 'testing-library/no-render-in-setup': 'error', 'testing-library/no-wait-for-empty-callback': 'error', 'testing-library/no-wait-for-multiple-assertions': 'error', + 'testing-library/no-wait-for-side-effects': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-screen-queries': 'error', 'testing-library/render-result-naming-convention': 'error', diff --git a/lib/configs/dom.ts b/lib/configs/dom.ts index 7ed01a78..3a31719a 100644 --- a/lib/configs/dom.ts +++ b/lib/configs/dom.ts @@ -11,6 +11,7 @@ export = { 'testing-library/no-promise-in-fire-event': 'error', 'testing-library/no-wait-for-empty-callback': 'error', 'testing-library/no-wait-for-multiple-assertions': 'error', + 'testing-library/no-wait-for-side-effects': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-screen-queries': 'error', }, diff --git a/lib/configs/react.ts b/lib/configs/react.ts index 13ce9685..e2a76b94 100644 --- a/lib/configs/react.ts +++ b/lib/configs/react.ts @@ -17,6 +17,7 @@ export = { 'testing-library/no-unnecessary-act': ['error', { isStrict: true }], 'testing-library/no-wait-for-empty-callback': 'error', 'testing-library/no-wait-for-multiple-assertions': 'error', + 'testing-library/no-wait-for-side-effects': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-screen-queries': 'error', 'testing-library/render-result-naming-convention': 'error', diff --git a/lib/configs/vue.ts b/lib/configs/vue.ts index d5d6b70d..b42f56d9 100644 --- a/lib/configs/vue.ts +++ b/lib/configs/vue.ts @@ -17,6 +17,7 @@ export = { 'testing-library/no-render-in-setup': 'error', 'testing-library/no-wait-for-empty-callback': 'error', 'testing-library/no-wait-for-multiple-assertions': 'error', + 'testing-library/no-wait-for-side-effects': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-screen-queries': 'error', 'testing-library/render-result-naming-convention': 'error', diff --git a/lib/rules/no-wait-for-side-effects.ts b/lib/rules/no-wait-for-side-effects.ts index 06bc34d9..2049f907 100644 --- a/lib/rules/no-wait-for-side-effects.ts +++ b/lib/rules/no-wait-for-side-effects.ts @@ -22,10 +22,10 @@ export default createTestingLibraryRule({ description: 'Disallow the use of side effects in `waitFor`', category: 'Best Practices', recommendedConfig: { - dom: false, - angular: false, - react: false, - vue: false, + dom: 'error', + angular: 'error', + react: 'error', + vue: 'error', }, }, messages: { diff --git a/tests/__snapshots__/index.test.ts.snap b/tests/__snapshots__/index.test.ts.snap index 4333d287..4e12f2a6 100644 --- a/tests/__snapshots__/index.test.ts.snap +++ b/tests/__snapshots__/index.test.ts.snap @@ -21,6 +21,7 @@ Object { "testing-library/no-render-in-setup": "error", "testing-library/no-wait-for-empty-callback": "error", "testing-library/no-wait-for-multiple-assertions": "error", + "testing-library/no-wait-for-side-effects": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error", "testing-library/render-result-naming-convention": "error", @@ -37,6 +38,7 @@ Object { "testing-library/no-promise-in-fire-event": "error", "testing-library/no-wait-for-empty-callback": "error", "testing-library/no-wait-for-multiple-assertions": "error", + "testing-library/no-wait-for-side-effects": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error", }, @@ -66,6 +68,7 @@ Object { ], "testing-library/no-wait-for-empty-callback": "error", "testing-library/no-wait-for-multiple-assertions": "error", + "testing-library/no-wait-for-side-effects": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error", "testing-library/render-result-naming-convention": "error", @@ -91,6 +94,7 @@ Object { "testing-library/no-render-in-setup": "error", "testing-library/no-wait-for-empty-callback": "error", "testing-library/no-wait-for-multiple-assertions": "error", + "testing-library/no-wait-for-side-effects": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error", "testing-library/render-result-naming-convention": "error", From e0a34edd15f620e399640c54ae1bace0716da94a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Thu, 14 Oct 2021 00:50:22 +0200 Subject: [PATCH 09/16] feat(no-wait-for-snapshot): add to all configs by default (#485) BREAKING CHANGE: `no-wait-for-snapshot` is now enabled by default in all configs --- README.md | 2 +- lib/configs/angular.ts | 1 + lib/configs/dom.ts | 1 + lib/configs/react.ts | 1 + lib/configs/vue.ts | 1 + lib/rules/no-wait-for-snapshot.ts | 8 ++++---- tests/__snapshots__/index.test.ts.snap | 4 ++++ 7 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 76f4b8ae..8b859d8c 100644 --- a/README.md +++ b/README.md @@ -205,7 +205,7 @@ To enable this configuration use the `extends` property in your | [`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` | | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/no-wait-for-side-effects`](./docs/rules/no-wait-for-side-effects.md) | Disallow the use of side effects in `waitFor` | | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | -| [`testing-library/no-wait-for-snapshot`](./docs/rules/no-wait-for-snapshot.md) | Ensures no snapshot is generated inside of a `waitFor` call | | | +| [`testing-library/no-wait-for-snapshot`](./docs/rules/no-wait-for-snapshot.md) | Ensures no snapshot is generated inside of a `waitFor` call | | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/prefer-explicit-assert`](./docs/rules/prefer-explicit-assert.md) | Suggest using explicit assertions rather than standalone queries | | | | [`testing-library/prefer-find-by`](./docs/rules/prefer-find-by.md) | Suggest using `find(All)By*` query instead of `waitFor` + `get(All)By*` to wait for elements | 🔧 | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/prefer-presence-queries`](./docs/rules/prefer-presence-queries.md) | Ensure appropriate `get*`/`query*` queries are used with their respective matchers | | | diff --git a/lib/configs/angular.ts b/lib/configs/angular.ts index 8d51b982..564f4ee3 100644 --- a/lib/configs/angular.ts +++ b/lib/configs/angular.ts @@ -17,6 +17,7 @@ export = { 'testing-library/no-wait-for-empty-callback': 'error', 'testing-library/no-wait-for-multiple-assertions': 'error', 'testing-library/no-wait-for-side-effects': 'error', + 'testing-library/no-wait-for-snapshot': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-screen-queries': 'error', 'testing-library/render-result-naming-convention': 'error', diff --git a/lib/configs/dom.ts b/lib/configs/dom.ts index 3a31719a..4f776c7f 100644 --- a/lib/configs/dom.ts +++ b/lib/configs/dom.ts @@ -12,6 +12,7 @@ export = { 'testing-library/no-wait-for-empty-callback': 'error', 'testing-library/no-wait-for-multiple-assertions': 'error', 'testing-library/no-wait-for-side-effects': 'error', + 'testing-library/no-wait-for-snapshot': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-screen-queries': 'error', }, diff --git a/lib/configs/react.ts b/lib/configs/react.ts index e2a76b94..9ad4f20f 100644 --- a/lib/configs/react.ts +++ b/lib/configs/react.ts @@ -18,6 +18,7 @@ export = { 'testing-library/no-wait-for-empty-callback': 'error', 'testing-library/no-wait-for-multiple-assertions': 'error', 'testing-library/no-wait-for-side-effects': 'error', + 'testing-library/no-wait-for-snapshot': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-screen-queries': 'error', 'testing-library/render-result-naming-convention': 'error', diff --git a/lib/configs/vue.ts b/lib/configs/vue.ts index b42f56d9..b860eb07 100644 --- a/lib/configs/vue.ts +++ b/lib/configs/vue.ts @@ -18,6 +18,7 @@ export = { 'testing-library/no-wait-for-empty-callback': 'error', 'testing-library/no-wait-for-multiple-assertions': 'error', 'testing-library/no-wait-for-side-effects': 'error', + 'testing-library/no-wait-for-snapshot': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-screen-queries': 'error', 'testing-library/render-result-naming-convention': 'error', diff --git a/lib/rules/no-wait-for-snapshot.ts b/lib/rules/no-wait-for-snapshot.ts index 0c78f30d..9b7ddd01 100644 --- a/lib/rules/no-wait-for-snapshot.ts +++ b/lib/rules/no-wait-for-snapshot.ts @@ -21,10 +21,10 @@ export default createTestingLibraryRule({ 'Ensures no snapshot is generated inside of a `waitFor` call', category: 'Best Practices', recommendedConfig: { - dom: false, - angular: false, - react: false, - vue: false, + dom: 'error', + angular: 'error', + react: 'error', + vue: 'error', }, }, messages: { diff --git a/tests/__snapshots__/index.test.ts.snap b/tests/__snapshots__/index.test.ts.snap index 4e12f2a6..53f87f59 100644 --- a/tests/__snapshots__/index.test.ts.snap +++ b/tests/__snapshots__/index.test.ts.snap @@ -22,6 +22,7 @@ Object { "testing-library/no-wait-for-empty-callback": "error", "testing-library/no-wait-for-multiple-assertions": "error", "testing-library/no-wait-for-side-effects": "error", + "testing-library/no-wait-for-snapshot": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error", "testing-library/render-result-naming-convention": "error", @@ -39,6 +40,7 @@ Object { "testing-library/no-wait-for-empty-callback": "error", "testing-library/no-wait-for-multiple-assertions": "error", "testing-library/no-wait-for-side-effects": "error", + "testing-library/no-wait-for-snapshot": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error", }, @@ -69,6 +71,7 @@ Object { "testing-library/no-wait-for-empty-callback": "error", "testing-library/no-wait-for-multiple-assertions": "error", "testing-library/no-wait-for-side-effects": "error", + "testing-library/no-wait-for-snapshot": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error", "testing-library/render-result-naming-convention": "error", @@ -95,6 +98,7 @@ Object { "testing-library/no-wait-for-empty-callback": "error", "testing-library/no-wait-for-multiple-assertions": "error", "testing-library/no-wait-for-side-effects": "error", + "testing-library/no-wait-for-snapshot": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-screen-queries": "error", "testing-library/render-result-naming-convention": "error", From 17d5376403582fbb2d369f66c7b9d269cb2796ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Thu, 14 Oct 2021 00:55:27 +0200 Subject: [PATCH 10/16] feat(prefer-presence-queries): add to all configs by default (#486) BREAKING CHANGE: `prefer-presence-queries` is now enabled by default in all configs --- README.md | 2 +- lib/configs/angular.ts | 1 + lib/configs/dom.ts | 1 + lib/configs/react.ts | 1 + lib/configs/vue.ts | 1 + lib/rules/prefer-presence-queries.ts | 8 ++++---- tests/__snapshots__/index.test.ts.snap | 4 ++++ 7 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8b859d8c..4fab0e47 100644 --- a/README.md +++ b/README.md @@ -208,7 +208,7 @@ To enable this configuration use the `extends` property in your | [`testing-library/no-wait-for-snapshot`](./docs/rules/no-wait-for-snapshot.md) | Ensures no snapshot is generated inside of a `waitFor` call | | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/prefer-explicit-assert`](./docs/rules/prefer-explicit-assert.md) | Suggest using explicit assertions rather than standalone queries | | | | [`testing-library/prefer-find-by`](./docs/rules/prefer-find-by.md) | Suggest using `find(All)By*` query instead of `waitFor` + `get(All)By*` to wait for elements | 🔧 | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | -| [`testing-library/prefer-presence-queries`](./docs/rules/prefer-presence-queries.md) | Ensure appropriate `get*`/`query*` queries are used with their respective matchers | | | +| [`testing-library/prefer-presence-queries`](./docs/rules/prefer-presence-queries.md) | Ensure appropriate `get*`/`query*` queries are used with their respective matchers | | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/prefer-query-by-disappearance`](./docs/rules/prefer-query-by-disappearance.md) | Suggest using `queryBy*` queries when waiting for disappearance | | | | [`testing-library/prefer-screen-queries`](./docs/rules/prefer-screen-queries.md) | Suggest using `screen` while querying | | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/prefer-user-event`](./docs/rules/prefer-user-event.md) | Suggest using `userEvent` over `fireEvent` for simulating user interactions | | | diff --git a/lib/configs/angular.ts b/lib/configs/angular.ts index 564f4ee3..066e5d45 100644 --- a/lib/configs/angular.ts +++ b/lib/configs/angular.ts @@ -19,6 +19,7 @@ export = { 'testing-library/no-wait-for-side-effects': 'error', 'testing-library/no-wait-for-snapshot': 'error', 'testing-library/prefer-find-by': 'error', + 'testing-library/prefer-presence-queries': 'error', 'testing-library/prefer-screen-queries': 'error', 'testing-library/render-result-naming-convention': 'error', }, diff --git a/lib/configs/dom.ts b/lib/configs/dom.ts index 4f776c7f..935fd36e 100644 --- a/lib/configs/dom.ts +++ b/lib/configs/dom.ts @@ -14,6 +14,7 @@ export = { 'testing-library/no-wait-for-side-effects': 'error', 'testing-library/no-wait-for-snapshot': 'error', 'testing-library/prefer-find-by': 'error', + 'testing-library/prefer-presence-queries': 'error', 'testing-library/prefer-screen-queries': 'error', }, }; diff --git a/lib/configs/react.ts b/lib/configs/react.ts index 9ad4f20f..9f509ce3 100644 --- a/lib/configs/react.ts +++ b/lib/configs/react.ts @@ -20,6 +20,7 @@ export = { 'testing-library/no-wait-for-side-effects': 'error', 'testing-library/no-wait-for-snapshot': 'error', 'testing-library/prefer-find-by': 'error', + 'testing-library/prefer-presence-queries': 'error', 'testing-library/prefer-screen-queries': 'error', 'testing-library/render-result-naming-convention': 'error', }, diff --git a/lib/configs/vue.ts b/lib/configs/vue.ts index b860eb07..5b637a80 100644 --- a/lib/configs/vue.ts +++ b/lib/configs/vue.ts @@ -20,6 +20,7 @@ export = { 'testing-library/no-wait-for-side-effects': 'error', 'testing-library/no-wait-for-snapshot': 'error', 'testing-library/prefer-find-by': 'error', + 'testing-library/prefer-presence-queries': 'error', 'testing-library/prefer-screen-queries': 'error', 'testing-library/render-result-naming-convention': 'error', }, diff --git a/lib/rules/prefer-presence-queries.ts b/lib/rules/prefer-presence-queries.ts index 1b8839c4..d07bf999 100644 --- a/lib/rules/prefer-presence-queries.ts +++ b/lib/rules/prefer-presence-queries.ts @@ -15,10 +15,10 @@ export default createTestingLibraryRule({ description: 'Ensure appropriate `get*`/`query*` queries are used with their respective matchers', recommendedConfig: { - dom: false, - angular: false, - react: false, - vue: false, + dom: 'error', + angular: 'error', + react: 'error', + vue: 'error', }, }, messages: { diff --git a/tests/__snapshots__/index.test.ts.snap b/tests/__snapshots__/index.test.ts.snap index 53f87f59..0d9a6eb9 100644 --- a/tests/__snapshots__/index.test.ts.snap +++ b/tests/__snapshots__/index.test.ts.snap @@ -24,6 +24,7 @@ Object { "testing-library/no-wait-for-side-effects": "error", "testing-library/no-wait-for-snapshot": "error", "testing-library/prefer-find-by": "error", + "testing-library/prefer-presence-queries": "error", "testing-library/prefer-screen-queries": "error", "testing-library/render-result-naming-convention": "error", }, @@ -42,6 +43,7 @@ Object { "testing-library/no-wait-for-side-effects": "error", "testing-library/no-wait-for-snapshot": "error", "testing-library/prefer-find-by": "error", + "testing-library/prefer-presence-queries": "error", "testing-library/prefer-screen-queries": "error", }, }, @@ -73,6 +75,7 @@ Object { "testing-library/no-wait-for-side-effects": "error", "testing-library/no-wait-for-snapshot": "error", "testing-library/prefer-find-by": "error", + "testing-library/prefer-presence-queries": "error", "testing-library/prefer-screen-queries": "error", "testing-library/render-result-naming-convention": "error", }, @@ -100,6 +103,7 @@ Object { "testing-library/no-wait-for-side-effects": "error", "testing-library/no-wait-for-snapshot": "error", "testing-library/prefer-find-by": "error", + "testing-library/prefer-presence-queries": "error", "testing-library/prefer-screen-queries": "error", "testing-library/render-result-naming-convention": "error", }, From ea893cc1f8851770c1ce53c191cd9d5424487edf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Thu, 14 Oct 2021 01:02:19 +0200 Subject: [PATCH 11/16] feat(prefer-query-by-disappearance): add to all configs by default (#487) BREAKING CHANGE: `prefer-query-by-disappearance` is now enabled by default in all configs --- README.md | 2 +- lib/configs/angular.ts | 1 + lib/configs/dom.ts | 1 + lib/configs/react.ts | 1 + lib/configs/vue.ts | 1 + lib/rules/prefer-query-by-disappearance.ts | 8 ++++---- tests/__snapshots__/index.test.ts.snap | 4 ++++ 7 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4fab0e47..f3cd4eaa 100644 --- a/README.md +++ b/README.md @@ -209,7 +209,7 @@ To enable this configuration use the `extends` property in your | [`testing-library/prefer-explicit-assert`](./docs/rules/prefer-explicit-assert.md) | Suggest using explicit assertions rather than standalone queries | | | | [`testing-library/prefer-find-by`](./docs/rules/prefer-find-by.md) | Suggest using `find(All)By*` query instead of `waitFor` + `get(All)By*` to wait for elements | 🔧 | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/prefer-presence-queries`](./docs/rules/prefer-presence-queries.md) | Ensure appropriate `get*`/`query*` queries are used with their respective matchers | | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | -| [`testing-library/prefer-query-by-disappearance`](./docs/rules/prefer-query-by-disappearance.md) | Suggest using `queryBy*` queries when waiting for disappearance | | | +| [`testing-library/prefer-query-by-disappearance`](./docs/rules/prefer-query-by-disappearance.md) | Suggest using `queryBy*` queries when waiting for disappearance | | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/prefer-screen-queries`](./docs/rules/prefer-screen-queries.md) | Suggest using `screen` while querying | | ![dom-badge][] ![angular-badge][] ![react-badge][] ![vue-badge][] | | [`testing-library/prefer-user-event`](./docs/rules/prefer-user-event.md) | Suggest using `userEvent` over `fireEvent` for simulating user interactions | | | | [`testing-library/prefer-wait-for`](./docs/rules/prefer-wait-for.md) | Use `waitFor` instead of deprecated wait methods | 🔧 | | diff --git a/lib/configs/angular.ts b/lib/configs/angular.ts index 066e5d45..af9b277c 100644 --- a/lib/configs/angular.ts +++ b/lib/configs/angular.ts @@ -20,6 +20,7 @@ export = { 'testing-library/no-wait-for-snapshot': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-presence-queries': 'error', + 'testing-library/prefer-query-by-disappearance': 'error', 'testing-library/prefer-screen-queries': 'error', 'testing-library/render-result-naming-convention': 'error', }, diff --git a/lib/configs/dom.ts b/lib/configs/dom.ts index 935fd36e..ce153733 100644 --- a/lib/configs/dom.ts +++ b/lib/configs/dom.ts @@ -15,6 +15,7 @@ export = { 'testing-library/no-wait-for-snapshot': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-presence-queries': 'error', + 'testing-library/prefer-query-by-disappearance': 'error', 'testing-library/prefer-screen-queries': 'error', }, }; diff --git a/lib/configs/react.ts b/lib/configs/react.ts index 9f509ce3..81fb1a8c 100644 --- a/lib/configs/react.ts +++ b/lib/configs/react.ts @@ -21,6 +21,7 @@ export = { 'testing-library/no-wait-for-snapshot': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-presence-queries': 'error', + 'testing-library/prefer-query-by-disappearance': 'error', 'testing-library/prefer-screen-queries': 'error', 'testing-library/render-result-naming-convention': 'error', }, diff --git a/lib/configs/vue.ts b/lib/configs/vue.ts index 5b637a80..cf9e42bb 100644 --- a/lib/configs/vue.ts +++ b/lib/configs/vue.ts @@ -21,6 +21,7 @@ export = { 'testing-library/no-wait-for-snapshot': 'error', 'testing-library/prefer-find-by': 'error', 'testing-library/prefer-presence-queries': 'error', + 'testing-library/prefer-query-by-disappearance': 'error', 'testing-library/prefer-screen-queries': 'error', 'testing-library/render-result-naming-convention': 'error', }, diff --git a/lib/rules/prefer-query-by-disappearance.ts b/lib/rules/prefer-query-by-disappearance.ts index e65f9db7..cc2d6671 100644 --- a/lib/rules/prefer-query-by-disappearance.ts +++ b/lib/rules/prefer-query-by-disappearance.ts @@ -25,10 +25,10 @@ export default createTestingLibraryRule({ 'Suggest using `queryBy*` queries when waiting for disappearance', category: 'Possible Errors', recommendedConfig: { - dom: false, - angular: false, - react: false, - vue: false, + dom: 'error', + angular: 'error', + react: 'error', + vue: 'error', }, }, messages: { diff --git a/tests/__snapshots__/index.test.ts.snap b/tests/__snapshots__/index.test.ts.snap index 0d9a6eb9..e67072cd 100644 --- a/tests/__snapshots__/index.test.ts.snap +++ b/tests/__snapshots__/index.test.ts.snap @@ -25,6 +25,7 @@ Object { "testing-library/no-wait-for-snapshot": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-presence-queries": "error", + "testing-library/prefer-query-by-disappearance": "error", "testing-library/prefer-screen-queries": "error", "testing-library/render-result-naming-convention": "error", }, @@ -44,6 +45,7 @@ Object { "testing-library/no-wait-for-snapshot": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-presence-queries": "error", + "testing-library/prefer-query-by-disappearance": "error", "testing-library/prefer-screen-queries": "error", }, }, @@ -76,6 +78,7 @@ Object { "testing-library/no-wait-for-snapshot": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-presence-queries": "error", + "testing-library/prefer-query-by-disappearance": "error", "testing-library/prefer-screen-queries": "error", "testing-library/render-result-naming-convention": "error", }, @@ -104,6 +107,7 @@ Object { "testing-library/no-wait-for-snapshot": "error", "testing-library/prefer-find-by": "error", "testing-library/prefer-presence-queries": "error", + "testing-library/prefer-query-by-disappearance": "error", "testing-library/prefer-screen-queries": "error", "testing-library/render-result-naming-convention": "error", }, From e3ebef8763f11cf522bc00e6559b9c64db170562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Thu, 14 Oct 2021 03:21:22 +0200 Subject: [PATCH 12/16] feat(no-unnecessary-act): make `isStrict` option `true` by default (#479) --- lib/configs/react.ts | 2 +- lib/rules/no-unnecessary-act.ts | 11 +++++---- tests/__snapshots__/index.test.ts.snap | 7 +----- tests/lib/rules/no-unnecessary-act.test.ts | 28 ++++++++++------------ 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/lib/configs/react.ts b/lib/configs/react.ts index 81fb1a8c..5e2bc966 100644 --- a/lib/configs/react.ts +++ b/lib/configs/react.ts @@ -14,7 +14,7 @@ export = { 'testing-library/no-node-access': 'error', 'testing-library/no-promise-in-fire-event': 'error', 'testing-library/no-render-in-setup': 'error', - 'testing-library/no-unnecessary-act': ['error', { isStrict: true }], + 'testing-library/no-unnecessary-act': 'error', 'testing-library/no-wait-for-empty-callback': 'error', 'testing-library/no-wait-for-multiple-assertions': 'error', 'testing-library/no-wait-for-side-effects': 'error', diff --git a/lib/rules/no-unnecessary-act.ts b/lib/rules/no-unnecessary-act.ts index 8fc06f67..5bdf4fd2 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: ['error', { isStrict: true }], + react: 'error', vue: false, }, }, @@ -40,18 +40,20 @@ export default createTestingLibraryRule({ { type: 'object', properties: { - isStrict: { type: 'boolean' }, + isStrict: { + type: 'boolean', + }, }, }, ], }, defaultOptions: [ { - isStrict: false, + isStrict: true, }, ], - create(context, [options], helpers) { + create(context, [{ isStrict = true }], helpers) { function getStatementIdentifier(statement: TSESTree.Statement) { const callExpression = getStatementCallExpression(statement); @@ -113,7 +115,6 @@ export default createTestingLibraryRule({ function checkNoUnnecessaryActFromBlockStatement( blockStatementNode: TSESTree.BlockStatement ) { - const { isStrict } = options; const functionNode = blockStatementNode.parent as | TSESTree.ArrowFunctionExpression | TSESTree.FunctionExpression diff --git a/tests/__snapshots__/index.test.ts.snap b/tests/__snapshots__/index.test.ts.snap index e67072cd..d800dee4 100644 --- a/tests/__snapshots__/index.test.ts.snap +++ b/tests/__snapshots__/index.test.ts.snap @@ -66,12 +66,7 @@ Object { "testing-library/no-node-access": "error", "testing-library/no-promise-in-fire-event": "error", "testing-library/no-render-in-setup": "error", - "testing-library/no-unnecessary-act": Array [ - "error", - Object { - "isStrict": true, - }, - ], + "testing-library/no-unnecessary-act": "error", "testing-library/no-wait-for-empty-callback": "error", "testing-library/no-wait-for-multiple-assertions": "error", "testing-library/no-wait-for-side-effects": "error", diff --git a/tests/lib/rules/no-unnecessary-act.test.ts b/tests/lib/rules/no-unnecessary-act.test.ts index 0a372f3f..62407e30 100644 --- a/tests/lib/rules/no-unnecessary-act.test.ts +++ b/tests/lib/rules/no-unnecessary-act.test.ts @@ -13,15 +13,18 @@ type ValidTestCase = TSESLint.ValidTestCase; type InvalidTestCase = TSESLint.InvalidTestCase; type TestCase = InvalidTestCase | ValidTestCase; -const enableStrict = (array: T[]): T[] => +const addOptions = ( + array: T[], + options?: Options[number] +): T[] => array.map((testCase) => ({ ...testCase, - options: [ - { - isStrict: true, - }, - ], + options: [options], })); +const disableStrict = (array: T[]): T[] => + addOptions(array, { isStrict: false }); +const enableStrict = (array: T[]): T[] => + addOptions(array, { isStrict: true }); /** * - AGR stands for Aggressive Reporting @@ -208,11 +211,6 @@ const validTestCases: ValidTestCase[] = [ const invalidStrictTestCases: InvalidTestCase[] = [ { - options: [ - { - isStrict: true, - }, - ], code: `// case: RTL act wrapping both RTL and non-RTL calls with strict option import { act, render } from '@testing-library/react' @@ -886,12 +884,12 @@ const invalidTestCases: InvalidTestCase[] = [ ruleTester.run(RULE_NAME, rule, { valid: [ ...validTestCases, - ...validNonStrictTestCases, - ...enableStrict(validTestCases), + ...disableStrict(validNonStrictTestCases), + ...disableStrict(validTestCases), ], invalid: [ ...invalidTestCases, - ...invalidStrictTestCases, - ...enableStrict(invalidTestCases), + ...enableStrict(invalidStrictTestCases), + ...disableStrict(invalidTestCases), ], }); From 5b03edb47e7f1ede556e69baadbe0b0f0304d8af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sun, 17 Oct 2021 16:00:56 +0200 Subject: [PATCH 13/16] feat: support ESLint v8 (#465) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: support ESLint 8.x * feat: support ESLint 8.x * chore: downgrade ESLint to v7 in dev deps * ci: force deps installation for running tests Co-authored-by: Mario Beltrán Alarcón --- .github/workflows/pipeline.yml | 6 ++++-- lib/rules/await-async-query.ts | 1 - lib/rules/await-async-utils.ts | 1 - lib/rules/await-fire-event.ts | 1 - lib/rules/consistent-data-testid.ts | 1 - lib/rules/no-await-sync-events.ts | 1 - lib/rules/no-await-sync-query.ts | 1 - lib/rules/no-container.ts | 1 - lib/rules/no-debugging-utils.ts | 1 - lib/rules/no-dom-import.ts | 1 - lib/rules/no-manual-cleanup.ts | 1 - lib/rules/no-node-access.ts | 1 - lib/rules/no-promise-in-fire-event.ts | 1 - lib/rules/no-render-in-setup.ts | 1 - lib/rules/no-unnecessary-act.ts | 1 - lib/rules/no-wait-for-empty-callback.ts | 1 - lib/rules/no-wait-for-multiple-assertions.ts | 1 - lib/rules/no-wait-for-side-effects.ts | 1 - lib/rules/no-wait-for-snapshot.ts | 1 - lib/rules/prefer-explicit-assert.ts | 1 - lib/rules/prefer-find-by.ts | 1 - lib/rules/prefer-presence-queries.ts | 1 - lib/rules/prefer-query-by-disappearance.ts | 1 - lib/rules/prefer-screen-queries.ts | 1 - lib/rules/prefer-user-event.ts | 1 - lib/rules/prefer-wait-for.ts | 1 - lib/rules/render-result-naming-convention.ts | 1 - package.json | 16 ++++++++-------- tests/fake-rule.ts | 1 - 29 files changed, 12 insertions(+), 37 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 893fcfe9..a1e12a94 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -52,7 +52,7 @@ jobs: strategy: matrix: node: [12.22.0, 12, 14.17.0, 14, '16.0', 16] - eslint: [7.5, 7] + eslint: [7.5, 7, 8] steps: - name: Cancel Previous Runs @@ -72,7 +72,9 @@ jobs: useLockFile: false - name: Install ESLint v${{ matrix.eslint }} - run: npm install --no-save eslint@${{ matrix.eslint }} + # force installation for now until we get ESLint and all plugins updated + # in dev dependencies + run: npm install --no-save --force eslint@${{ matrix.eslint }} - name: Run tests run: npm run test:ci diff --git a/lib/rules/await-async-query.ts b/lib/rules/await-async-query.ts index c3860452..90be4e9f 100644 --- a/lib/rules/await-async-query.ts +++ b/lib/rules/await-async-query.ts @@ -20,7 +20,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Enforce promises from async queries to be handled', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/await-async-utils.ts b/lib/rules/await-async-utils.ts index 6206fe1e..1f23e9fa 100644 --- a/lib/rules/await-async-utils.ts +++ b/lib/rules/await-async-utils.ts @@ -19,7 +19,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Enforce promises from async utils to be awaited properly', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/await-fire-event.ts b/lib/rules/await-fire-event.ts index 912086f2..e6a70568 100644 --- a/lib/rules/await-fire-event.ts +++ b/lib/rules/await-fire-event.ts @@ -19,7 +19,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Enforce promises from `fireEvent` methods to be handled', - category: 'Best Practices', recommendedConfig: { dom: false, angular: false, diff --git a/lib/rules/consistent-data-testid.ts b/lib/rules/consistent-data-testid.ts index e799acd0..ed462367 100644 --- a/lib/rules/consistent-data-testid.ts +++ b/lib/rules/consistent-data-testid.ts @@ -18,7 +18,6 @@ export default createTestingLibraryRule({ type: 'suggestion', docs: { description: 'Ensures consistent usage of `data-testid`', - category: 'Best Practices', recommendedConfig: { dom: false, angular: false, diff --git a/lib/rules/no-await-sync-events.ts b/lib/rules/no-await-sync-events.ts index bdb407ab..87753dc6 100644 --- a/lib/rules/no-await-sync-events.ts +++ b/lib/rules/no-await-sync-events.ts @@ -21,7 +21,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Disallow unnecessary `await` for sync events', - category: 'Best Practices', recommendedConfig: { dom: false, angular: false, diff --git a/lib/rules/no-await-sync-query.ts b/lib/rules/no-await-sync-query.ts index 5e71c9fc..1797aa9d 100644 --- a/lib/rules/no-await-sync-query.ts +++ b/lib/rules/no-await-sync-query.ts @@ -13,7 +13,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Disallow unnecessary `await` for sync queries', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/no-container.ts b/lib/rules/no-container.ts index 3da280b3..e64af6ca 100644 --- a/lib/rules/no-container.ts +++ b/lib/rules/no-container.ts @@ -20,7 +20,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Disallow the use of `container` methods', - category: 'Best Practices', recommendedConfig: { dom: false, angular: 'error', diff --git a/lib/rules/no-debugging-utils.ts b/lib/rules/no-debugging-utils.ts index 3f382b5e..a6357cd5 100644 --- a/lib/rules/no-debugging-utils.ts +++ b/lib/rules/no-debugging-utils.ts @@ -31,7 +31,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Disallow the use of debugging utilities like `debug`', - category: 'Best Practices', recommendedConfig: { dom: false, angular: 'error', diff --git a/lib/rules/no-dom-import.ts b/lib/rules/no-dom-import.ts index 5298eea2..9ae585ee 100644 --- a/lib/rules/no-dom-import.ts +++ b/lib/rules/no-dom-import.ts @@ -18,7 +18,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Disallow importing from DOM Testing Library', - category: 'Best Practices', recommendedConfig: { dom: false, angular: ['error', 'angular'], diff --git a/lib/rules/no-manual-cleanup.ts b/lib/rules/no-manual-cleanup.ts index 506dc9c8..45d4a1c2 100644 --- a/lib/rules/no-manual-cleanup.ts +++ b/lib/rules/no-manual-cleanup.ts @@ -29,7 +29,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Disallow the use of `cleanup`', - category: 'Best Practices', recommendedConfig: { dom: false, angular: false, diff --git a/lib/rules/no-node-access.ts b/lib/rules/no-node-access.ts index a9e4ce4e..36d232be 100644 --- a/lib/rules/no-node-access.ts +++ b/lib/rules/no-node-access.ts @@ -13,7 +13,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Disallow direct Node access', - category: 'Best Practices', recommendedConfig: { dom: false, angular: 'error', diff --git a/lib/rules/no-promise-in-fire-event.ts b/lib/rules/no-promise-in-fire-event.ts index ea1c6f8b..01027201 100644 --- a/lib/rules/no-promise-in-fire-event.ts +++ b/lib/rules/no-promise-in-fire-event.ts @@ -20,7 +20,6 @@ export default createTestingLibraryRule({ docs: { description: 'Disallow the use of promises passed to a `fireEvent` method', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/no-render-in-setup.ts b/lib/rules/no-render-in-setup.ts index 89db8ef6..29f9a442 100644 --- a/lib/rules/no-render-in-setup.ts +++ b/lib/rules/no-render-in-setup.ts @@ -50,7 +50,6 @@ export default createTestingLibraryRule({ docs: { description: 'Disallow the use of `render` in testing frameworks setup functions', - category: 'Best Practices', recommendedConfig: { dom: false, angular: 'error', diff --git a/lib/rules/no-unnecessary-act.ts b/lib/rules/no-unnecessary-act.ts index 5bdf4fd2..5cd9f4b1 100644 --- a/lib/rules/no-unnecessary-act.ts +++ b/lib/rules/no-unnecessary-act.ts @@ -23,7 +23,6 @@ export default createTestingLibraryRule({ docs: { description: 'Disallow wrapping Testing Library utils or empty callbacks in `act`', - category: 'Possible Errors', recommendedConfig: { dom: false, angular: false, diff --git a/lib/rules/no-wait-for-empty-callback.ts b/lib/rules/no-wait-for-empty-callback.ts index d731ecd7..7bbfef99 100644 --- a/lib/rules/no-wait-for-empty-callback.ts +++ b/lib/rules/no-wait-for-empty-callback.ts @@ -18,7 +18,6 @@ export default createTestingLibraryRule({ docs: { description: 'Disallow empty callbacks for `waitFor` and `waitForElementToBeRemoved`', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/no-wait-for-multiple-assertions.ts b/lib/rules/no-wait-for-multiple-assertions.ts index 171dd290..f3f23ebd 100644 --- a/lib/rules/no-wait-for-multiple-assertions.ts +++ b/lib/rules/no-wait-for-multiple-assertions.ts @@ -17,7 +17,6 @@ export default createTestingLibraryRule({ docs: { description: 'Disallow the use of multiple `expect` calls inside `waitFor`', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/no-wait-for-side-effects.ts b/lib/rules/no-wait-for-side-effects.ts index 2049f907..4c919245 100644 --- a/lib/rules/no-wait-for-side-effects.ts +++ b/lib/rules/no-wait-for-side-effects.ts @@ -20,7 +20,6 @@ export default createTestingLibraryRule({ type: 'suggestion', docs: { description: 'Disallow the use of side effects in `waitFor`', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/no-wait-for-snapshot.ts b/lib/rules/no-wait-for-snapshot.ts index 9b7ddd01..96450678 100644 --- a/lib/rules/no-wait-for-snapshot.ts +++ b/lib/rules/no-wait-for-snapshot.ts @@ -19,7 +19,6 @@ export default createTestingLibraryRule({ docs: { description: 'Ensures no snapshot is generated inside of a `waitFor` call', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/prefer-explicit-assert.ts b/lib/rules/prefer-explicit-assert.ts index 86e1f4ed..a8d376f0 100644 --- a/lib/rules/prefer-explicit-assert.ts +++ b/lib/rules/prefer-explicit-assert.ts @@ -69,7 +69,6 @@ export default createTestingLibraryRule({ docs: { description: 'Suggest using explicit assertions rather than standalone queries', - category: 'Best Practices', recommendedConfig: { dom: false, angular: false, diff --git a/lib/rules/prefer-find-by.ts b/lib/rules/prefer-find-by.ts index 40bb865a..460eab38 100644 --- a/lib/rules/prefer-find-by.ts +++ b/lib/rules/prefer-find-by.ts @@ -56,7 +56,6 @@ export default createTestingLibraryRule({ docs: { description: 'Suggest using `find(All)By*` query instead of `waitFor` + `get(All)By*` to wait for elements', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/prefer-presence-queries.ts b/lib/rules/prefer-presence-queries.ts index d07bf999..611cf5ed 100644 --- a/lib/rules/prefer-presence-queries.ts +++ b/lib/rules/prefer-presence-queries.ts @@ -11,7 +11,6 @@ export default createTestingLibraryRule({ name: RULE_NAME, meta: { docs: { - category: 'Best Practices', description: 'Ensure appropriate `get*`/`query*` queries are used with their respective matchers', recommendedConfig: { diff --git a/lib/rules/prefer-query-by-disappearance.ts b/lib/rules/prefer-query-by-disappearance.ts index cc2d6671..bbb2a9e6 100644 --- a/lib/rules/prefer-query-by-disappearance.ts +++ b/lib/rules/prefer-query-by-disappearance.ts @@ -23,7 +23,6 @@ export default createTestingLibraryRule({ docs: { description: 'Suggest using `queryBy*` queries when waiting for disappearance', - category: 'Possible Errors', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/prefer-screen-queries.ts b/lib/rules/prefer-screen-queries.ts index bca47eef..acca7c5a 100644 --- a/lib/rules/prefer-screen-queries.ts +++ b/lib/rules/prefer-screen-queries.ts @@ -40,7 +40,6 @@ export default createTestingLibraryRule({ type: 'suggestion', docs: { description: 'Suggest using `screen` while querying', - category: 'Best Practices', recommendedConfig: { dom: 'error', angular: 'error', diff --git a/lib/rules/prefer-user-event.ts b/lib/rules/prefer-user-event.ts index 76f37f93..2e0a8958 100644 --- a/lib/rules/prefer-user-event.ts +++ b/lib/rules/prefer-user-event.ts @@ -71,7 +71,6 @@ export default createTestingLibraryRule({ docs: { description: 'Suggest using `userEvent` over `fireEvent` for simulating user interactions', - category: 'Best Practices', recommendedConfig: { dom: false, angular: false, diff --git a/lib/rules/prefer-wait-for.ts b/lib/rules/prefer-wait-for.ts index fc8f654b..a302ee1c 100644 --- a/lib/rules/prefer-wait-for.ts +++ b/lib/rules/prefer-wait-for.ts @@ -26,7 +26,6 @@ export default createTestingLibraryRule({ type: 'suggestion', docs: { description: 'Use `waitFor` instead of deprecated wait methods', - category: 'Best Practices', recommendedConfig: { dom: false, angular: false, diff --git a/lib/rules/render-result-naming-convention.ts b/lib/rules/render-result-naming-convention.ts index 8e9d9e4f..046ce4ed 100644 --- a/lib/rules/render-result-naming-convention.ts +++ b/lib/rules/render-result-naming-convention.ts @@ -24,7 +24,6 @@ export default createTestingLibraryRule({ type: 'suggestion', docs: { description: 'Enforce a valid naming for return value from `render`', - category: 'Best Practices', recommendedConfig: { dom: false, angular: 'error', diff --git a/package.json b/package.json index e9edaadd..94f839e5 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "prepare": "is-ci || husky install" }, "dependencies": { - "@typescript-eslint/experimental-utils": "^4.30.0" + "@typescript-eslint/experimental-utils": "^5.0.0" }, "devDependencies": { "@babel/eslint-plugin": "^7.14.5", @@ -50,17 +50,17 @@ "@commitlint/config-conventional": "^13.2.0", "@types/jest": "^27.0.2", "@types/node": "^16.10.6", - "@typescript-eslint/eslint-plugin": "^4.30.0", - "@typescript-eslint/parser": "^4.30.0", + "@typescript-eslint/eslint-plugin": "^5.0.0", + "@typescript-eslint/parser": "^5.0.0", "cpy-cli": "^3.1.1", "eslint": "^7.32.0", - "eslint-config-kentcdodds": "^19.1.1", + "eslint-config-kentcdodds": "^19.2.0", "eslint-config-prettier": "^8.3.0", - "eslint-plugin-import": "^2.24.2", - "eslint-plugin-jest": "^24.4.0", + "eslint-plugin-import": "^2.25.2", + "eslint-plugin-jest": "^25.0.6", "eslint-plugin-jest-formatting": "^3.0.0", "eslint-plugin-node": "^11.1.0", - "eslint-plugin-prettier": "^3.4.1", + "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-promise": "^5.1.0", "husky": "^7.0.2", "is-ci": "^3.0.0", @@ -73,7 +73,7 @@ "typescript": "^4.4.4" }, "peerDependencies": { - "eslint": "^7.5.0" + "eslint": "^7.5.0 || ^8.0.0" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0", diff --git a/tests/fake-rule.ts b/tests/fake-rule.ts index 70a8d5da..9f57493e 100644 --- a/tests/fake-rule.ts +++ b/tests/fake-rule.ts @@ -26,7 +26,6 @@ export default createTestingLibraryRule({ type: 'problem', docs: { description: 'Fake rule to test rule maker and detection helpers', - category: 'Possible Errors', recommendedConfig: { dom: false, angular: false, From 307bfac15505773571b63f0710caed55b2e926e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Sun, 17 Oct 2021 21:18:33 +0200 Subject: [PATCH 14/16] chore: bump jest dependencies --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 94f839e5..8d055a2b 100644 --- a/package.json +++ b/package.json @@ -57,18 +57,18 @@ "eslint-config-kentcdodds": "^19.2.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-import": "^2.25.2", - "eslint-plugin-jest": "^25.0.6", + "eslint-plugin-jest": "^25.2.2", "eslint-plugin-jest-formatting": "^3.0.0", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-promise": "^5.1.0", "husky": "^7.0.2", "is-ci": "^3.0.0", - "jest": "^27.2.5", + "jest": "^27.3.0", "lint-staged": "^11.2.3", "prettier": "2.4.1", "semantic-release": "^18.0.0", - "ts-jest": "27.0.5", + "ts-jest": "27.0.7", "ts-node": "^10.3.0", "typescript": "^4.4.4" }, From 6dd5158edbf7b1c88e8a1331a60e2f05875e6525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Sun, 17 Oct 2021 21:25:50 +0200 Subject: [PATCH 15/16] docs: add migration guide to v5 --- README.md | 1 + docs/migration-guides/v5.md | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 docs/migration-guides/v5.md diff --git a/README.md b/README.md index f3cd4eaa..c6cba0dc 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ $ yarn add --dev eslint-plugin-testing-library You can find detailed guides for migrating `eslint-plugin-testing-library` in the [migration guide docs](docs/migration-guides): - [Migrate guide for v4](docs/migration-guides/v4.md) +- [Migrate guide for v5](docs/migration-guides/v5.md) ## Usage diff --git a/docs/migration-guides/v5.md b/docs/migration-guides/v5.md new file mode 100644 index 00000000..2a544f3c --- /dev/null +++ b/docs/migration-guides/v5.md @@ -0,0 +1,25 @@ +# Guide: migrating to v5 + +Assuming you are already in v4, migrating to v5 will be easy. If you are not in v4 yet, we recommend you to follow [the proper guide to migrate to it](docs/migration-guides/v4.md). + +## Overview + +- Support for ESLint v8 +- Drop support for Node v10 - required node version is now `^12.22.0 || ^14.17.0 || >=16.0.0`. Node v10 was EOL'd in April 2021, and ESLint v8 dropped support for it too. +- Update dependencies +- `no-debug` is now called `no-debugging-utils` +- `no-render-in-setup` is now enabled by default in the Angular, React & Vue configs +- `no-unnecessary-act`'s `isStrict` option is now `true` by default +- `no-unnecessary-act` is now enabled by default in the React config +- `no-wait-for-multiple-assertions` is now enabled by default in all configs +- `no-wait-for-side-effects` is now enabled by default in all configs +- `no-wait-for-snapshot` is now enabled by default in all configs +- `prefer-presence-queries` is now enabled by default in all configs +- `prefer-query-by-disappearance` is now enabled by default in all configs + +## Steps to upgrade + +- `eslint-plugin-testing-library` supports both ESLint v7 and v8, so you are fine with either version +- Make sure you are using a compatible Node version, and update it if it's not the case +- Rename `testing-library/no-debug` to `testing-library/no-debugging-utils` if you were referencing it manually somewhere +- Be aware of new rules enabled in Shared Configs which can lead to new reported errors From ffe5cfeb9b6e953703e358298b16830f767dcd8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Tue, 19 Oct 2021 16:16:52 +0200 Subject: [PATCH 16/16] docs: improve migrating to v5 guide --- docs/migration-guides/v5.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/migration-guides/v5.md b/docs/migration-guides/v5.md index 2a544f3c..0ca34954 100644 --- a/docs/migration-guides/v5.md +++ b/docs/migration-guides/v5.md @@ -5,7 +5,7 @@ Assuming you are already in v4, migrating to v5 will be easy. If you are not in ## Overview - Support for ESLint v8 -- Drop support for Node v10 - required node version is now `^12.22.0 || ^14.17.0 || >=16.0.0`. Node v10 was EOL'd in April 2021, and ESLint v8 dropped support for it too. +- Drop support for Node v10. Required node version is now `^12.22.0 || ^14.17.0 || >=16.0.0`. Node v10 was EOL'd in April 2021, and ESLint v8 dropped support for it too. - Update dependencies - `no-debug` is now called `no-debugging-utils` - `no-render-in-setup` is now enabled by default in the Angular, React & Vue configs @@ -20,6 +20,6 @@ Assuming you are already in v4, migrating to v5 will be easy. If you are not in ## Steps to upgrade - `eslint-plugin-testing-library` supports both ESLint v7 and v8, so you are fine with either version -- Make sure you are using a compatible Node version, and update it if it's not the case -- Rename `testing-library/no-debug` to `testing-library/no-debugging-utils` if you were referencing it manually somewhere -- Be aware of new rules enabled in Shared Configs which can lead to new reported errors +- Making sure you are using a compatible Node version (`^12.22.0 || ^14.17.0 || >=16.0.0`), and update it if it's not the case +- Renaming `testing-library/no-debug` to `testing-library/no-debugging-utils` if you were referencing it manually somewhere +- Being aware of new rules enabled in Shared Configs which can lead to new reported errors