fix(sarif): guard optional chain in baseline.test.ts for Biome 2.5.3#291
Merged
Conversation
Biome 2.5.3 tightened lint/correctness/noUnsafeOptionalChaining and now flags two spots in baseline.test.ts where an optional chain (tagged.runs[0]?.results?.[0]) was followed by a non-optional .baselineState member access on the next line. If the chain short-circuits to undefined, the access throws TypeError. Add the optional-chaining operator so the access is guarded. Behavior is unchanged for the passing path (value present); if the chain were ever undefined the assertion now fails on value mismatch instead of a raw TypeError. Unblocks the Biome 2.5.2 -> 2.5.3 bump in the typescript-tooling group (PR #287), whose lint + self-scan jobs fail on this pre-existing code.
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.
What
Add the optional-chaining operator (
?.) to two spots inpackages/sarif/src/baseline.test.tswhere an optional chain was followed by a non-optional member access on the next line:Why
Biome 2.5.3 tightened
lint/correctness/noUnsafeOptionalChaining. The pre-existing code onmain(lines 135 and 174) short-circuitstagged.runs[0]?.results?.[0]toundefined, then reads.baselineStateon it — which would throwTypeErrorat runtime. Biome now flags this as an error.Verified locally against
@biomejs/biome@2.5.3: the unfixed file emits 2noUnsafeOptionalChainingerrors; the fixed file passes clean.Impact
mainindependent of any dep bump.typescript-toolinggroup (build(deps-dev): bump the typescript-tooling group with 2 updates #287), whoselint+self-scanjobs fail on exactly this code.undefined, the assertion now fails on value mismatch instead of a rawTypeError.🤖 Opened by Bonk nightly maintenance.