From 23324b12a80298139d5aec4410a5bcb203798341 Mon Sep 17 00:00:00 2001 From: pierrezimmermann Date: Sun, 19 Dec 2021 17:51:18 +0100 Subject: [PATCH 1/3] docs: add doc on compatibility with eslint-plugin-testing-library --- website/docs/EslintPLluginTestingLibrary.md | 31 +++++++++++++++++++++ website/sidebars.js | 1 + 2 files changed, 32 insertions(+) create mode 100644 website/docs/EslintPLluginTestingLibrary.md diff --git a/website/docs/EslintPLluginTestingLibrary.md b/website/docs/EslintPLluginTestingLibrary.md new file mode 100644 index 000000000..2d492d565 --- /dev/null +++ b/website/docs/EslintPLluginTestingLibrary.md @@ -0,0 +1,31 @@ +--- +id: eslint-plugin-testing-library +title: Eslint plugin testing library compatibility +--- + + +Most of the rules of the [eslint-plugin-testing-library](https://github.com/testing-library/eslint-plugin-testing-library) are compatible with this library except the followings: + +- [prefer-screen-queries](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-screen-queries.md): there is no screen object so this rule shouldn't be used + +- [prefer-user-event](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-user-event.md): userEvent requires a dom environement so it is not compatible with this library + +Also, some rules have become useless, unless maybe you're using an old version of the library: + +- [prefer-wait-for](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-wait-for.md): the wait utility is no longer available + +- [no-wait-for-empty-callback](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-wait-for-empty-callback.md): waitFor callback param is no longer optional + +To get the rule [consistent-data-testid](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/consistent-data-testid.md) to work, you need to configure it to check the testID attribute by adding the following in your eslint config file, the testIdPattern being whichever pattern you want to enforce: + +```javascript +{ + "testing-library/consistent-data-testid": [ + 2, + { + "testIdAttribute": ["testID"], + "testIdPattern": "^TestId(__[A-Z]*)?$" + } + ] +} +``` \ No newline at end of file diff --git a/website/sidebars.js b/website/sidebars.js index 63f1cb6aa..289508d94 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -7,6 +7,7 @@ module.exports = { 'migration-v7', 'migration-v2', 'how-should-i-query', + 'eslint-plugin-testing-library', ], Examples: ['react-navigation', 'redux-integration'], }, From d1cd4cd500f3ed392df0f98c8afdd703ed931267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 20 Dec 2021 10:05:43 +0100 Subject: [PATCH 2/3] Update website/docs/EslintPLluginTestingLibrary.md --- website/docs/EslintPLluginTestingLibrary.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/EslintPLluginTestingLibrary.md b/website/docs/EslintPLluginTestingLibrary.md index 2d492d565..04729b97e 100644 --- a/website/docs/EslintPLluginTestingLibrary.md +++ b/website/docs/EslintPLluginTestingLibrary.md @@ -16,7 +16,7 @@ Also, some rules have become useless, unless maybe you're using an old version o - [no-wait-for-empty-callback](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/no-wait-for-empty-callback.md): waitFor callback param is no longer optional -To get the rule [consistent-data-testid](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/consistent-data-testid.md) to work, you need to configure it to check the testID attribute by adding the following in your eslint config file, the testIdPattern being whichever pattern you want to enforce: +To get the rule [consistent-data-testid](https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/consistent-data-testid.md) to work, you need to configure it to check the testID attribute by adding the following in your eslint config file, the `testIdPattern` being whichever pattern you want to enforce: ```javascript { From 31b2debfd17383fb63594ff9bc8dc5a2a252e938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 20 Dec 2021 10:05:48 +0100 Subject: [PATCH 3/3] Update website/docs/EslintPLluginTestingLibrary.md --- website/docs/EslintPLluginTestingLibrary.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/EslintPLluginTestingLibrary.md b/website/docs/EslintPLluginTestingLibrary.md index 04729b97e..43419a863 100644 --- a/website/docs/EslintPLluginTestingLibrary.md +++ b/website/docs/EslintPLluginTestingLibrary.md @@ -1,6 +1,6 @@ --- id: eslint-plugin-testing-library -title: Eslint plugin testing library compatibility +title: ESLint Plugin Testing Library Compatibility ---