Skip to content

gapic-generator-typescript emits ESLint-violating output (promise/*, prefer-const) #9432

Description

@bshaffer

Split out from #9429, which works around this with an .eslintrc.json override.

Problem

Four generator templates emit code that violates the repo's root ESLint config, so every librarian regeneration PR fails bin/linter.mjs --strict (#9427 had 59 errors).

Rule Template Issue
promise/always-return templates/{cjs,esm}/typescript_gapic/src/$version/$service_client.ts.njk (close()) return this.xStub.then(stub => { ... }) — callback returns nothing
promise/always-return templates/{cjs,esm}/typescript_gapic/test/gapic_$service_$version.ts.njk (both close() tests) client.close().then(() => { done(); })
@typescript-eslint/no-floating-promises same test template, Locations/IAM mixin callback tests client.getLocation(req, opts, cb) — the callback overload still types as returning Promise
prefer-const templates/{cjs,esm}/typescript_gapic/_util.njk:268 let routingParameter = {} is only ever Object.assign'd — plain bug

Latent debt

bin/linter.mjs is diff-scoped (eslint.lintFiles() on changed files only), so checked-in generated code already carries violations CI never sees. Untouched files on main today:

  • packages/google-cloud-run/src/v2/jobs_client.ts → 9 errors (8x prefer-const, 1x promise/always-return)
  • packages/google-storage-control/src/v2/storage_client.ts → 37 errors (9x prefer-const, 1x promise/always-return, 20x prettier/prettier)

16 checked-in files contain let routingParameter.

The prettier/prettier count suggests the templates have formatting drift beyond these four rules; worth a full audit.

Removing the workaround

Fixing the templates on main is not sufficient. librarian.yaml pins the generator to a repo tag fetched as a checksummed tarball:

- name: gapic-generator-typescript
  version: gapic-generator-v5.5.0
  package: https://github.com/googleapis/google-cloud-node/archive/gapic-generator-v5.5.0.tar.gz
  checksum: dec0756bf04ff1cb881cd7a8a51c538fd5d25daedd1b65d93800632d85baddea

So the sequence is:

  1. Fix the four templates (cjs + esm) and update generator baselines
  2. Cut a new gapic-generator-v* tag
  3. Bump version + checksum in librarian.yaml
  4. Drop the @typescript-eslint/no-floating-promises and prefer-const lines from the generated-GAPIC override in .eslintrc.json

Note the two promise/* lines are a restoration of pre-#8458 behavior (the promise plugin was added to the root config in #8446, three weeks after per-package root: true configs were deleted), so those can stay off permanently or be dropped in the same step — either is defensible.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions