fix(noUnnecessararyConditions): no false positive on optional param with fallback#8775
fix(noUnnecessararyConditions): no false positive on optional param with fallback#8775ematipico merged 3 commits intobiomejs:mainfrom
Conversation
🦋 Changeset detectedLatest commit: f7108e8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Merging this PR will not alter performance
Comparing Footnotes
|
WalkthroughThis patch release fixes the Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.changeset/purple-snakes-sleep.md:
- Line 5: The rule identifier "noUnnecessararyConditions" contains a typo and
should be renamed to "noUnnecessaryConditions"; update the rule's exported
name/string in the rule definition (where "noUnnecessararyConditions" is
declared), rename any references in the rule registry/map, tests, docs,
changelog, and any metadata or configuration keys, and update import/exports so
all occurrences use "noUnnecessaryConditions" (ensure tests and rule lookup
still pass after renaming).
|
Oh wow, there was a typo all along should be |
…fined`
Adds unit tests asserting `ConditionalType::from_resolved_data` does not
classify the type of an optional non-primitive parameter (`user?: { name: string }`,
`args?: Args`, `value?: object`) as truthy.
These cases were reported as false positives of `noUnnecessaryConditions`
in biomejs#6611. They were actually fixed upstream by biomejs#8775 (commit 7ea71cd),
which wraps optional-param types in `Union([ty, undefined])`. The tests
land as regression guards so future refactors of the optional-parameter
path can't silently re-break `noUnnecessaryConditions` (and other
type-aware rules) for non-primitive annotations.
Wrote initial test myself, planning to ask claude code to fix it.
Summary
The
noUnnecessararyConditionsrule says that optional parameter can never be falsy, which is incorrect.Test Plan
New test case covers the fix.