From b6c836617ab3b2a11a314981b4aec80421c55e6b Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Tue, 14 Jan 2025 16:28:39 -0700 Subject: [PATCH] Update ESLint warning thresholds, and produce them consistently The ESLint warning thresholds file records warnings that were produced the last time that `eslint` was run, categorizing them by rule. This file should be kept up to date at all times so we can know whether new code changes introduce a regression in the number of warnings or an improvement. Specifically, the lint step will now fail if more warnings are introduced to the codebase. However, in the past we have observed inconsistencies in the behavior of ESLint across different people's machines as well as in CI. With the addition of the quality gate this means that some people are unable to merge PRs because warnings are produced that are not seen in development, and the warnings may not be reproducible by other developers. With that said, we recently learned that if `dist` directories are present from a previous run of `yarn build`, it could affect the behavior of the TypeScript-specific lint rules and cause the observed inconsistencies. To mitigate this problem, this commit ensures that all `dist` directories are removed before running `eslint`. This indeed does change the number of warnings produced, and the thresholds file has been updated to reflect this. --- eslint-warning-thresholds.json | 6 ++---- package.json | 5 +++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/eslint-warning-thresholds.json b/eslint-warning-thresholds.json index fc7d2173b6..92cc78a3f7 100644 --- a/eslint-warning-thresholds.json +++ b/eslint-warning-thresholds.json @@ -2,16 +2,14 @@ "@typescript-eslint/consistent-type-exports": 19, "@typescript-eslint/no-base-to-string": 3, "@typescript-eslint/no-duplicate-enum-values": 2, - "@typescript-eslint/no-misused-promises": 3, - "@typescript-eslint/no-unsafe-enum-comparison": 59, + "@typescript-eslint/no-unsafe-enum-comparison": 34, "@typescript-eslint/no-unused-vars": 36, "@typescript-eslint/prefer-promise-reject-errors": 13, "@typescript-eslint/prefer-readonly": 145, - "@typescript-eslint/switch-exhaustiveness-check": 10, "import-x/namespace": 189, "import-x/no-named-as-default": 1, "import-x/no-named-as-default-member": 8, - "import-x/order": 209, + "import-x/order": 205, "jest/no-conditional-in-test": 129, "jest/prefer-lowercase-title": 2, "jest/prefer-strict-equal": 2, diff --git a/package.json b/package.json index a52e92956a..67464d8c8b 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ ], "scripts": { "build": "yarn ts-bridge --project tsconfig.build.json --verbose", - "build:clean": "rimraf dist '**/*.tsbuildinfo' && yarn build", + "build:clean": "yarn build:only-clean && yarn build", + "build:only-clean": "rimraf -g 'packages/*/dist'", "build:docs": "yarn workspaces foreach --all --no-private --parallel --interlaced --verbose run build:docs", "build:types": "tsc --build tsconfig.build.json --verbose", "changelog:update": "yarn workspaces foreach --all --no-private --parallel --interlaced --verbose run changelog:update", @@ -23,7 +24,7 @@ "lint": "yarn lint:eslint && yarn lint:misc --check && yarn constraints && yarn lint:dependencies && yarn lint:teams", "lint:dependencies": "depcheck && yarn dedupe --check", "lint:dependencies:fix": "depcheck && yarn dedupe", - "lint:eslint": "yarn ts-node ./scripts/run-eslint.ts --cache", + "lint:eslint": "yarn build:only-clean && yarn ts-node ./scripts/run-eslint.ts --cache", "lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write && yarn constraints --fix && yarn lint:dependencies:fix", "lint:misc": "prettier --no-error-on-unmatched-pattern '**/*.json' '**/*.md' '**/*.yml' '!.yarnrc.yml' '!merged-packages/**' --ignore-path .gitignore", "lint:teams": "ts-node scripts/lint-teams-json.ts",