chore(frontend): add ESLint config, fix findings, and gate lint in CI - #1353
Conversation
|
Important Review skippedNo new commits to review since the last review. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughAdds an ESLint configuration (.eslintrc.json) and ignore file (.eslintignore) for the frontend, wires a lint step into the CI workflow before typecheck/build, and applies minor code changes (const bindings, updated comments, non-null assertion) to satisfy lint rules. ChangesESLint setup and lint fixes
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Observation for a possible follow-up: the removed |
|
@coderabbitai review |
✅ Action performedReview finished.
|
What was missing
frontend/package.jsondeclared"lint": "eslint src/**/*.ts"witheslint ^8.50and@typescript-eslint ^6as dev-dependencies, but no ESLint config file existed anywhere infrontend/. Runningnpm run lintproduced "Oops! Something went wrong!" and exited non-zero. ESLint was also absent from the CI workflow (frontend-build.yml).Config format decision
Uses the legacy
.eslintrc.jsonformat (ESLint 8.x default). This works under both@typescript-eslintv6 (currentmain) and v8 (pending PR #1345, which bumps@typescript-eslintwhile keepingeslint ^8.50). ESLint 8.x picks up legacy config automatically without any opt-in flag. Flat config (eslint.config.js) is opt-in on ESLint 8 and belongs with a future ESLint 9 upgrade — that migration is out of scope here.Config choices:
root: true— prevents ESLint from walking up to any parent config@typescript-eslint/parserwithecmaVersion: 2020, sourceType: moduleplugin:@typescript-eslint/recommended(non-type-aware; noparserOptions.project) — avoids the performance cost of type-checked rules on a codebase of this size; the type-aware ruleset can be added incrementally laterenv: browser, jest, es2020.eslintignoreadded to excludewebpack.config.js(CommonJS, not insrc/) anddist/.Rules adjusted and why
@typescript-eslint/no-explicit-any"warn"(downgraded from default"error")anyheavily at DOM and API boundaries across ~90 sites; fixing all of them is a separate undertaking outside this PR's scope@typescript-eslint/no-unused-vars["error", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }]@typescript-eslint/no-var-requires"off"inoverridesforsrc/__tests__/**/*.tsjest.mock(...)+require()inside test bodies/hooks) requires callingrequire()at runtime after the mock is installed; static ESMimportcannot replicate this pattern@typescript-eslint/no-require-imports"off"inoverridesforsrc/__tests__/**/*.tsAll other
plugin:@typescript-eslint/recommendedrules remain at their default severity.Source fixes (zero blanket suppressions)
src/settings.ts:161let savedSnapshot→const savedSnapshot(prefer-const: never reassigned, only mutated via index)src/users/state.ts:20export let selectedUserIds→export const selectedUserIds(prefer-const: Set is only mutated via.add/.clear/.delete, never reassigned)src/__tests__/recommendations.test.ts:1296firstRow?.querySelector(...)!→firstRow!.querySelector(...)!(fixesno-non-null-asserted-optional-chain: optional chain combined with non-null assertion is contradictory; the row is guaranteed to exist afterloadRecommendations())src/users/userList.ts:242,341// eslint-disable-next-line no-unsanitized/propertywith plain explanatory comments. ESLint 8 reports an error for disable comments referencing rules from uninstalled plugins;eslint-plugin-no-unsanitizedis not a project dependencyCI change
Added a
Lintstep to.github/workflows/frontend-build.ymlbefore the existingTypeScript typecheckstep, matching the existing step style.Verification
Note on PR #1345 lockfile
This PR adds no new npm dependencies (config only). The
package-lock.jsonis untouched. PR #1345 (which bumps@typescript-eslintto ^8) will produce its own lockfile update; the two do not conflict since the.eslintrc.jsonformat used here is compatible with both v6 and v8 under ESLint 8.x.Closes #1350
Summary by CodeRabbit