Commit 65bf119
feat(linter): implement react no-object-type-as-default-prop (#22481)
> [!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](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-object-type-as-default-prop.md).
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
```jsx
// Flagged by ours, not by eslint-plugin-react
function Foo({ icon = <></> }) { return <div /> }
```
### 2. Flags wrapped components
```jsx
// Flagged by ours, not by eslint-plugi-react
const Foo = React.forwardRef(({ items = [] }, ref) => <div ref={ref} />);
```
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 2a6ddce commit 65bf119
8 files changed
Lines changed: 469 additions & 1 deletion
File tree
- apps/oxlint/src-js/package
- crates/oxc_linter/src
- generated
- rules/react
- snapshots
- npm/oxlint
- tasks/website_linter/src/snapshots
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
942 | 942 | | |
943 | 943 | | |
944 | 944 | | |
| 945 | + | |
945 | 946 | | |
946 | 947 | | |
947 | 948 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
| 443 | + | |
443 | 444 | | |
444 | 445 | | |
445 | 446 | | |
| |||
0 commit comments