build(lint): add ESLint flat configs for both workspaces#320
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes broken bun run lint in both frontend and backend workspaces by adding ESLint 9+ flat configuration files, then resolves all surfaced lint findings (replacing any casts with precise types, removing unused code, fixing React hook dependency arrays). All changes are behavior-preserving and verified by the existing test suite (128 frontend + 723 backend tests passing).
Changes:
- Added
frontend/eslint.config.jsandbackend/eslint.config.mjswith typescript-eslint flat/recommended configs, plus react-hooks/react-refresh rules for the frontend - Replaced all
anytypes in backend services with narrow local interfaces (InferenceProviderConfigResource,TlsFetchOptions,ClusterAutoscalerStatus,ProviderConfigResource, etc.) and leveraged the existingk8s-errorshelpers - Fixed frontend lint issues: memoized
gpuRecommendationwithuseMemoto stabilize effect dependencies, correcteduseCallbackdependency arrays, removed unused variables and imports
Reviewed changes
Copilot reviewed 37 out of 38 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/eslint.config.js | New ESLint flat config for React + TypeScript frontend |
| backend/eslint.config.mjs | New ESLint flat config for Bun + Hono backend |
| backend/package.json | Added @typescript-eslint/eslint-plugin and @typescript-eslint/parser dev deps |
| bun.lock | Updated lockfile for new dependencies and resolved ignore version |
| frontend/src/components/deployments/DeploymentForm.tsx | useMemo for gpuRecommendation, corrected dependency arrays |
| frontend/src/hooks/useToast.ts | Converted runtime actionTypes object to pure type alias |
| frontend/src/components/ui/input.tsx | Converted empty interface to type alias |
| frontend/src/main.tsx | Replaced (window as any) with typed window extension |
| frontend/src/hooks/useAuth.ts | Removed unused catch binding |
| frontend/src/components/deployments/CostEstimate.tsx | Removed unused catch binding |
| backend/src/services/kubernetes.ts | Added local types, replaced any casts with proper typing, removed stale eslint-disable |
| backend/src/services/secrets.ts | Switched to getK8sErrorStatusCode/K8sApiError from k8s-errors |
| backend/src/services/registry.ts | Same error-handling pattern, removed as any on ports |
| backend/src/services/providerHealth.ts | Added ProviderCondition/ProviderConfigLike types |
| backend/src/services/autoscaler.ts | Added ClusterAutoscalerStatus type, switched to getK8sErrorStatusCode |
| backend/src/routes/installation.ts | Added ProviderConfigResource/InstallationAnnotation types, filter invalid helm repos |
| backend/src/routes/oauth.ts | Removed unused route handler parameter |
| backend/src/routes/autoscaler.ts | Removed unused imports |
| backend/src/routes/costs.ts | Removed unused totalGpus variable |
| backend/src/services/costEstimation.ts | Removed unused imports and constant |
| backend/src/services/huggingface.ts | Removed unused import |
| backend/src/services/aiconfigurator.ts | Prefixed unused _stdout parameter |
| backend/src/lib/logger.ts | Removed dead isCompiled function |
| backend/src/lib/kubeconfig.ts | Replaced as any with narrow writable cast |
| backend/src/test/helpers.ts | Tightened generic constraint from any to unknown |
| backend/src/services/kubernetes.test.ts | Added typed MockableKubernetesService, K8sCallArg, used V1Pod |
| backend/src/services/kubernetes-runtime-status.test.ts | Added typed mock helpers |
| backend/src/services/kubernetes-gateway.test.ts | Typed stub arg shapes |
| backend/src/services/kubernetes-enhanced.test.ts | Removed unused import |
| backend/src/services/helm.test.ts | Typed private method stubs |
| backend/src/services/modelCompatibility.test.ts | Removed unused import, removed as any |
| backend/src/services/aikit.test.ts | Replaced as any with indexed access type |
| backend/src/services/cloudPricing.test.ts | Removed unused import |
| backend/src/services/auth.test.ts | Removed unused import |
| backend/src/services/aiconfigurator.test.ts | Removed unused imports |
| backend/src/routes/installation.test.ts | Used HelmChart type for captured arrays |
| backend/src/routes/deployments.test.ts | Used DeploymentConfig type for captured config |
| backend/src/hono-app.test.ts | Removed unused import |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c87a3c6 to
e2b35a8
Compare
e2b35a8 to
9dc3695
Compare
2a0ca8e to
1d65fe1
Compare
1d65fe1 to
2c55a0e
Compare
robert-cronin
left a comment
There was a problem hiding this comment.
Verified on my local, all green, but it looks like eslint config might have been duplicated, left a comment to address that otherwise lgtm
ESLint 9+ no longer reads .eslintrc.*, so bun run lint failed with no config present. Add the flat configs and the parser the backend was missing. - frontend: add eslint.config.js with typescript-eslint flat/recommended plus the react-hooks and react-refresh rules - backend: add eslint.config.mjs (.mjs since the package is CommonJS) with typescript-eslint flat/recommended - backend: add @typescript-eslint/parser and @typescript-eslint/eslint-plugin dev dependencies, updating bun.lock
Make both workspaces pass bun run lint cleanly by resolving every ESLint finding surfaced once the flat configs were active. - eslint config: allow _-prefixed identifiers via the no-unused-vars argsIgnorePattern in both the frontend and backend configs - backend: replace any with typed shapes (InferenceProviderConfigResource, ProviderConfigLike, TlsFetchOptions) and route error handling through getK8sStatusCode/getK8sErrorMessage and lib/k8s-errors - backend: drop unused imports/variables and a stale eslint-disable - frontend: convert the empty InputProps interface to a type alias and restructure the useToast action types - frontend: memoize gpuRecommendation and correct the useEffect/ useCallback dependency arrays in DeploymentForm - tests: replace mock any casts with typed accessors and fixtures Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
- add test-coverage, test-coverage-backend, and test-coverage-frontend targets to the Makefile, reusing each workspace's test:coverage script - route the CI coverage steps through make test-coverage-* and fix exit-code masking with set -o pipefail + tee, so a failing suite now fails the job while the step-summary section stays well-formed - add a dedicated web-ui-lint job that runs make lint on every push and PR Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
The package.json `verify-versions` script is literally `make verify-versions`, so `bun run verify-versions` was redundant indirection. Call the make target directly so the Makefile stays the single source of truth for CI checks. Signed-off-by: Suraj Deshmukh <suraj.deshmukh@microsoft.com>
The `GET /api/installation/helm/status` test called the real route, which spawns the `helm` binary. On CI runners without helm the spawn hangs until Bun's 5000ms per-test timeout, failing the suite. (This was masked before the coverage step started propagating exit codes.) Mock `helmService.checkHelmAvailable` with a local restore, matching the pattern used throughout installation.test.ts, so the test is deterministic and no longer depends on helm being installed. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
PR kaito-project#311 added frontend/eslint.config.mjs to main; this branch independently added frontend/eslint.config.js. With both present ESLint silently loads only the .js and ignores the .mjs. Merge into the single .mjs (keeping kaito-project#311's parser/JSX wiring and react-hooks recommended set) and delete the .js. The rules this PR cleaned up — no-explicit-any, no-empty-object-type, no-unused-vars (with argsIgnorePattern '^_') — are promoted to errors so they cannot regress; the experimental react-hooks React-Compiler rules stay warnings per kaito-project#311's backlog decision. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
5de4684 to
f01dccf
Compare
Description
bun run lintwas broken: ESLint 9+ no longer reads.eslintrc.*, and the repo had no flat config in either workspace (thebackendwas also missing the TypeScript parser entirely), so linting crashed before it could run. This PR adds the missing ESLint flat configs and then resolves every finding the now-working linter surfaced, so bothfrontendandbackendpassbun run lintcleanly with no behavior change.Type of Change
Changes Made
ESLint flat configs (build tooling)
frontend/eslint.config.jswith typescript-eslintflat/recommendedplus thereact-hooksandreact-refreshrules (loaded as ESM since the package is"type": "module")backend/eslint.config.mjswith typescript-eslintflat/recommended(uses the.mjsextension because the backend package is CommonJS)@typescript-eslint/parserand@typescript-eslint/eslint-pluginasbackenddev dependencies (updatingbun.lock) — the parser was previously absent, so the backend could not lint TypeScript at all@typescript-eslint/no-unused-varswithargsIgnorePattern: '^_'in both configs so intentionally-unused_-prefixed identifiers are allowedBackend — replace
anywith real typeslib/k8s-errorshelpers (getK8sErrorStatusCode,extractK8sErrorMessage) and retyped the localgetK8sStatusCode/getK8sErrorMessagehelpers inkubernetes.tsto acceptunknowninstead ofanyInferenceProviderConfigResourceandTlsFetchOptionsinkubernetes.ts,ProviderConfigLike/ProviderConditioninproviderHealth.ts, and CR/annotation shapes ininstallation.tskubernetes.tsagainstnode:httpsRequestOptionsand removed unnecessaryas anycasts (e.g. numeric ports inregistry.ts, which already acceptIntOrString)kubeconfig.tsused to strip client certificatesBackend — remove unused code
isCompiledinlogger.ts, unused imports inautoscaler.ts,costEstimation.ts,huggingface.ts, and several*.test.tsfiles) and a staleeslint-disabledirective inkubernetes.tsFrontend — lint fixes
gpuRecommendationwithuseMemoinDeploymentForm.tsxand corrected theuseEffect/useCallbackdependency arraysInputPropsinterface to a type alias ininput.tsx, restructured theuseToast.tsaction types, replaced(window as any)with a typed cast inmain.tsx, and simplified unusedcatchbindings inCostEstimate.tsxanduseAuth.tsTests — replace mock
anycastsas anymock casts with typed accessors and real types (DeploymentConfig,HelmChart,V1Pod,K8sCallArg) across the backend test suite, and tightened themockServiceMethodgeneric constraint intest/helpers.tsTesting
bun run test)bun run testpasses: 128 frontend tests and 723 backend tests, 0 failures. Type safety was verified by establishing atscbaseline before the changes and confirming zero new type errors after.Checklist
bun run lintAdditional Notes
gpuRecommendationmemoization inDeploymentForm.tsx, which stabilizes object identity so the effect dependency arrays are correct.tscerrors unrelated to this PR (e.g.Cannot find name 'Bun', themoduleResolutiondeprecation) remain, as the project builds via Bun's transpiler rather thantsc.