Skip to content

Commit

Permalink
feat(eslint): introduce from jest-react config
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Rules for `@testing-library/react` have been moved to a new `jest-react` config,
which extends the `jest` config.
  • Loading branch information
mrmckeb committed Aug 29, 2023
1 parent 85f8b18 commit 8f612e0
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ For more information, see: [Scoped configuration with `overrides`](#scoped-confi
The following additional configs are available:

- `@vercel/style-guide/eslint/jest`
- `@vercel/style-guide/eslint/jest-react` (includes rules for `@testing-library/react`)
- `@vercel/style-guide/eslint/next` (requires `@next/eslint-plugin-next` to be installed at the same version as `next`)
- `@vercel/style-guide/eslint/playwright-test`
- `@vercel/style-guide/eslint/react`
Expand Down
9 changes: 9 additions & 0 deletions eslint/jest-react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
plugins: ['testing-library'],
extends: [
require.resolve('./jest'),
// We may want to separate this out in future, as it's only needed when
// using React with Testing Library.
'plugin:testing-library/react',
],
};
9 changes: 1 addition & 8 deletions eslint/jest.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
const { TYPESCRIPT_FILES } = require('./constants');

module.exports = {
plugins: ['testing-library'],
extends: [
'plugin:jest/recommended',
// We may want to separate this out in future, as it's only needed when
// using React with Testing Library.
'plugin:testing-library/react',
require.resolve('./rules/jest'),
],
extends: ['plugin:jest/recommended', require.resolve('./rules/jest')],
overrides: [
// Prefer the Jest version of this rule. This silently fails when type
// information is not available.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"eslint-plugin-playwright": "^0.16.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-testing-library": "^5.7.0",
"eslint-plugin-testing-library": "^6.0.1",
"eslint-plugin-tsdoc": "^0.2.17",
"eslint-plugin-unicorn": "^48.0.1",
"prettier-plugin-packagejson": "^2.4.5"
Expand Down
80 changes: 75 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8f612e0

Please sign in to comment.