From 2ae8c1d6c5742b9e0c5746ebc49ee43ad888fadb Mon Sep 17 00:00:00 2001 From: dangreen Date: Thu, 8 Jun 2023 01:43:39 +0400 Subject: [PATCH] feat(eslint-config): move jest-dom rules to separate entry --- packages/eslint-config/README.md | 1 + packages/eslint-config/package.json | 1 + packages/eslint-config/src/jest-dom.js | 22 ++++++++++++++++++++++ packages/eslint-config/src/jest.js | 8 ++------ packages/eslint-config/src/rules/es6.js | 2 +- 5 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 packages/eslint-config/src/jest-dom.js diff --git a/packages/eslint-config/README.md b/packages/eslint-config/README.md index 9317df4..267b63a 100644 --- a/packages/eslint-config/README.md +++ b/packages/eslint-config/README.md @@ -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. | diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index 6af0eb3..f911b9f 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -33,6 +33,7 @@ "postpublish": "del ./package" }, "peerDependencies": { + "@testing-library/dom": ">=8.0.0", "eslint": ">=7.0.0" }, "dependencies": { diff --git a/packages/eslint-config/src/jest-dom.js b/packages/eslint-config/src/jest-dom.js new file mode 100644 index 0000000..9db1fd6 --- /dev/null +++ b/packages/eslint-config/src/jest-dom.js @@ -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'] + } + ] +} diff --git a/packages/eslint-config/src/jest.js b/packages/eslint-config/src/jest.js index 443e271..cb92b41 100644 --- a/packages/eslint-config/src/jest.js +++ b/packages/eslint-config/src/jest.js @@ -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 }, diff --git a/packages/eslint-config/src/rules/es6.js b/packages/eslint-config/src/rules/es6.js index 747618d..5beaee8 100644 --- a/packages/eslint-config/src/rules/es6.js +++ b/packages/eslint-config/src/rules/es6.js @@ -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',