Repository navigation
feat(linter): add noReactObjectTypeAsDefaultProp rule - #10634
Merged
ematipico merged 26 commits intoSep 19, 2026
Merged
Conversation
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
Ports
no-object-type-as-default-propfromeslint-plugin-reactasnoObjectTypeAsDefaultPropin the nursery group.The rule reports reference-type defaults on destructured props of React function components. These create a new instance on every render, which can break memoization and trigger extra re-renders. Primitive defaults are fine.
It flags the following default value types:
{})[])newexpressionsSymbol()callsCloses #7656
Notes
ReactComponentInfo(name + param count), not return-value analysis. Two cases differ from upstream:export default function NotReturningJsx({ foo = {} }) {}is reported (PascalCase name).({ a = {} }, context) => {}is not reported (two params, so not a component here).memo/forwardRefwrappers, and default-exported functions.Test plan
cargo test -p biome_js_analyze -- no_object_type_as_default_propcargo run -p rules_checkjust gen-analyzerThe committed snapshots (
invalid.jsx.snap/valid.jsx.snap) show the rendered diagnostics for every flagged type.AI usage disclosure
I used an AI assistant (Claude) heavily while writing this PR — for finding the right syntax-tree APIs, writing a lot of the traversal code, fixing compile errors, and polishing the docs. I made the design decisions (how components are detected, which default types to flag, the differences from upstream), wrote the test cases, and reviewed and verified all the code.