Repository navigation
Enforce complexity, shadowing, block statement, useless else and readonly rules with Biome - #1590
Merged
Merged
Conversation
…tyle-with-biome-d40615
…tyle-with-biome-d40615 # Conflicts: # packages/testcontainers/src/container-runtime/clients/container/docker-container-client.ts
The rules live in biome.json. AGENTS.md keeps only the guidance that config can't express: fix a violation rather than suppressing it.
…only rules with Biome
This was referenced Oct 13, 2026
…-1d8369 # Conflicts: # biome.json # packages/testcontainers/src/wait-strategies/http-wait-strategy.ts
cristianrgreco
marked this pull request as ready for review
October 13, 2026 10:02
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 five more Biome rules at
error. Every existing violation is fixed: there is nobiome-ignore, no per-file exemption, and none of the five is turned off for**/*.test.ts.Builds on #1585, which has merged. Hits are from
biome lint --only=<rule> --max-diagnostics=none ., before on the #1585 branch and after on this one.*.test.tscomplexity/noExcessiveCognitiveComplexity(default max 15)suspicious/noShadowstyle/noUselessElsestyle/useBlockStatementsstyle/useReadonlyClassPropertiesCognitive complexity
CouchbaseContainer.configureExternalPortssetServicePorts(body, container)placed below it.ImageNameconstructorstringmoves into a privatebuildString()placed below it.setServicePortsscores exactly 15, the limit.buildStringreturns the value and the constructor assigns it. The branches could not be moved as they were, becausestringisreadonlyand can only be assigned in the constructor. Eachthis.string = xbecamereturn x, in the same order.Shadowing
The inner binding is renamed in every case but one.
gcloud/src/spanner-emulator-helper.tsSpannerclass from the dynamic import is aliased toSpannerClient; theSpannertype import is unchangedtoxiproxy/src/toxiproxy-container.tsreducecallback parameterporttocandidatePortcontainer-runtime/auth/get-auth-config.tsparseDockerConfigparameterdockerConfigtojsoncontainer-runtime/clients/container/docker-container-client.tsprocessStreamparameterstreamtosourceport-forwarder/port-forwarder.tsfindcallback parameterporttomappingreaper/reaper.ts(5 hits)let sessionIdtoreaperSessionIdutils/test-helper.tsstatustorunningwait-strategies/startup-check-strategy.tsstartupStatustostatushivemqandmosquittotests (3 hits)messagehandler parametermessagetopayloadkurrentdbtestgetStreamFirstEventparameterstreamtosubscriptioncommon/retry.test.ts(3 hits)resulttovaluecontainer-runtime/auth/credential-provider.test.tscredentialProvidertounnamedCredentialProviderdocker-compose-environment.test.ts(2 hits),generic-container.test.tsawait using _to_pulledgeneric-container-logs.test.tsdatahandler parameterlinetochunkreaper.tsis the exception: the outer, unexported variable is renamed. Two of the five inner bindings are thesessionIdparameter properties ofRyukReaperandDisabledReaper, which implementReaper.sessionId, so they cannot be renamed.Useless else and block statements
Both are Biome autofixes, applied with
--write --unsafeand then read line by line.noUselessElse: every site is anelseafter a branch that ends inreturnorthrow. Theelsebody moves out one level.useBlockStatements: braces are added around single-statementifandelsebodies.Readonly class properties
By default the rule checks private properties only. All eight are assigned in the initialiser or constructor and nowhere else, so all eight are now
readonly.AzureCosmosDbEmulatorContainerkey,explorerEnabled,portGeneratorMSSQLServerContainerusernameNatsContainerargs,valuesDockerComposeEnvironmentwaitStrategySocatContainertargetsargs,values,waitStrategyandtargetsare collections that are mutated but never reassigned.key,explorerEnabledandusernamehave no setter, so they were already constants.Object.assign, an index signature or a cast.Verification
npm run format: no changes.npm run lintandnpm run lint:ci: pass.npm run knip: pass.npm run check-compiles: pass.biome lint --only=<rule> .for each of the five rules: 0 hits.main(Enforce function length, nullish coalescing and no-console with Biome #1585 squashed, v12.2.1, Add a write-code skill for code conventions #1517). The merge conflicted inbiome.jsonandhttp-wait-strategy.ts, wheremainhad the Enforce function length, nullish coalescing and no-console with Biome #1585 version of lines this PR changes; this branch's side is kept in both.git diff origin/main...HEADis 44 files.Local tests
The test files covering the changed files were run as two Vitest processes at the same time. The Docker host has 4 GB of memory and was shared with other sessions, which had five Couchbase containers running. No failure has been compared against the base branch yet.
Core, 25 files: 24 passed, 1 failed (272 tests passed, 1 failed, 1 skipped).
generic-container.test.ts> should return first mapped port with regardless of protocolTest timed out in 180000msModules, 15 files: 8 passed, 7 failed (66 tests passed, 12 failed). The 8 that passed:
cloudstorage-emulator-container,emulator-flags-manager,spanner-emulator-helper,kurrentdb-container,mongodb-container,mosquitto-container,nats-container,toxiproxy-container.redis-container.test.tsread ECONNRESEThivemq-container.test.tsGet "https://registry-1.docker.io/v2/": net/http: TLS handshake timeoutazurite-container.test.tsRestErrorwith an empty messagepostgresql-container.test.tsconnect ECONNREFUSED 127.0.0.1:61302mongodb-atlas-local-container.test.tscontainer … is not running(HTTP 409);cannot query search index … while in state UNKNOWNazure-cosmosdb-emulator-container.test.tsschema "cosmos_api" does not existmssqlserver-container.test.tsLog stream ended and message "/.*Recovery is complete.*/" was not received(3); the same for/.*Attribute synchronization manager initialized*/(1)Not run locally:
couchbase-container.test.ts, which coversconfigureExternalPorts. CI runs it.Not breaking
setServicePorts,buildString) and the eightreadonlyfields are private.elsekeywords. Control flow is the same.payloadandsubscription.