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:
- Fix the four templates (cjs + esm) and update generator baselines
- Cut a new
gapic-generator-v* tag
- Bump
version + checksum in librarian.yaml
- 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.
Split out from #9429, which works around this with an
.eslintrc.jsonoverride.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).promise/always-returntemplates/{cjs,esm}/typescript_gapic/src/$version/$service_client.ts.njk(close())return this.xStub.then(stub => { ... })— callback returns nothingpromise/always-returntemplates/{cjs,esm}/typescript_gapic/test/gapic_$service_$version.ts.njk(bothclose()tests)client.close().then(() => { done(); })@typescript-eslint/no-floating-promisesclient.getLocation(req, opts, cb)— the callback overload still types as returningPromiseprefer-consttemplates/{cjs,esm}/typescript_gapic/_util.njk:268let routingParameter = {}is only everObject.assign'd — plain bugLatent debt
bin/linter.mjsis diff-scoped (eslint.lintFiles()on changed files only), so checked-in generated code already carries violations CI never sees. Untouched files onmaintoday: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/prettiercount suggests the templates have formatting drift beyond these four rules; worth a full audit.Removing the workaround
Fixing the templates on
mainis not sufficient.librarian.yamlpins the generator to a repo tag fetched as a checksummed tarball:So the sequence is:
gapic-generator-v*tagversion+checksuminlibrarian.yaml@typescript-eslint/no-floating-promisesandprefer-constlines from the generated-GAPIC override in.eslintrc.jsonNote 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-packageroot: trueconfigs were deleted), so those can stay off permanently or be dropped in the same step — either is defensible.