From b5dda51b831c269208f0b5166d8f05dba49dba6a Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Mon, 20 Jan 2025 14:34:07 +0000 Subject: [PATCH] chore: control coverage by COLLECT_COVERAGE env var Changes the CI and package scripts such that there is no longer a forced `--coverage` flag in some packages. Instead, it is now determined by the `COLLECT_COVERAGE` environment variable. --- .github/workflows/ci.yml | 3 ++- jest.config.base.js | 2 +- packages/eslint-plugin-internal/package.json | 2 +- packages/eslint-plugin/package.json | 4 ++-- packages/integration-tests/package.json | 2 +- packages/parser/package.json | 2 +- packages/rule-schema-to-typescript-types/package.json | 3 ++- packages/rule-tester/package.json | 3 ++- packages/scope-manager/package.json | 2 +- packages/type-utils/package.json | 2 +- packages/typescript-eslint/package.json | 2 +- packages/typescript-estree/package.json | 2 +- packages/utils/package.json | 2 +- packages/visitor-keys/package.json | 2 +- yarn.lock | 2 ++ 15 files changed, 20 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 356d319a5a9a..eda5500ed33e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -205,9 +205,10 @@ jobs: run: npx nx test ${{ matrix.package }} env: CI: true + COLLECT_COVERAGE: true - name: Run unit tests for ${{ matrix.package }} if: env.PRIMARY_NODE_VERSION != matrix.node-version || matrix.os != 'ubuntu-latest' - run: npx nx test ${{ matrix.package }} --coverage=false + run: npx nx test ${{ matrix.package }} env: CI: true diff --git a/jest.config.base.js b/jest.config.base.js index fe816c4ca66e..f6d8e8795974 100644 --- a/jest.config.base.js +++ b/jest.config.base.js @@ -6,7 +6,7 @@ const path = require('node:path'); // @ts-check /** @type {import('@jest/types').Config.InitialOptions} */ module.exports = { - collectCoverage: true, + collectCoverage: process.env.COLLECT_COVERAGE === 'true', collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'], coverageReporters: ['lcov'], moduleFileExtensions: [ diff --git a/packages/eslint-plugin-internal/package.json b/packages/eslint-plugin-internal/package.json index 3ce2ccfa0ab1..620651237c92 100644 --- a/packages/eslint-plugin-internal/package.json +++ b/packages/eslint-plugin-internal/package.json @@ -19,7 +19,7 @@ "postclean": "rimraf dist && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", "lint": "npx nx lint", - "test": "jest --coverage", + "test": "jest", "typecheck": "npx tsc --noEmit" }, "dependencies": { diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index ab5b08148a7b..cc2bfbda31a3 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -55,8 +55,8 @@ "generate:breaking-changes": "tsx tools/generate-breaking-changes.mts", "generate:configs": "npx nx generate-configs repo", "lint": "npx nx lint", - "test": "cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --coverage --logHeapUsage", - "test-single": "cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --no-coverage", + "test": "cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --logHeapUsage", + "test-single": "cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest", "typecheck": "tsc --noEmit" }, "dependencies": { diff --git a/packages/integration-tests/package.json b/packages/integration-tests/package.json index 5c4e9cec240a..25d2c78e200d 100644 --- a/packages/integration-tests/package.json +++ b/packages/integration-tests/package.json @@ -14,7 +14,7 @@ "scripts": { "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", "lint": "npx nx lint", - "test": "jest --no-coverage", + "test": "jest", "typecheck": "tsc --noEmit" }, "devDependencies": { diff --git a/packages/parser/package.json b/packages/parser/package.json index 58b3a95a2093..79c156040d9d 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -45,7 +45,7 @@ "postclean": "rimraf dist && rimraf _ts4.3 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", "lint": "npx nx lint", - "test": "jest --coverage", + "test": "jest", "typecheck": "tsc --noEmit" }, "peerDependencies": { diff --git a/packages/rule-schema-to-typescript-types/package.json b/packages/rule-schema-to-typescript-types/package.json index 7ae3a21b28d5..659539d47c71 100644 --- a/packages/rule-schema-to-typescript-types/package.json +++ b/packages/rule-schema-to-typescript-types/package.json @@ -30,7 +30,7 @@ "generate-sponsors": "tsx ./src/generate-sponsors.ts", "lint": "npx nx lint", "postinstall-script": "tsx ./src/postinstall.ts", - "test": "npx jest --coverage", + "test": "jest", "typecheck": "tsc --noEmit" }, "dependencies": { @@ -41,6 +41,7 @@ }, "devDependencies": { "@jest/types": "29.6.3", + "jest": "29.7.0", "typescript": "*" }, "funding": { diff --git a/packages/rule-tester/package.json b/packages/rule-tester/package.json index e099f7b70904..ba340b3b574d 100644 --- a/packages/rule-tester/package.json +++ b/packages/rule-tester/package.json @@ -43,7 +43,7 @@ "lint": "npx nx lint", "pretest-eslint-base": "tsc -b tsconfig.build.json", "test-eslint-base": "mocha --require source-map-support/register ./tests/eslint-base/eslint-base.test.js", - "test": "npx jest --coverage", + "test": "jest", "typecheck": "tsc --noEmit" }, "//": "NOTE - AJV is out-of-date, but it's intentionally synced with ESLint - https://github.com/eslint/eslint/blob/ad9dd6a933fd098a0d99c6a9aa059850535c23ee/package.json#L70", @@ -67,6 +67,7 @@ "eslint-visitor-keys": "^4.2.0", "espree": "^10.3.0", "esprima": "^4.0.1", + "jest": "29.7.0", "mocha": "^10.4.0", "sinon": "^16.1.3", "source-map-support": "^0.5.21", diff --git a/packages/scope-manager/package.json b/packages/scope-manager/package.json index 451de1fb7b8f..031333b7800b 100644 --- a/packages/scope-manager/package.json +++ b/packages/scope-manager/package.json @@ -42,7 +42,7 @@ "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", "generate-lib": "npx nx generate-lib repo", "lint": "npx nx lint", - "test": "npx nx test --code-coverage", + "test": "npx nx test", "typecheck": "npx nx typecheck" }, "dependencies": { diff --git a/packages/type-utils/package.json b/packages/type-utils/package.json index 2e9fece9568d..9a6b604ea09b 100644 --- a/packages/type-utils/package.json +++ b/packages/type-utils/package.json @@ -42,7 +42,7 @@ "postclean": "rimraf dist && rimraf _ts3.4 && rimraf _ts4.3 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", "lint": "npx nx lint", - "test": "jest --coverage", + "test": "jest", "typecheck": "tsc --noEmit" }, "dependencies": { diff --git a/packages/typescript-eslint/package.json b/packages/typescript-eslint/package.json index fb4cff321f66..d140cdaf97a1 100644 --- a/packages/typescript-eslint/package.json +++ b/packages/typescript-eslint/package.json @@ -48,7 +48,7 @@ "postclean": "rimraf dist && rimraf _ts4.3 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", "lint": "nx lint", - "test": "jest --coverage --passWithNoTests", + "test": "jest --passWithNoTests", "typecheck": "tsc --noEmit" }, "dependencies": { diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 1fe1eb27926e..4b2bbb10ab5f 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -50,7 +50,7 @@ "postclean": "rimraf dist && rimraf _ts4.3 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", "lint": "npx nx lint", - "test": "jest --coverage --runInBand --verbose", + "test": "jest --runInBand --verbose", "typecheck": "tsc --noEmit" }, "dependencies": { diff --git a/packages/utils/package.json b/packages/utils/package.json index 868c6608f4ee..c28aa3605972 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -59,7 +59,7 @@ "postclean": "rimraf dist && rimraf _ts3.4 && rimraf _ts4.3 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", "lint": "npx nx lint", - "test": "jest --coverage", + "test": "jest", "typecheck": "tsc --noEmit" }, "dependencies": { diff --git a/packages/visitor-keys/package.json b/packages/visitor-keys/package.json index 840dd66531cd..5b67ba501324 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -43,7 +43,7 @@ "postclean": "rimraf dist && rimraf _ts3.4 && rimraf _ts4.3 && rimraf coverage", "format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore", "lint": "npx nx lint", - "test": "jest --coverage", + "test": "jest", "typecheck": "tsc --noEmit" }, "dependencies": { diff --git a/yarn.lock b/yarn.lock index abacaff130a7..4ba44af82c6b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5816,6 +5816,7 @@ __metadata: "@jest/types": 29.6.3 "@typescript-eslint/type-utils": 8.21.0 "@typescript-eslint/utils": 8.21.0 + jest: 29.7.0 natural-compare: ^1.4.0 prettier: ^3.2.5 typescript: "*" @@ -5837,6 +5838,7 @@ __metadata: eslint-visitor-keys: ^4.2.0 espree: ^10.3.0 esprima: ^4.0.1 + jest: 29.7.0 json-stable-stringify-without-jsonify: ^1.0.1 lodash.merge: 4.6.2 mocha: ^10.4.0