Repository navigation
Enforce function length, nullish coalescing and no-console with Biome - #1585
Merged
cristianrgreco merged 5 commits intoOct 13, 2026
Merged
Conversation
…tyle-with-biome-d40615
…tyle-with-biome-d40615 # Conflicts: # packages/testcontainers/src/container-runtime/clients/container/docker-container-client.ts
cristianrgreco
marked this pull request as ready for review
October 12, 2026 18:35
The rules live in biome.json. AGENTS.md keeps only the guidance that config can't express: fix a violation rather than suppressing it.
This was referenced Oct 12, 2026
Merged
cristianrgreco
deleted the
claude/enforce-code-style-with-biome-d40615
branch
October 13, 2026 09:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enables three Biome rules at
error, so conventions that were only written down (#1517) are checked bynpm run lintand theLintjob. Every existing violation is fixed rather than suppressed: there is nobiome-ignoreand no per-file exemption for these rules.complexity/noExcessiveLinesPerFunction(maxLines: 50)*.test.ts, 7 in source)*.test.ts, 7 refactorednursery/useNullishCoalescingsuspicious/noConsoleFunction length
The rule is off for
**/*.test.ts. 64 of the 68 hits there aredescribecallbacks, which wrap a whole suite and cannot be shortened, and the rule has no option to skip callbacks. The other 4 are twoitbodies, oneit.eachbody and one mock factory. The seven long functions are split by extracting phases into private helpers placed below their caller. The statements are moved, not rewritten.CouchbaseContainer.createBucketscreateBucket,waitUntilBucketHasEnabledServices,waitUntilBucketIsHealthy,waitUntilKeyspaceIsPresent,createPrimaryIndex,waitUntilPrimaryIndexIsOnlineDockerComposeEnvironment.upcreateCommandOptions,createComposeOptions,waitForStartedContainers,toStartedGenericContainerAzuriteContainer.startcreateCommand,configureSslGenericContainer.startContainerconnectContainerToNetworks,copyToCreatedContainer,consumeContainerLogsDockerContainerClient.execcreateExecOptions,waitForExecStreamToEndinitStrategyincontainer-runtime/clients/client.tscreateInfoHttpWaitStrategy.waitUntilReadysendRequest,matchesPredicatesThree statements moved relative to code with no side effects, which cannot be observed:
DockerComposeEnvironment.upcallspullPolicy.shouldPull()before building the command options array, not between two pushes to it.initStrategybuilt thenodeInfoliteral (process.version,arch,platform) before looking up host IPs.createInfobuilds it afterwards, together with the runtime info.CouchbaseContainer.createBucketsreadsremainingStartupMs()for the two HTTP waits when it calls the helper, not part-way through building the wait strategy. Nothing is awaited in between.createBucketswas 137 lines when this PR was opened and 157 after #1514.Nullish coalescing
Both sites behave the same with
??:ValkeyContainer.importInitialData:this.password || "". The left side isstring | undefined, and an empty string yields""either way.StartedGenericContainer.getContainerCommitChangeCommands:options.changes || []. The left side isstring[] | undefined, and an array is never falsy.Console
StartedCloudStorageEmulatorContainer.processServerConfigChangeandStartedPostgreSqlContainer.execCommandsSQLnow uselogfromtestcontainers, at the same level (warn,error) with the same message. PostgreSQL appends the error to the message, becauselog.errortakes one string.overridesentry enables it forpackages/**/src/**, excludingpackages/testcontainers/src/common/logger.ts. That file is the logger and bindsconsole.logas its sink. Files outside package source are not covered, such aspackages/testcontainers/smoke-test.js, which prints its failure before exiting non-zero.Couchbase
The first revision of this PR left
packages/modules/couchbase/src/couchbase-container.tsalone, because #1514 was rewriting it, and carried a temporaryoverridesentry for that file. #1514 has merged, somainis merged in, the entry is gone and the file is fixed like the others.Left out:
style/useConsistentMemberAccessibilityWith
accessibility: "explicit"it reports 237 members in 88 files. 128 of them are constructors, and the rule has no option to exempt constructors, so it would forcepublic constructor(...)everywhere.Follow-up
#1517 has not merged, so
.agents/skills/write-code/SKILL.mdis not edited here. Once it is onmain, its bullets on function length,??andconsoleshould say Biome enforces them. InAGENTS.md, the bullets that listed Biome rules (import boundaries, import cycles) are replaced by one line: fix a lint violation rather than suppressing it. The rules themselves live inbiome.json.Verification
main. The second merge (Replace hand-rolled stream handling with Node stream built-ins #1566) conflicted on one import line indocker-container-client.ts.npm run format: no changes.npm run lintandnpm run lint:ci: pass.npm run knip: pass.npm run check-compiles: pass.console.logand a||default, checked withbiome ci --error-on-warnings:packages/testcontainers/src/andpackages/modules/redis/src/: 3 errors, one per rule*.test.ts: 2 errors (function length is off).github/scripts/and aspackages/testcontainers/smoke-test.*: 2 errors (noConsoledoes not apply)it.skip).npx vitest run packages/modules/couchbase/src/couchbase-container.test.ts, after mergingmainand splittingcreateBuckets: 2 of 11 passed locally. The 9 failures are startup timeouts (180 s test timeouts,URL /pools not accessible after 60000ms,URL /admin/ping not accessible after 60000ms), all in waits that run beforecreateBuckets. The run shared a Docker host with other sessions' Couchbase containers at a load average of about 70, and it was not compared with unmodifiedmainunder the same load, so it shows neither a pass nor a regression. TheTests (couchbase, ...)jobs on this PR are the evidence for this file. They passed on the first commit, which already had theHttpWaitStrategyrefactor those waits go through.consoleand??changes:cloudstorage-emulator-container.test.ts,postgresql-container-snapshot.test.tsandgeneric-container-commit.test.tstogether: 12 of 12 pass.postgresql-container.test.tsandvalkey-container.test.tstogether: 15 of 15 pass.vitest runfail two restart tests,PostgreSqlContainer > should work with restarted container(read ECONNRESET) andValkeyContainer > should reconnect with volume and persistence data(Socket closed unexpectedly). The same command on unmodifiedmainfails the same two tests with the same errors, so this PR does not cause them.Not breaking
No public API, export or default changes. The refactors only move statements into private helpers, and the two
??changes are equivalent for the types involved.Two things a consumer could notice:
testcontainersdebug logger, so they appear withDEBUG=testcontainers*. PostgreSQL still rethrows the error, and the emulator did not throw before either.GenericContainer,AzuriteContainer,CouchbaseContainer,DockerComposeEnvironmentandHttpWaitStrategygain the private methods listed above. A subclass that already declares a member with one of those names would clash. No module in this repository does.