Skip to content

feat(linter): implement react no-object-type-as-default-prop#22481

Merged
camchenry merged 2 commits into
oxc-project:mainfrom
uhyo:feature/react-no-object-type-as-default-prop
May 17, 2026
Merged

feat(linter): implement react no-object-type-as-default-prop#22481
camchenry merged 2 commits into
oxc-project:mainfrom
uhyo:feature/react-no-object-type-as-default-prop

Conversation

@uhyo

@uhyo uhyo commented May 16, 2026

Copy link
Copy Markdown
Contributor

Note

AI disclosure: Claude Opus 4.7 authored all code changes. I reviewed all of them.

This PR implements react/no-object-type-as-default-prop. That was the only missing piece when I migrated from ESLint 😀

Related: #1022

Difference from eslint-plugin-react

As a result of pursuing the best possible implementation, it diverges from eslint-plugin-react's in the following ways.

If we should strictly match the eslint-plugin-react behavior, I'm happy to revise the implementation.

1. Flags JSX Fragment as object type

// Flagged by ours, not by eslint-plugin-react
function Foo({ icon = <></> }) { return <div /> }

2. Flags wrapped components

// Flagged by ours, not by eslint-plugi-react
const Foo = React.forwardRef(({ items = [] }, ref) => <div ref={ref} />);

uhyo and others added 2 commits May 16, 2026 21:37
Flags object, array, function, class, regex, `new`, and JSX expressions used
as default values for destructured props of a function component, since these
are re-created on every render and break referential equality.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…-prop

Document and lock in that we flag `<></>` defaults too. Upstream
eslint-plugin-react v7.37 does not flag JSX fragments, but they create a
new reference per render just like JSX elements.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

@camchenry camchenry left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@codspeed-hq

codspeed-hq Bot commented May 17, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing uhyo:feature/react-no-object-type-as-default-prop (eb0b5f6) with main (8c1da44)

Open in CodSpeed

Footnotes

  1. 47 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@camchenry camchenry merged commit 65bf119 into oxc-project:main May 17, 2026
32 checks passed
@uhyo uhyo deleted the feature/react-no-object-type-as-default-prop branch May 18, 2026 10:00
camc314 pushed a commit that referenced this pull request May 18, 2026
# Oxlint
### 🚀 Features

- 1ae291e linter/no-underscore-dangle: Add `allowInUsingDeclarations`
option (#22483) (吴杨帆)
- 0440b0f linter/eslint: Implement `id-match` rule (#22379) (Vladislav
Sayapin)
- 65bf119 linter: Implement react no-object-type-as-default-prop
(#22481) (uhyo)
- 2a6ddce linter/eslint: Implement `no-implied-eval` rule (#22391)
(Vladislav Sayapin)
- d3a3c1d linter: Auto detect agents from CLI and transition to the
agent output format (#22068) (Jovi De Croock)
- 625758a linter/vitest: Implement padding-around-after-all-blocks rule
(#21788) (kapobajza)
- 37680b0 linter: Implement react no-unstable-nested-components (#22248)
(Jovi De Croock)
- d8d9c74 linter: Implement import/newline-after-import rule (#19142)
(Ryuya Yanagi)

### 🐛 Bug Fixes

- 3f59e03 linter: Only call rayon/miette/tracing inits once (#21899)
(Matiss Janis Aboltins)
- 602dfd6 linter/promise/no-return-wrap: Detect Promise calls in all
branches (#22474) (zennnnnnn11)
- e182aee linter: Allow dialogs and popovers for no_autofocus (#22289)
(mehm8128)
- 7ffb710 linter/jest/vitest: Jest/no-standalone-expect ignores
additionalTestBlockFunctions option for jest/vitest hooks (#22477)
(kapobajza)
- c6f2d3f linter: Add more expression support for iframe-has-title
(#22460) (mehm8128)
- 5747ff1 linter: Avoid enabling jest with vitest plugin (#22499)
(camc314)
- 863984f linter/no-find-dom-node: Run on all files (#22479) (bab)

### ⚡ Performance

- 2afef79 linter: Optimize `no-loop-func` (#22491) (camchenry)
- 4c9ca72 oxlint: Align walker thread count with rayon pool (#22494)
(Boshen)

### 📚 Documentation

- f7967c7 linter/id-match: Clarify `onlyDeclarations` config docs
(#22523) (camc314)
- 1e0c97f linter: Fix closing code block in documentation for
`padding-around-after-all-blocks` rule. (#22513) (connorshea)
- a9049fd linter: Exclude directly provide autoFocus to dialog pattern
(#22510) (mehm8128)
# Oxfmt
### 🐛 Bug Fixes

- 8ee946f formatter/sort_imports: Use label to classify lines (#22512)
(leaysgur)
- 8c1da44 formatter: Normalize destructuring keys in DCR (#22478)
(camc314)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants