diff --git a/website/docs/EslintPLluginTestingLibrary.md b/website/docs/EslintPLluginTestingLibrary.md new file mode 100644 index 000000000..43419a863 --- /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'], },