Skip to content

fix(linter): detect React components from returned JSX#24521

Merged
graphite-app[bot] merged 1 commit into
mainfrom
codex/fix-react-component-detection
Jul 15, 2026
Merged

fix(linter): detect React components from returned JSX#24521
graphite-app[bot] merged 1 commit into
mainfrom
codex/fix-react-component-detection

Conversation

@camc314

@camc314 camc314 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • detect React function components from reachable JSX/null returns using a shared CFG utility
  • avoid function-component-definition false positives for callbacks, lowercase helpers, class methods, and functions that only contain JSX
  • avoid display-name false positives for higher-order functions that contain but do not return JSX

fixes #22685

closes oxc-project/oxc#22755

follow up to #24471

Copilot AI review requested due to automatic review settings July 14, 2026 17:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@graphite-app

graphite-app Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@github-actions github-actions Bot added the A-linter Area - Linter label Jul 14, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 80b180594f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/oxc_linter/src/rules/react/function_component_definition.rs Outdated
@camc314
camc314 marked this pull request as draft July 14, 2026 17:58
@camc314 camc314 self-assigned this Jul 14, 2026
@codspeed-hq

codspeed-hq Bot commented Jul 14, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 5 untouched benchmarks
⏩ 66 skipped benchmarks1


Comparing codex/fix-react-component-detection (f92e751) with main (16a65f2)

Open in CodSpeed

Footnotes

  1. 66 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.

@camc314
camc314 marked this pull request as ready for review July 14, 2026 19:57

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f92e7518c2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/oxc_linter/src/utils/react.rs
Comment thread crates/oxc_linter/src/utils/react.rs
@camc314
camc314 force-pushed the codex/fix-react-component-detection branch from f92e751 to 03ea7f0 Compare July 15, 2026 10:23
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Jul 15, 2026

camc314 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

  • Jul 15, 10:28 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jul 15, 10:28 AM UTC: camc314 added this pull request to the Graphite merge queue.
  • Jul 15, 10:33 AM UTC: The Graphite merge queue couldn't merge this PR because it failed for an unknown reason (All comments in this PR must be resolved before merging. Once you've resolved all open comment threads, you can retry your merge.).
  • Jul 15, 10:38 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jul 15, 10:39 AM UTC: camc314 added this pull request to the Graphite merge queue.
  • Jul 15, 10:49 AM UTC: Merged by the Graphite merge queue.

graphite-app Bot pushed a commit that referenced this pull request Jul 15, 2026
## Summary

- detect React function components from reachable JSX/null returns using a shared CFG utility
- avoid function-component-definition false positives for callbacks, lowercase helpers, class methods, and functions that only contain JSX
- avoid display-name false positives for higher-order functions that contain but do not return JSX

fixes  [https://github.com/oxc-project/oxc/issues/22685](https://github.com/oxc-project/oxc/issues/22685)

closes [#22755](#22755)

follow up to #24471
@graphite-app
graphite-app Bot force-pushed the codex/fix-react-component-detection branch from 03ea7f0 to a47a3e9 Compare July 15, 2026 10:28

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 03ea7f0def

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/oxc_linter/src/utils/react.rs
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label Jul 15, 2026
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Jul 15, 2026
## Summary

- detect React function components from reachable JSX/null returns using a shared CFG utility
- avoid function-component-definition false positives for callbacks, lowercase helpers, class methods, and functions that only contain JSX
- avoid display-name false positives for higher-order functions that contain but do not return JSX

fixes  [https://github.com/oxc-project/oxc/issues/22685](https://github.com/oxc-project/oxc/issues/22685)

closes [#22755](#22755)

follow up to #24471
@graphite-app
graphite-app Bot force-pushed the codex/fix-react-component-detection branch from a47a3e9 to ac9200a Compare July 15, 2026 10:43
@graphite-app
graphite-app Bot merged commit ac9200a into main Jul 15, 2026
29 checks passed
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label Jul 15, 2026
@graphite-app
graphite-app Bot deleted the codex/fix-react-component-detection branch July 15, 2026 10:49
camc314 added a commit that referenced this pull request Jul 21, 2026
# Oxlint
### 💥 BREAKING CHANGES

- 54cc121 ast: [**BREAKING**] Split `MetaProperty` into `ImportMeta` and
`NewTarget` (#24557) (camc314)

### 🚀 Features

- 7b045cd minfier: Drop last break from last switch case (#24673)
(Armano)
- dd18383 linter/node: Implement no-top-level-await rule (#24634)
(Connor Shea)
- 16a65f2 linter/react: Implement function-component-definition rule
(#24471) (Cole Ellison)
- 7f1f585 linter: Reuse `jest/padding-around-test-blocks` for
`vitest/padding-around-test-blocks` (#24519) (Mikhail Baev)
- 99978a8 linter/import/consistent-type-specifier-style: Support
`prefer-top-level-if-only-type-imports` option (#24502) (camc314)

### 🐛 Bug Fixes

- 0184ad6 linter/unicorn/no-useless-undefined: Preserve valid parameter
defaults (#24686) (camc314)
- 8694167 linter/eslint/prefer-destructuring: Handle typed declarations
(#24616) (camc314)
- 477cf0f linter/eslint/no-throw-literal: Handle assigned errors
(#24561) (Cole Ellison)
- ac9200a linter: Detect React components from returned JSX (#24521)
(camc314)
- c0a6522 linter/eslint/no-useless-computed-key: Allow TS syntax in
computed keys (#24524) (Cole Ellison)

### ⚡ Performance

- 346eed1 linter/unicorn/prefer-event-target: Only run on `Class` and
`NewExpression` nodes (#24685) (Mikhail Baev)
- 7be5cf0 oxlint/lsp: Only invoke lint on code actions when document is
not opened (#24676) (Sysix)
- d3f07a0 diagnostics: Box OxcDiagnosticInner to reduce binary size
(#24665) (Boshen)
- 90ae040 linter/reporter/stylish: Compute diagnostic Info once per
diagnostic (#24525) (connorshea)

### 📚 Documentation

- e6f7174 linter/valid-expect: Fix correct example being identical to
incorrect one (#24468) (mkan0141)
# Oxfmt
### 💥 BREAKING CHANGES

- 54cc121 ast: [**BREAKING**] Split `MetaProperty` into `ImportMeta` and
`NewTarget` (#24557) (camc314)

### 🚀 Features

- 3d22307 parser: Add `ParseOptions::enable_ident_hashes` (#24491)
(Boshen)

### 🐛 Bug Fixes

- 6fe866a oxfmt: Keep tailwind classes glued to template expr with
`preserveWhitespace` (#24609) (leaysgur)
- 33e32d8 formatter_css: Use `line_suffix` for EOL line comment (#24580)
(leaysgur)
- 5f76998 formatter_graphql: Keep same line comments pending across
intervening tokens (#24579) (leaysgur)

Co-authored-by: Boshen <[email protected]>
Co-authored-by: Cameron <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: react/display-name false positive for function that returns function that has JSX (but doesn't return it)

2 participants