fix: resolve unsafe optional chaining lint error in affinity-fingerprint test - #1357
Closed
github-actions[bot] wants to merge 1 commit into
Closed
fix: resolve unsafe optional chaining lint error in affinity-fingerprint test#1357github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
…int test The biome rule lint/correctness/noUnsafeOptionalChaining flagged `contents[1]?.parts[1]` as unsafe: if the optional chaining short-circuits to undefined, the subsequent `[1]` index access throws TypeError. The test data guarantees contents[1] is defined, so direct access is correct. CI Run: https://github.com/ding113/claude-code-hub/actions/runs/29960089110
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.
CI Auto-Fix
Original PR: #1356
Failed CI Run: Non-Main Branch CI/CD
Fixes Applied
tests/unit/proxy/affinity-fingerprint.test.ts:583contents[1]?.partswithcontents[1].partsThe biome rule
lint/correctness/noUnsafeOptionalChainingflagged(otherUri.contents[1]?.parts as ...)[1]because if the optional chaining short-circuits toundefined, the subsequent[1]index access throws aTypeError. The test fixture explicitly definescontents[1]as a non-null object, so the optional chaining was both unnecessary and unsafe. Switching to direct member access is behavior-preserving for this test.Not Auto-Fixable
The biome config also emits 2 infos (not errors, do not fail CI):
biome.jsonschema version mismatch (2.4.16 vs CLI 2.5.5) — requires runningbiome migratelinter.recommendedfield deprecated in favor ofpreset— requires runningbiome migrateThese are informational and do not block the pipeline.
Verification
bun run lintpasses (exit code 0 after CI'sformatstep)affinity-fingerprint.test.tspass?.to.fixAuto-generated by Claude AI
Greptile Summary
This PR removes a redundant
?.optional chain in a single test assertion, fixing a biomenoUnsafeOptionalChaininglint error. The test fixture at the mutation site unconditionally definescontents[1]as a non-null object, so the removal is behavior-preserving.otherUri.contents[1]?.partswithotherUri.contents[1].partsin the test for thecomputeFingerprintChaingemini path — eliminates the lint error with no semantic change.Confidence Score: 5/5
Safe to merge — single mechanical character change in a test file with no production code impact.
The change removes one
?.operator from a test assertion where the fixture guarantees the object is present. The fix is verified by the existing test suite and purely eliminates a lint warning with no behavioral difference.No files require special attention.
Important Files Changed
contents[1]?.partsat line 583; the test fixture guaranteescontents[1]is non-null, so the change is behavior-preserving and fixes the biome lint error.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A["Test fixture: contents[1] is a non-null object"] --> B{"Optional chaining used?"} B -- "Before fix: contents[1]?.parts" --> C["biome lint error: noUnsafeOptionalChaining"] B -- "After fix: contents[1].parts" --> D["Direct access — safe, lint passes"] D --> E["All 42 tests pass unchanged"]Reviews (1): Last reviewed commit: "fix: resolve unsafe optional chaining li..." | Re-trigger Greptile