Skip to content

Commit 65bf119

Browse files
uhyoclaude
andauthored
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/config.generated.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,7 @@ export interface DummyRuleMap {
942942
"react/no-is-mounted"?: DummyRule;
943943
"react/no-multi-comp"?: DummyRule;
944944
"react/no-namespace"?: DummyRule;
945+
"react/no-object-type-as-default-prop"?: DummyRule;
945946
"react/no-react-children"?: DummyRule;
946947
"react/no-redundant-should-component-update"?: DummyRule;
947948
"react/no-render-return-value"?: DummyRule;

crates/oxc_linter/src/generated/rule_runner_impls.rs

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/oxc_linter/src/generated/rules_enum.rs

Lines changed: 35 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/oxc_linter/src/rules.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ pub(crate) mod react {
440440
pub mod no_is_mounted;
441441
pub mod no_multi_comp;
442442
pub mod no_namespace;
443+
pub mod no_object_type_as_default_prop;
443444
pub mod no_react_children;
444445
pub mod no_redundant_should_component_update;
445446
pub mod no_render_return_value;

0 commit comments

Comments
 (0)