Skip to content

chore(FR-2790): add ESLint flat config to backend.ai-client#7204

Open
yomybaby wants to merge 1 commit intomainfrom
04-30-chore_fr-2790_add_eslint_flat_config_to_backend.ai-client
Open

chore(FR-2790): add ESLint flat config to backend.ai-client#7204
yomybaby wants to merge 1 commit intomainfrom
04-30-chore_fr-2790_add_eslint_flat_config_to_backend.ai-client

Conversation

@yomybaby
Copy link
Copy Markdown
Member

@yomybaby yomybaby commented Apr 30, 2026

Resolves #7197(FR-2790)

Epic: FR-2792 (backend.ai-client production readiness)

Summary

Adds an ESLint 9 flat config to packages/backend.ai-client/ so the existing pnpm lint script (and therefore prepublishOnly) actually validates the source. Without this, lint either no-ops or picks up an unrelated config and prepublishOnly is a misleading green light.

Changes

  • packages/backend.ai-client/eslint.config.js — flat config (type: module) extending eslint-config-bai base, with package-specific overrides:
    • @typescript-eslint/consistent-type-imports: error
    • @typescript-eslint/no-floating-promises: error (with parserOptions.projectService for type info)
    • @typescript-eslint/no-explicit-any: warn (overrides the shared base's off; the strict-typing pass is intentionally a separate ticket so existing any use is visible but not blocking)
    • **/*.test.ts files relax no-floating-promises and no-explicit-any.
  • package.json — drops --max-warnings=0 from the lint script (warnings are expected during the strict-typing migration), adds @eslint/js (catalog), eslint-config-bai (workspace), and typescript-eslint (catalog) as devDependencies.
  • Lint-driven source fixes (mechanical, surfaced by the new rules):
    • src/client.tsObjectobject parameter type; [^\w\-][^\w-] (unnecessary escape).
    • src/client.tsopts: object = {} default to match the JSDoc-declared optionality.
    • src/resources/pipeline.tsresult.hasOwnProperty('token')Object.prototype.hasOwnProperty.call(...) (avoids no-prototype-builtins).

Lint status

pnpm --filter backend.ai-client lint — 0 errors, 242 warnings (exit 0). All 242 warnings are no-explicit-any from pre-existing : any annotations and are explicitly out of scope.

Out of scope

  • Removing all any (separate epic — there are 242 of them).
  • Tightening tsconfig.strict (separate ticket).
  • Pre-existing bug in Pipeline.login (always returns false even on success) — filed as FR-2793 under the same Epic, since it's pre-existing in origin/main and not introduced by this PR.

Verification

  • pnpm --filter backend.ai-client lint — 0 errors / 242 warnings.
  • pnpm --filter backend.ai-client test — 4/4 pass.
  • pnpm --filter backend.ai-client build — ESM 174.99 KB + DTS 65.36 KB.
  • Sanity: introduced a deliberate floating-promise / explicit-any in a temp file, confirmed lint flagged them, reverted.
  • bash scripts/verify.sh — Relay/Lint/Format pass; TypeScript pre-existing errors are unrelated.

Copy link
Copy Markdown
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • flow:merge-queue - adds this PR to the back of the merge queue
  • flow:hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions Bot added the size:M 30~100 LoC label Apr 30, 2026
@yomybaby yomybaby marked this pull request as ready for review April 30, 2026 16:25
Copilot AI review requested due to automatic review settings April 30, 2026 16:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an ESLint 9 flat configuration to packages/backend.ai-client (reusing the repo’s shared eslint-config-bai) and makes a few small source tweaks to satisfy/align with the new linting rules in this package.

Changes:

  • Add packages/backend.ai-client/eslint.config.js (flat config) extending eslint-config-bai with a few package-specific rule overrides and type-aware linting settings.
  • Update packages/backend.ai-client/package.json to use the flat config and add required dev dependencies.
  • Minor lint-driven code adjustments in the client library (safer hasOwnProperty usage, type tweak, regex simplification).

Reviewed changes

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

File Description
packages/backend.ai-client/src/resources/pipeline.ts Adjusts token presence check to avoid no-prototype-builtins pattern.
packages/backend.ai-client/src/client.ts Tweaks execute() options parameter type and a slugify regex.
packages/backend.ai-client/package.json Adds flat-config-related dev deps and updates lint script.
packages/backend.ai-client/eslint.config.js Introduces ESLint flat config extending shared base + rule overrides.
Comments suppressed due to low confidence (1)

packages/backend.ai-client/src/resources/pipeline.ts:50

  • Pipeline.login() always resolves false even when a token is returned (it sets the cookie and then still returns false). This makes successful logins indistinguishable from failures. Align this with the node client implementation by resolving true when the token exists.
      if (!Object.prototype.hasOwnProperty.call(result, 'token')) {
        return Promise.resolve(false);
      } else {
        const token = result.token;
        document.cookie = `${this.tokenName}=${token}; path=/`;
        return Promise.resolve(false);
      }

Comment thread packages/backend.ai-client/src/client.ts Outdated
@yomybaby yomybaby force-pushed the 04-30-chore_fr-2790_add_eslint_flat_config_to_backend.ai-client branch from 32cce11 to be19d10 Compare April 30, 2026 16:35
@yomybaby
Copy link
Copy Markdown
Member Author

Re: Copilot's suppressed comment on packages/backend.ai-client/src/resources/pipeline.ts:50 (Pipeline.login resolving false on success) — confirmed pre-existing on origin/main (introduced in #6614 / FR-2529 extraction), so out of scope for this lint/config PR. Filed as FR-2793 under the same Epic FR-2792 for a focused fix + unit test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30~100 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ESLint flat config to backend.ai-client package

2 participants