Skip to content

Commit

Permalink
feat(eslint-config): move jest-dom rules to separate entry
Browse files Browse the repository at this point in the history
  • Loading branch information
dangreen committed Jun 7, 2023
1 parent a1a799e commit 2ae8c1d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/eslint-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ There are additional configs for specific language features:
| @trigen/eslint-config/tsm | Rules for TS modules. |
| @trigen/eslint-config/react | Rules for ReactJS code. |
| @trigen/eslint-config/jest | Rules for Jest tests. |
| @trigen/eslint-config/jest-dom | Rules for Jest DOM tests. |
| @trigen/eslint-config/storybook | Rules for Storybook's stories. |
| @trigen/eslint-config/typescript | Rules for TypeScript code. |
| @trigen/eslint-config/typescript-requiring-type-checking | Rules for TypeScript code with type checking. |
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"postpublish": "del ./package"
},
"peerDependencies": {
"@testing-library/dom": ">=8.0.0",
"eslint": ">=7.0.0"
},
"dependencies": {
Expand Down
22 changes: 22 additions & 0 deletions packages/eslint-config/src/jest-dom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Jest DOM override
*/
const { makePatterns } = require('./utils')

const postfixes = ['spec', 'mock']
const extensions = [
'js',
'jsx',
'ts',
'tsx'
]

module.exports = {
overrides: [
{
files: makePatterns(postfixes, extensions),
plugins: ['jest-dom'],
extends: ['plugin:jest-dom/recommended']
}
]
}
8 changes: 2 additions & 6 deletions packages/eslint-config/src/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ module.exports = {
overrides: [
{
files: makePatterns(postfixes, extensions),
plugins: [
'jest',
'testing-library',
'jest-dom'
],
extends: ['plugin:testing-library/react', 'plugin:jest-dom/recommended'],
plugins: ['jest', 'testing-library'],
extends: ['plugin:testing-library/react'],
env: {
'jest/globals': true
},
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/src/rules/es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ module.exports = {
allowParens: true
}
],
'no-duplicate-imports': 'error',
'no-duplicate-imports': 'off', // in favor of import/no-duplicates
'no-useless-computed-key': 'error',
'no-useless-constructor': 'error',
'no-useless-rename': 'error',
Expand Down

0 comments on commit 2ae8c1d

Please sign in to comment.