Skip to content

Commit

Permalink
Update ESLint warning thresholds, and produce them consistently (#5151)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mcmire authored Jan 15, 2025
1 parent f92d7a3 commit f418952
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 2 additions & 4 deletions eslint-warning-thresholds.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit f418952

Please sign in to comment.