Skip to content

build(lint): add ESLint flat configs for both workspaces#320

Merged
robert-cronin merged 6 commits into
kaito-project:mainfrom
surajssd:suraj/fix-bun-issues
Jun 15, 2026
Merged

build(lint): add ESLint flat configs for both workspaces#320
robert-cronin merged 6 commits into
kaito-project:mainfrom
surajssd:suraj/fix-bun-issues

Conversation

@surajssd

@surajssd surajssd commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Description

bun run lint was broken: ESLint 9+ no longer reads .eslintrc.*, and the repo had no flat config in either workspace (the backend was 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 both frontend and backend pass bun run lint cleanly with no behavior change.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📚 Documentation update
  • 🎨 UI/UX improvement
  • ♻️ Refactoring (no functional changes)
  • 🧪 Test update
  • 🔧 Build/CI configuration

Changes Made

ESLint flat configs (build tooling)

  • Added frontend/eslint.config.js with typescript-eslint flat/recommended plus the react-hooks and react-refresh rules (loaded as ESM since the package is "type": "module")
  • Added backend/eslint.config.mjs with typescript-eslint flat/recommended (uses the .mjs extension because the backend package is CommonJS)
  • Added @typescript-eslint/parser and @typescript-eslint/eslint-plugin as backend dev dependencies (updating bun.lock) — the parser was previously absent, so the backend could not lint TypeScript at all
  • Enabled @typescript-eslint/no-unused-vars with argsIgnorePattern: '^_' in both configs so intentionally-unused _-prefixed identifiers are allowed

Backend — replace any with real types

  • Replaced the loosely-typed error handling across services with the existing lib/k8s-errors helpers (getK8sErrorStatusCode, extractK8sErrorMessage) and retyped the local getK8sStatusCode/getK8sErrorMessage helpers in kubernetes.ts to accept unknown instead of any
  • Introduced precise local types for untyped Kubernetes objects: InferenceProviderConfigResource and TlsFetchOptions in kubernetes.ts, ProviderConfigLike/ProviderCondition in providerHealth.ts, and CR/annotation shapes in installation.ts
  • Typed the K8s client TLS interop in kubernetes.ts against node:https RequestOptions and removed unnecessary as any casts (e.g. numeric ports in registry.ts, which already accept IntOrString)
  • Tightened the writable cast in kubeconfig.ts used to strip client certificates

Backend — remove unused code

  • Removed dead imports and variables (isCompiled in logger.ts, unused imports in autoscaler.ts, costEstimation.ts, huggingface.ts, and several *.test.ts files) and a stale eslint-disable directive in kubernetes.ts

Frontend — lint fixes

  • Memoized gpuRecommendation with useMemo in DeploymentForm.tsx and corrected the useEffect/useCallback dependency arrays
  • Converted the empty InputProps interface to a type alias in input.tsx, restructured the useToast.ts action types, replaced (window as any) with a typed cast in main.tsx, and simplified unused catch bindings in CostEstimate.tsx and useAuth.ts

Tests — replace mock any casts

  • Replaced as any mock casts with typed accessors and real types (DeploymentConfig, HelmChart, V1Pod, K8sCallArg) across the backend test suite, and tightened the mockServiceMethod generic constraint in test/helpers.ts

Testing

  • Unit tests pass (bun run test)
  • Manual testing performed
  • Tested with a Kubernetes cluster

bun run test passes: 128 frontend tests and 723 backend tests, 0 failures. Type safety was verified by establishing a tsc baseline before the changes and confirming zero new type errors after.

Checklist

  • My code follows the project's style guidelines
  • I have run bun run lint
  • I have added tests that prove my fix/feature works
  • New and existing unit tests pass locally
  • I have updated documentation if needed
  • My changes generate no new warnings

Additional Notes

  • This is a behavior-preserving cleanup; the only functional adjustment is the gpuRecommendation memoization in DeploymentForm.tsx, which stabilizes object identity so the effect dependency arrays are correct.
  • No new tests were added because the change is a lint/type-safety refactor; correctness is covered by the existing suite, which continues to pass.
  • Pre-existing tsc errors unrelated to this PR (e.g. Cannot find name 'Bun', the moduleResolution deprecation) remain, as the project builds via Bun's transpiler rather than tsc.

Copilot AI review requested due to automatic review settings June 8, 2026 23:58
@surajssd surajssd requested a review from a team as a code owner June 8, 2026 23:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.js and backend/eslint.config.mjs with typescript-eslint flat/recommended configs, plus react-hooks/react-refresh rules for the frontend
  • Replaced all any types in backend services with narrow local interfaces (InferenceProviderConfigResource, TlsFetchOptions, ClusterAutoscalerStatus, ProviderConfigResource, etc.) and leveraged the existing k8s-errors helpers
  • Fixed frontend lint issues: memoized gpuRecommendation with useMemo to stabilize effect dependencies, corrected useCallback dependency 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.

Copilot AI review requested due to automatic review settings June 9, 2026 16:56
@surajssd surajssd force-pushed the suraj/fix-bun-issues branch from c87a3c6 to e2b35a8 Compare June 9, 2026 16:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 40 out of 41 changed files in this pull request and generated 1 comment.

Comment thread backend/src/services/autoscaler.ts Outdated
@surajssd surajssd force-pushed the suraj/fix-bun-issues branch from e2b35a8 to 9dc3695 Compare June 9, 2026 17:35
Copilot AI review requested due to automatic review settings June 9, 2026 21:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 41 out of 42 changed files in this pull request and generated no new comments.

@surajssd surajssd added this to the 0.7.0 milestone Jun 9, 2026
Copilot AI review requested due to automatic review settings June 10, 2026 18:52
@surajssd surajssd force-pushed the suraj/fix-bun-issues branch from 2a0ca8e to 1d65fe1 Compare June 10, 2026 18:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 41 out of 42 changed files in this pull request and generated no new comments.

@surajssd surajssd requested a review from robert-cronin June 10, 2026 22:14
@surajssd surajssd force-pushed the suraj/fix-bun-issues branch from 1d65fe1 to 2c55a0e Compare June 11, 2026 00:30
Copilot AI review requested due to automatic review settings June 11, 2026 00:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 40 out of 40 changed files in this pull request and generated no new comments.

@robert-cronin robert-cronin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on my local, all green, but it looks like eslint config might have been duplicated, left a comment to address that otherwise lgtm

Comment thread frontend/eslint.config.js Outdated
surajssd and others added 6 commits June 11, 2026 13:08
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>
@surajssd surajssd force-pushed the suraj/fix-bun-issues branch from 5de4684 to f01dccf Compare June 11, 2026 20:23
@surajssd surajssd requested a review from robert-cronin June 11, 2026 22:06
@robert-cronin robert-cronin merged commit c5a4422 into kaito-project:main Jun 15, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants