Repository navigation
Description
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 (8xprefer-const, 1xpromise/always-return)packages/google-storage-control/src/v2/storage_client.ts→ 37 errors (9xprefer-const, 1xpromise/always-return, 20xprettier/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: dec0756bf04ff1cb881cd7a8a51c538fd5d25daedd1b65d93800632d85baddeaSo the sequence is:
- Fix the four templates (cjs + esm) and update generator baselines
- Cut a new
gapic-generator-v*tag - Bump
version+checksuminlibrarian.yaml - Drop the
@typescript-eslint/no-floating-promisesandprefer-constlines 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
chore(lint): document removal condition for generated-GAPIC override