From 3c9909c54084fec626f886187bdcb162f021ae49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Sun, 4 Apr 2021 14:18:08 +0200 Subject: [PATCH 01/11] docs: first steps for migrating to v4 guide --- docs/migrating-to-v4-guide.md | 65 +++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 docs/migrating-to-v4-guide.md diff --git a/docs/migrating-to-v4-guide.md b/docs/migrating-to-v4-guide.md new file mode 100644 index 00000000..d21babff --- /dev/null +++ b/docs/migrating-to-v4-guide.md @@ -0,0 +1,65 @@ +Previous versions of `eslint-plugin-testing-library` weren't checking common things consistently: Testing Library imports, renamed methods, wrappers around Testing Library methods, etc. +One of the most important changes of `eslint-plugin-testing-library` v4 is the new detection mechanism implemented to be shared across all the rules, so each one of them has been rewritten to detect and report Testing Library usages consistently and correctly from a core module. + +## Overview + +- Aggressive Reporting opted-in to avoid silencing possible errors +- 7 new rules + - `no-container` + - `no-node-access` + - `no-promise-in-fire-event` + - `no-wait-for-multiple-assertions` + - `no-wait-for-side-effects` + - `prefer-user-event` + - `render-result-naming-convention` +- Config presets updated + - `recommended` renamed to `dom` + - `no-wait-for-empty-callback` and `prefer-screen-queries` enabled in presets +- Some rules option removed in favor of new Shared Settings + Aggressive Reporting +- More consistent and flexible core rules detection +- Tons of errors and small issues fixed +- Dependencies updates + +## Breaking Changes + +### Dependencies + +- Min Node version required is `10.22.1` +- Min ESLint version required is `7.5` + +Make sure you have Node and ESLint installed satisfying these new required versions. + +### New errors reported + +Since there are two new rules enabled in presets (`no-wait-for-empty-callback` and `prefer-screen-queries`), and v4 also fixes a lot of issues, you might find new errors reported in your codebase. +Just be aware of this when migrating to v4. + +### `recommended` preset has been renamed + +If you were using `recommended` preset, it has been renamed to `dom` so you'll need to update it in your ESLint config file: + +```diff +{ + ... +- "extends": ["plugin:testing-library/recommended"] ++ "extends": ["plugin:testing-library/dom"] +} +``` + +This preset has been renamed to clarify there is no "recommended" preset by default, so it depends on which Testing Library package you are using: DOM, Angular, React, or Vue (for now). + +### `customQueryNames` rules option has been removed + +Until now, those rules reporting errors related to Testing Library queries needed an option called `customQueryNames` so you could specify which extra queries you'd like to report apart from built-in ones. This has been removed in favor of reporting every method matching Testing Library queries pattern. This means every method matching `get(All)By*`, `query(All)By*`, or `find(All)By*` will be reported, so for instance `getByText` and `getByIcon` will be assumed as queries to be reported. The only thing you need to do is removing `customQueryNames` from your rules config if any. + +### `renderFunctions` rules option has been removed + +TODO + +## Aggressive Reporting + +TODO + +## Shared Settings + +TODO From b91dbdb346c7486a9202b1ff4be867638a995675 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Sun, 4 Apr 2021 17:47:40 +0200 Subject: [PATCH 02/11] docs: extract Aggressive Reporting Query info to its own section --- docs/migrating-to-v4-guide.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/migrating-to-v4-guide.md b/docs/migrating-to-v4-guide.md index d21babff..079f9757 100644 --- a/docs/migrating-to-v4-guide.md +++ b/docs/migrating-to-v4-guide.md @@ -50,7 +50,7 @@ This preset has been renamed to clarify there is no "recommended" preset by defa ### `customQueryNames` rules option has been removed -Until now, those rules reporting errors related to Testing Library queries needed an option called `customQueryNames` so you could specify which extra queries you'd like to report apart from built-in ones. This has been removed in favor of reporting every method matching Testing Library queries pattern. This means every method matching `get(All)By*`, `query(All)By*`, or `find(All)By*` will be reported, so for instance `getByText` and `getByIcon` will be assumed as queries to be reported. The only thing you need to do is removing `customQueryNames` from your rules config if any. +Until now, those rules reporting errors related to Testing Library queries needed an option called `customQueryNames` so you could specify which extra queries you'd like to report apart from built-in ones. This has been removed in favor of reporting every method matching Testing Library queries pattern. The only thing you need to do is removing `customQueryNames` from your rules config if any. You can read more about it in corresponding [Aggressive Reporting - Queries](#queries) section. ### `renderFunctions` rules option has been removed @@ -58,8 +58,23 @@ TODO ## Aggressive Reporting +Motivated by [this issue comment](https://github.com/testing-library/eslint-plugin-testing-library/issues/222#issuecomment-679592434). + +### Imports + +TODO + +### Render + TODO +### Queries + +Testing Library has a set of built-in queries which always follow the pattern `get(All)By*`, `query(All)By*`, or `find(All)By*`. What if we have some custom queries? Before v4, this had to be setup through some options over specific rules. This could lead to silencing errors tho since someone could forget to add a custom query to some custom rule option, so it would never be reported properly. + +In order to avoid that, since v4, every method found which matches some of Testing Library queries patterns will be treated as a valid query to be reported. For instance: `getByText` and `getByIcon` will be assumed as queries to be reported for `no-await-sync-query` rule, no matter if they are built-in (`*ByText`) or custom (`*ByIcon`) ones. +You don't need to set up anything for this behavior, and there is nothing for now to config it somehow. + ## Shared Settings TODO From 0499e32d5fff5aa1ff6649933684ce3aea1f27bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Sun, 4 Apr 2021 18:38:41 +0200 Subject: [PATCH 03/11] docs: explain Aggressive Reporting motivation and mechanism --- docs/migrating-to-v4-guide.md | 71 +++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 7 deletions(-) diff --git a/docs/migrating-to-v4-guide.md b/docs/migrating-to-v4-guide.md index 079f9757..3d3ba399 100644 --- a/docs/migrating-to-v4-guide.md +++ b/docs/migrating-to-v4-guide.md @@ -1,9 +1,11 @@ +# Guide: migrating to v4 + Previous versions of `eslint-plugin-testing-library` weren't checking common things consistently: Testing Library imports, renamed methods, wrappers around Testing Library methods, etc. One of the most important changes of `eslint-plugin-testing-library` v4 is the new detection mechanism implemented to be shared across all the rules, so each one of them has been rewritten to detect and report Testing Library usages consistently and correctly from a core module. ## Overview -- Aggressive Reporting opted-in to avoid silencing possible errors +- [Aggressive Reporting](#aggressive-reporting) opted-in to avoid silencing possible errors - 7 new rules - `no-container` - `no-node-access` @@ -46,25 +48,80 @@ If you were using `recommended` preset, it has been renamed to `dom` so you'll n } ``` -This preset has been renamed to clarify there is no "recommended" preset by default, so it depends on which Testing Library package you are using: DOM, Angular, React, or Vue (for now). +This preset has been renamed to clarify there is no _recommended_ preset by default, so it depends on which Testing Library package you are using: DOM, Angular, React, or Vue (for now). ### `customQueryNames` rules option has been removed -Until now, those rules reporting errors related to Testing Library queries needed an option called `customQueryNames` so you could specify which extra queries you'd like to report apart from built-in ones. This has been removed in favor of reporting every method matching Testing Library queries pattern. The only thing you need to do is removing `customQueryNames` from your rules config if any. You can read more about it in corresponding [Aggressive Reporting - Queries](#queries) section. +Until now, those rules reporting errors related to Testing Library queries needed an option called `customQueryNames` so you could specify which extra queries you'd like to report apart from built-in ones. This option has been removed in favor of reporting every method matching Testing Library queries pattern. The only thing you need to do is removing `customQueryNames` from your rules config if any. You can read more about it in corresponding [Aggressive Reporting - Queries](#queries) section. ### `renderFunctions` rules option has been removed -TODO +Until now, those rules reporting errors related to Testing Library `render` needed an option called `renderFunctions` so you could specify which extra functions from your codebase should be assumed as extra `render` methods apart from built-in one. This option has been removed in favor of reporting every method which contains `*render*` on its name. The only thing you need to do is removing `renderFunctions` from your rules config if any. You can read more about it in corresponding [Aggressive Reporting - Render](#renders) section, and available config in [Shared Settings](#shared-settings) section. ## Aggressive Reporting -Motivated by [this issue comment](https://github.com/testing-library/eslint-plugin-testing-library/issues/222#issuecomment-679592434). +So what is this Aggressive Reporting introduced on v4? Until v3, `eslint-plugin-testing-library` had assumed that all Testing Libraries utils would be imported from some `@testing-library/*` or `*-testing-library` package. However, this is not always true since: + +- users can [add their own Custom Render](https://testing-library.com/docs/react-testing-library/setup/#custom-render) methods, so it can be named other than `render`. +- users can [re-export Testing Library utils from a custom module](https://testing-library.com/docs/react-testing-library/setup/#configuring-jest-with-test-utils), so they won't be imported from a Testing Library package but a custom one. +- users can [add their own Custom Queries](https://testing-library.com/docs/react-testing-library/setup/#add-custom-queries), so it's possible to use other queries than built-in ones. + +These customization mechanisms make impossible for `eslint-plugin-testing-library` to figure out if some utils are related to Testing Library or not. Here you have some examples illustrating it: + +```javascript +import { render, screen } from '@testing-library/react'; +// ... + +// ✅ this render has to be reported since it's named `render` +// and it's imported from @testing-library/* package +const wrapper = render(); + +// ✅ this query has to be reported since it's named after a built-in query +// and it's imported from @testing-library/* package +const el = screen.findByRole('button'); +``` + +```javascript +// importing from Custom Module +import { renderWithRedux, findByIcon } from 'utils'; +// ... + +// ❓ we don't know if this render has to be reported since it's NOT named `render` +// and it's NOT imported from @testing-library/* package +const wrapper = renderWithRedux(); + +// ❓ we don't know if this query has to be reported since it's NOT named after a built-in query +// and it's NOT imported from @testing-library/* package +const el = findByIcon('profile'); +``` + +How can the `eslint-plugin-testing-library` be aware of this? Until v3, the plugin offered some options to indicate some of these custom things, so the plugin will check them when reporting usages. This can lead to false negatives tho since the users might not be aware of the necessity of indicating such custom utils or just forgot about doing so. + +Instead, in `eslint-plugin-testing-library` v4 we have opted-in a more **aggressive reporting** mechanism which, by default, will assume any method named following the same patterns as Testing Library utils has to be reported too: + +```javascript +// importing from Custom Module +import { renderWithRedux, findByIcon } from 'utils'; +// ... + +// ✅ this render has to be reported since its name contains "*render*" +// and it doesn't matter where it's imported from +const wrapper = renderWithRedux(); + +// ✅ this render has to be reported since its name starts by "findBy*" +// and it doesn't matter where it's imported from +const el = findByIcon('profile'); +``` + +There are 3 behaviors then that can be aggressively reported: imports, renders, and queries. This new Aggressive Reporting mechanism will just work fine out of the box and won't create false positives. However, it's possible to do some tweaks to disable some of these behaviors using the new [Shared Settings](#shared-settings). We recommend you keep reading this section to know more about these Aggressive Reporting behaviors, and then check the Shared Settings if you think you'd need them for any particular reason. + +_You can find the motivation behind this behavior on [this issue comment](https://github.com/testing-library/eslint-plugin-testing-library/issues/222#issuecomment-679592434)._ ### Imports TODO -### Render +### Renders TODO @@ -72,7 +129,7 @@ TODO Testing Library has a set of built-in queries which always follow the pattern `get(All)By*`, `query(All)By*`, or `find(All)By*`. What if we have some custom queries? Before v4, this had to be setup through some options over specific rules. This could lead to silencing errors tho since someone could forget to add a custom query to some custom rule option, so it would never be reported properly. -In order to avoid that, since v4, every method found which matches some of Testing Library queries patterns will be treated as a valid query to be reported. For instance: `getByText` and `getByIcon` will be assumed as queries to be reported for `no-await-sync-query` rule, no matter if they are built-in (`*ByText`) or custom (`*ByIcon`) ones. +In order to avoid that, since v4, every method found which matches some Testing Library queries patterns will be treated as a valid query to be reported. For instance: `getByText` and `getByIcon` will be assumed as queries to be reported for `no-await-sync-query` rule, no matter if they are built-in (`*ByText`) or custom (`*ByIcon`) ones. You don't need to set up anything for this behavior, and there is nothing for now to config it somehow. ## Shared Settings From 4b226771e8167d2997f1b182412e402e4befb5d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Sun, 4 Apr 2021 19:06:09 +0200 Subject: [PATCH 04/11] docs: describe each aggressive reporting mechanism --- docs/migrating-to-v4-guide.md | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/docs/migrating-to-v4-guide.md b/docs/migrating-to-v4-guide.md index 3d3ba399..319df878 100644 --- a/docs/migrating-to-v4-guide.md +++ b/docs/migrating-to-v4-guide.md @@ -83,7 +83,7 @@ const el = screen.findByRole('button'); ```javascript // importing from Custom Module -import { renderWithRedux, findByIcon } from 'utils'; +import { renderWithRedux, findByIcon } from 'test-utils'; // ... // ❓ we don't know if this render has to be reported since it's NOT named `render` @@ -101,7 +101,7 @@ Instead, in `eslint-plugin-testing-library` v4 we have opted-in a more **aggress ```javascript // importing from Custom Module -import { renderWithRedux, findByIcon } from 'utils'; +import { renderWithRedux, findByIcon } from 'test-utils'; // ... // ✅ this render has to be reported since its name contains "*render*" @@ -113,25 +113,38 @@ const wrapper = renderWithRedux(); const el = findByIcon('profile'); ``` -There are 3 behaviors then that can be aggressively reported: imports, renders, and queries. This new Aggressive Reporting mechanism will just work fine out of the box and won't create false positives. However, it's possible to do some tweaks to disable some of these behaviors using the new [Shared Settings](#shared-settings). We recommend you keep reading this section to know more about these Aggressive Reporting behaviors, and then check the Shared Settings if you think you'd need them for any particular reason. +There are 3 behaviors then that can be aggressively reported: imports, renders, and queries. This new Aggressive Reporting mechanism will just work fine out of the box and won't create false positives. However, it's possible to do some tweaks to disable some of these behaviors using the new [Shared Settings](#shared-settings). We recommend you to keep reading this section to know more about these Aggressive Reporting behaviors and then check the Shared Settings if you think you'd still need it for some particular reason. _You can find the motivation behind this behavior on [this issue comment](https://github.com/testing-library/eslint-plugin-testing-library/issues/222#issuecomment-679592434)._ ### Imports -TODO +By default, `eslint-plugin-testing-library` v4 won't check from which module are the utils imported. This means it doesn't matter if you are importing the utils from `@testing-library/*`, `test-utils` or `whatever`. + +There is a new Shared Setting to restrict this scope tho: [`utils-module`](#utils-module). By using this setting, only utils imported from `@testing-library/*` packages, or the custom one indicated in this setting would be reported. ### Renders -TODO +By default, `eslint-plugin-testing-library` v4 will assume that all methods which names contain "render" should be reported. This means it doesn't matter if you are rendering your elements for testing using `render`, `customRender` or `renderWithRedux`. + +There is a new Shared Setting to restrict this scope tho: [`custom-renders`](#custom-renders). By using this setting, only methods strictly named `render` or as one of the indicated Custom Renders would be reported. ### Queries -Testing Library has a set of built-in queries which always follow the pattern `get(All)By*`, `query(All)By*`, or `find(All)By*`. What if we have some custom queries? Before v4, this had to be setup through some options over specific rules. This could lead to silencing errors tho since someone could forget to add a custom query to some custom rule option, so it would never be reported properly. +`eslint-plugin-testing-library` v4 will assume that all methods named following the pattern `get(All)By*`, `query(All)By*`, or `find(All)By*` are queries to be reported. This means it doesn't matter if you are using a built-in query (`getByText`), or a custom one (`getByIcon`): if it matches this pattern, it will be assumed as a potential query to be reported. -In order to avoid that, since v4, every method found which matches some Testing Library queries patterns will be treated as a valid query to be reported. For instance: `getByText` and `getByIcon` will be assumed as queries to be reported for `no-await-sync-query` rule, no matter if they are built-in (`*ByText`) or custom (`*ByIcon`) ones. -You don't need to set up anything for this behavior, and there is nothing for now to config it somehow. +There is no way to restrict this behavior for now. ## Shared Settings +TODO: link to ESLint shared settings + +⚠️ **Please be aware of using these settings will opt-out part of [Aggressive Reporting](#aggressive-reporting).** + +### `utils-module` + +TODO + +### `custom-renders` + TODO From f4d4f067ab8ed6d12a5216d62b6660b3a5ac8e38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Sun, 4 Apr 2021 19:21:44 +0200 Subject: [PATCH 05/11] docs: shared settings --- docs/migrating-to-v4-guide.md | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/docs/migrating-to-v4-guide.md b/docs/migrating-to-v4-guide.md index 319df878..cb4dbfaf 100644 --- a/docs/migrating-to-v4-guide.md +++ b/docs/migrating-to-v4-guide.md @@ -137,14 +137,38 @@ There is no way to restrict this behavior for now. ## Shared Settings -TODO: link to ESLint shared settings +ESLint has a setting feature which allows configuring data that must be shared across all its rules: [Shared Settings](https://eslint.org/docs/user-guide/configuring/configuration-files#adding-shared-settings). Since `eslint-plugin-testing-library` v4 we are using this Shared Settings to config global things for the plugin. -⚠️ **Please be aware of using these settings will opt-out part of [Aggressive Reporting](#aggressive-reporting).** +To avoid collision with settings from other ESLint plugins, all the properties for this one are prefixed with `testing-library/`. + +⚠️ **Please be aware of using these settings will disable part of [Aggressive Reporting](#aggressive-reporting).** ### `utils-module` -TODO +Relates to [Aggressive Reporting - Imports](#imports). This setting (just a string) allows you to indicate which is the only Custom Module you'd like to be reported by `eslint-plugin-testing-library`. + +```json +// .eslintrc +{ + "settings": { + "testing-library/utils-module": "my-custom-test-utils" + } +} +``` + +The previous setting example would force `eslint-plugin-testing-library` to only report Testing Library utils coming from `@testing-library/*` package or `my-custom-test-utils`, silencing potential errors for utils imported from somewhere else. ### `custom-renders` -TODO +Relates to [Aggressive Reporting - Renders](#renders). This setting (array of strings) allows you to indicate which are the only Custom Renders you'd like to be reported by `eslint-plugin-testing-library`. + +```json +// .eslintrc +{ + "settings": { + "testing-library/custom-renders": ["display", "renderWithProviders"] + } +} +``` + +The previous setting example would force `eslint-plugin-testing-library` to only report Testing Library renders named `render` (built-in one is always included), `display` and `renderWithProviders`, silencing potential errors for others custom renders. From 588973c9c8cccdf8d6baa76fa73d8d770ec96180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Mon, 5 Apr 2021 01:20:59 +0200 Subject: [PATCH 06/11] docs: update info related to Shareable Configs updated --- docs/migrating-to-v4-guide.md | 46 +++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/docs/migrating-to-v4-guide.md b/docs/migrating-to-v4-guide.md index cb4dbfaf..1d9a39f0 100644 --- a/docs/migrating-to-v4-guide.md +++ b/docs/migrating-to-v4-guide.md @@ -14,9 +14,9 @@ One of the most important changes of `eslint-plugin-testing-library` v4 is the n - `no-wait-for-side-effects` - `prefer-user-event` - `render-result-naming-convention` -- Config presets updated +- Shareable Configs updated - `recommended` renamed to `dom` - - `no-wait-for-empty-callback` and `prefer-screen-queries` enabled in presets + - list rules of rules enabled has changed - Some rules option removed in favor of new Shared Settings + Aggressive Reporting - More consistent and flexible core rules detection - Tons of errors and small issues fixed @@ -33,12 +33,11 @@ Make sure you have Node and ESLint installed satisfying these new required versi ### New errors reported -Since there are two new rules enabled in presets (`no-wait-for-empty-callback` and `prefer-screen-queries`), and v4 also fixes a lot of issues, you might find new errors reported in your codebase. -Just be aware of this when migrating to v4. +Since v4 also fixes a lot of issues and detect invalid usages in a more consistent way, you might find new errors reported in your codebase. Just be aware of this when migrating to v4. -### `recommended` preset has been renamed +### `recommended` Shareable Config has been renamed -If you were using `recommended` preset, it has been renamed to `dom` so you'll need to update it in your ESLint config file: +If you were using `recommended` Shareable Config, it has been renamed to `dom` so you'll need to update it in your ESLint config file: ```diff { @@ -48,7 +47,40 @@ If you were using `recommended` preset, it has been renamed to `dom` so you'll n } ``` -This preset has been renamed to clarify there is no _recommended_ preset by default, so it depends on which Testing Library package you are using: DOM, Angular, React, or Vue (for now). +This Shareable Config has been renamed to clarify there is no _recommended_ config by default, so it depends on which Testing Library package you are using: DOM, Angular, React, or Vue (for now). + +### Shareable Configs updated + +Shareable Configs have been updated with: + +- `dom` + - `no-promise-in-fire-event` enabled as "error" + - `no-wait-for-empty-callback` enabled as "error" + - `prefer-screen-queries` enabled as "error" +- `angular` + - `no-container` enabled as "error" + - `no-debug` changed from "warning" to "error" + - `no-node-access` enabled as "error" + - `no-promise-in-fire-event` enabled as "error" + - `no-wait-for-empty-callback` enabled as "error" + - `prefer-screen-queries` enabled as "error" + - `render-result-naming-convention` enabled as "error" +- `react` + - `no-container` enabled as "error" + - `no-debug` changed from "warning" to "error" + - `no-node-access` enabled as "error" + - `no-promise-in-fire-event` enabled as "error" + - `no-wait-for-empty-callback` enabled as "error" + - `prefer-screen-queries` enabled as "error" + - `render-result-naming-convention` enabled as "error" +- `vue` + - `no-container` enabled as "error" + - `no-debug` changed from "warning" to "error" + - `no-node-access` enabled as "error" + - `no-promise-in-fire-event` enabled as "error" + - `no-wait-for-empty-callback` enabled as "error" + - `prefer-screen-queries` enabled as "error" + - `render-result-naming-convention` enabled as "error" ### `customQueryNames` rules option has been removed From 51b88a309a1adabd005766d5ec816825600759b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Mon, 5 Apr 2021 01:23:08 +0200 Subject: [PATCH 07/11] docs: fix typo --- docs/migrating-to-v4-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/migrating-to-v4-guide.md b/docs/migrating-to-v4-guide.md index 1d9a39f0..239118aa 100644 --- a/docs/migrating-to-v4-guide.md +++ b/docs/migrating-to-v4-guide.md @@ -16,7 +16,7 @@ One of the most important changes of `eslint-plugin-testing-library` v4 is the n - `render-result-naming-convention` - Shareable Configs updated - `recommended` renamed to `dom` - - list rules of rules enabled has changed + - list of rules enabled has changed - Some rules option removed in favor of new Shared Settings + Aggressive Reporting - More consistent and flexible core rules detection - Tons of errors and small issues fixed From cde0570919750ab21d78e9a1aad31aa994f5bc94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Mon, 5 Apr 2021 01:33:44 +0200 Subject: [PATCH 08/11] docs: fix more typos --- docs/migrating-to-v4-guide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/migrating-to-v4-guide.md b/docs/migrating-to-v4-guide.md index 239118aa..c67ea98b 100644 --- a/docs/migrating-to-v4-guide.md +++ b/docs/migrating-to-v4-guide.md @@ -127,7 +127,7 @@ const wrapper = renderWithRedux(); const el = findByIcon('profile'); ``` -How can the `eslint-plugin-testing-library` be aware of this? Until v3, the plugin offered some options to indicate some of these custom things, so the plugin will check them when reporting usages. This can lead to false negatives tho since the users might not be aware of the necessity of indicating such custom utils or just forgot about doing so. +How can the `eslint-plugin-testing-library` be aware of this? Until v3, the plugin offered some options to indicate some of these custom things, so the plugin would check them when reporting usages. This can lead to false negatives tho since the users might not be aware of the necessity of indicating such custom utils or just forget about doing so. Instead, in `eslint-plugin-testing-library` v4 we have opted-in a more **aggressive reporting** mechanism which, by default, will assume any method named following the same patterns as Testing Library utils has to be reported too: @@ -145,7 +145,7 @@ const wrapper = renderWithRedux(); const el = findByIcon('profile'); ``` -There are 3 behaviors then that can be aggressively reported: imports, renders, and queries. This new Aggressive Reporting mechanism will just work fine out of the box and won't create false positives. However, it's possible to do some tweaks to disable some of these behaviors using the new [Shared Settings](#shared-settings). We recommend you to keep reading this section to know more about these Aggressive Reporting behaviors and then check the Shared Settings if you think you'd still need it for some particular reason. +There are 3 behaviors then that can be aggressively reported: imports, renders, and queries. This new Aggressive Reporting mechanism will just work fine out of the box and won't create false positives for most of the users. However, it's possible to do some tweaks to disable some of these behaviors using the new [Shared Settings](#shared-settings). We recommend you to keep reading this section to know more about these Aggressive Reporting behaviors and then check the Shared Settings if you think you'd still need it for some particular reason. _You can find the motivation behind this behavior on [this issue comment](https://github.com/testing-library/eslint-plugin-testing-library/issues/222#issuecomment-679592434)._ From d91279ab0271bb88cb2c9b1903974bef48090fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Mon, 5 Apr 2021 11:46:04 +0200 Subject: [PATCH 09/11] docs: replace tho by though --- docs/migrating-to-v4-guide.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/migrating-to-v4-guide.md b/docs/migrating-to-v4-guide.md index c67ea98b..4c057fbc 100644 --- a/docs/migrating-to-v4-guide.md +++ b/docs/migrating-to-v4-guide.md @@ -84,7 +84,9 @@ Shareable Configs have been updated with: ### `customQueryNames` rules option has been removed -Until now, those rules reporting errors related to Testing Library queries needed an option called `customQueryNames` so you could specify which extra queries you'd like to report apart from built-in ones. This option has been removed in favor of reporting every method matching Testing Library queries pattern. The only thing you need to do is removing `customQueryNames` from your rules config if any. You can read more about it in corresponding [Aggressive Reporting - Queries](#queries) section. +Until now, + +se rules reporting errors related to Testing Library queries needed an option called `customQueryNames` so you could specify which extra queries you'd like to report apart from built-in ones. This option has been removed in favor of reporting every method matching Testing Library queries pattern. The only thing you need to do is removing `customQueryNames` from your rules config if any. You can read more about it in corresponding [Aggressive Reporting - Queries](#queries) section. ### `renderFunctions` rules option has been removed @@ -127,7 +129,7 @@ const wrapper = renderWithRedux(); const el = findByIcon('profile'); ``` -How can the `eslint-plugin-testing-library` be aware of this? Until v3, the plugin offered some options to indicate some of these custom things, so the plugin would check them when reporting usages. This can lead to false negatives tho since the users might not be aware of the necessity of indicating such custom utils or just forget about doing so. +How can the `eslint-plugin-testing-library` be aware of this? Until v3, the plugin offered some options to indicate some of these custom things, so the plugin would check them when reporting usages. This can lead to false negatives though since the users might not be aware of the necessity of indicating such custom utils or just forget about doing so. Instead, in `eslint-plugin-testing-library` v4 we have opted-in a more **aggressive reporting** mechanism which, by default, will assume any method named following the same patterns as Testing Library utils has to be reported too: @@ -153,13 +155,13 @@ _You can find the motivation behind this behavior on [this issue comment](https: By default, `eslint-plugin-testing-library` v4 won't check from which module are the utils imported. This means it doesn't matter if you are importing the utils from `@testing-library/*`, `test-utils` or `whatever`. -There is a new Shared Setting to restrict this scope tho: [`utils-module`](#utils-module). By using this setting, only utils imported from `@testing-library/*` packages, or the custom one indicated in this setting would be reported. +There is a new Shared Setting to restrict this scope though: [`utils-module`](#utils-module). By using this setting, only utils imported from `@testing-library/*` packages, or the custom one indicated in this setting would be reported. ### Renders By default, `eslint-plugin-testing-library` v4 will assume that all methods which names contain "render" should be reported. This means it doesn't matter if you are rendering your elements for testing using `render`, `customRender` or `renderWithRedux`. -There is a new Shared Setting to restrict this scope tho: [`custom-renders`](#custom-renders). By using this setting, only methods strictly named `render` or as one of the indicated Custom Renders would be reported. +There is a new Shared Setting to restrict this scope though: [`custom-renders`](#custom-renders). By using this setting, only methods strictly named `render` or as one of the indicated Custom Renders would be reported. ### Queries From ebce42be2e33e35b289c63f6739a20e376a7e407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Mon, 5 Apr 2021 11:53:34 +0200 Subject: [PATCH 10/11] docs: fix wrong new lines entered --- docs/migrating-to-v4-guide.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/migrating-to-v4-guide.md b/docs/migrating-to-v4-guide.md index 4c057fbc..9fae28dd 100644 --- a/docs/migrating-to-v4-guide.md +++ b/docs/migrating-to-v4-guide.md @@ -84,9 +84,7 @@ Shareable Configs have been updated with: ### `customQueryNames` rules option has been removed -Until now, - -se rules reporting errors related to Testing Library queries needed an option called `customQueryNames` so you could specify which extra queries you'd like to report apart from built-in ones. This option has been removed in favor of reporting every method matching Testing Library queries pattern. The only thing you need to do is removing `customQueryNames` from your rules config if any. You can read more about it in corresponding [Aggressive Reporting - Queries](#queries) section. +Until now, those rules reporting errors related to Testing Library queries needed an option called `customQueryNames` so you could specify which extra queries you'd like to report apart from built-in ones. This option has been removed in favor of reporting every method matching Testing Library queries pattern. The only thing you need to do is removing `customQueryNames` from your rules config if any. You can read more about it in corresponding [Aggressive Reporting - Queries](#queries) section. ### `renderFunctions` rules option has been removed From 3b899bba84110a7e63b9632d3bfffe42b63559c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Beltr=C3=A1n=20Alarc=C3=B3n?= Date: Mon, 5 Apr 2021 11:54:44 +0200 Subject: [PATCH 11/11] ci: remove duplicated max-warnings param --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 85f576c8..d1896066 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -45,7 +45,7 @@ jobs: run: npm run lint - name: Check format - run: npm run format:check -- --max-warnings 0 + run: npm run format:check tests: name: Tests (Node v${{ matrix.node }} - ESLint v${{ matrix.eslint }})