From 8ad503627329563d10273592db2d0bc01dfb5657 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Tue, 9 Sep 2025 10:37:06 -0400 Subject: [PATCH] Limit Jest usage to test files; conslidate ESLint config. (#3086) Prior to this commit, technically Jest could have been imported in production files and ESLint would have been okay with that since it was allowed across the codebase. After this commit, ESLint will only allow Jest usage in test files. In addition, the 3-line test-specific ESLint config was consolidated into the main config. Co-authored-by: Johannes Klein --- .eslintrc.js | 13 +++++++++---- tests/.eslintrc.js | 4 ---- 2 files changed, 9 insertions(+), 8 deletions(-) delete mode 100644 tests/.eslintrc.js diff --git a/.eslintrc.js b/.eslintrc.js index 1d43cb46c..467c9b01f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -144,10 +144,6 @@ module.exports = { }], "@typescript-eslint/no-unsafe-function-type": 1 }, - // need this so jest doesn't show as undefined in jest.setup.js - env: { - jest: true - }, ignorePatterns: ["/coverage/*", "/vendor/*", "**/flow-typed"], settings: { "import/resolver": { @@ -172,6 +168,15 @@ module.exports = { rules: { "@typescript-eslint/no-require-imports": "off" } + }, + { + files: ["tests/**/*", "__mocks__/**/*", "e2e/**/*"], + env: { jest: true } + }, + { + files: ["tests/**/*"], + plugins: ["testing-library"], + extends: ["plugin:testing-library/react"] } ] }; diff --git a/tests/.eslintrc.js b/tests/.eslintrc.js deleted file mode 100644 index 5a6289ab6..000000000 --- a/tests/.eslintrc.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - plugins: ["testing-library"], - extends: ["plugin:testing-library/react"] -};