Skip to content

fix(linter/react/only-export-components): classify JSX values as non-components - #28761

Merged
graphite-app[bot] merged 1 commit into
mainfrom
codex/react-refresh-jsx-exports
Nov 5, 2026
Merged

graphite-app[bot] merged 1 commit into
mainfrom
codex/react-refresh-jsx-exports

Conversation

@camc314

@camc314 camc314 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

react/only-export-components treated JSX values as components and reported unrelated utility exports. Classify JSX elements and fragments as non-component exports, including named exports, to match eslint-plugin-react-refresh@0.5.7.

export const CLOSED_ICON = <span>closed</span>;
export const STATUS_LABELS = { open: 'Open', closed: 'Closed' };

This module now passes. When a real component is also exported, JSX values are reported. Local-component discovery only considers top-level declarations, preserving function-expression components and avoiding warnings for functions inside JSX render props. Regression tests cover these paths and TypeScript wrappers.

Fixes #28578

Copilot AI balanced review requested due to automatic review settings November 3, 2026 14:30
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T16:31:48.996611Z 299c5ab New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the A-linter Area - Linter (oxlint): rules, config, diagnostics, fixes. Add L-* labels for details label Nov 3, 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: e1cded25ec

ℹ️ 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".

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.

🟡 Changes recommended

The change drops missing-export diagnostics for function-expression components wrapped in parentheses or nested TypeScript assertions, and for those passed to React.memo.

2 open issues
What changed in this PR

Updates react/only-export-components to treat JSX values as non-components, addressing false warnings in constants-only modules reported in #28578.

Changes:

  • Classifies JSX elements and fragments as non-component exports, including named exports.
  • Limits local-component discovery to top-level declarations and adds function-expression handling.
  • Adds regression cases and diagnostic snapshots for JSX exports, TypeScript wrappers, and local components.
File Description
crates/​oxc_linter/​src/​snapshots/​react_only_export_components.snap Records expected diagnostics for the new regression cases.
crates/​oxc_linter/​src/​rules/​react/​only_export_components.rs Updates export classification and local-component discovery, with regression tests.

Review effort: Balanced

@codspeed

codspeed Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 5 untouched benchmarks
⏩ 91 skipped benchmarks1


Comparing codex/react-refresh-jsx-exports (299c5ab) with main (3c051ab)2

Open in CodSpeed

Footnotes

  1. 91 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. ↩

  2. No successful run was found on main (5c25203) during the generation of this report, so 3c051ab was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Nov 5, 2026

camc314 commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Merge activity

…components (#28761)

`react/only-export-components` treated JSX values as components and reported unrelated utility exports. Classify JSX elements and fragments as non-component exports, including named exports, to match `eslint-plugin-react-refresh@0.5.7`.

```tsx
export const CLOSED_ICON = <span>closed</span>;
export const STATUS_LABELS = { open: 'Open', closed: 'Closed' };
```

This module now passes. When a real component is also exported, JSX values are reported. Local-component discovery only considers top-level declarations, preserving function-expression components and avoiding warnings for functions inside JSX render props. Regression tests cover these paths and TypeScript wrappers.

Fixes #28578
@graphite-app
graphite-app Bot force-pushed the codex/react-refresh-jsx-exports branch from 299c5ab to c6ec50b Compare November 5, 2026 16:44
@graphite-app
graphite-app Bot merged commit c6ec50b into main Nov 5, 2026
33 checks passed
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label Nov 5, 2026
@graphite-app
graphite-app Bot deleted the codex/react-refresh-jsx-exports branch November 5, 2026 16:49
graphite-app Bot pushed a commit that referenced this pull request Nov 6, 2026
# Oxlint
### 🚀 Features

- 4a52ba2 oxlint: Discover tsrs for type-aware linting (#28751) (camc314)
- b7d2c75 linter/eslint/no-redeclare: Add `ignoreDeclarationMerge` option (#28816) (Cam McHenry)

### 🐛 Bug Fixes

- fa66fde oxlint,oxfmt: Resolve Vite+ config root from the config file directory (#28801) (MK (fengmk2))
- 2091564 linter/jsdoc/require-param: Ignore enclosing function JSDoc (#28866) (camc314)
- c6ec50b linter/react/only-export-components: Classify JSX values as non-components (#28761) (camc314)
- 3c051ab linter/vitest/prefer-called-exactly-once-with: Preserve neighboring code in autofix (#28864) (camc314)
- 674b962 linter/eslint/no-misleading-character-class: Use lazy regex for combining marks (#28822) (Sysix)
- 838d339 linter/vitest/prefer-called-exactly-once-with: Avoid panic on non-ASCII text (#28850) (YT)
- 8d24c26 linter/jsx-a11y/aria-role: Allow role={undefined} (#28804) (Abhay Godavarthy)
- a7143bf linter/eslint/no-restricted-imports: Respect allowTypeImports correctly for empty patterns (#28842) (Cam McHenry)
- 3d3a6f4 react-compiler: Ignore callback-local reassignments (#28820) (camc314)
- 0cc6515 linter/unicorn/prefer-type-error: Report throws in unbraced if branches (#28819) (camc314)
- ae43c80 linter/unicorn/prefer-single-call: Remove duplicate fix status (#28763) (Mikhail Baev)
- a8a621a linter/eslint/no-fallthrough: Ignore unreachable exits from infinite loops (#28755) (camc314)
- 7a17a80 linter/eslint/prefer-spread: Report calls on non-member expressions (#28753) (camc314)
- 28442f7 oxlint: Prevent --init from overwriting existing configs (#28754) (camc314)
- 0ae350d linter/unicorn/no-zero-fractions: Preserve exponent case (#28752) (camc314)
- b5b3f3f linter/eslint/no-misleading-character-class: Detect more combining characters (#28733) (Sysix)

### ⚡ Performance

- 74d50c1 linter: Overlap import graph batches instead of polling on a pool worker (#28323) (Dunqing)
# Oxfmt
### 💥 BREAKING CHANGES

- 00d1a67 oxfmt: [**BREAKING**] Format `parser:vue` files by `oxc_formatter_htmlish` (#28848) (leaysgur)

### 🚀 Features

- 9a81e58 formatter_htmlish: Format Vue templates (#28847) (leaysgur)
- 119d82f formatter: Format a template's expressions and handlers as `JsRoot` (#28846) (leaysgur)

### 🐛 Bug Fixes

- fa66fde oxlint,oxfmt: Resolve Vite+ config root from the config file directory (#28801) (MK (fengmk2))
- 4d4104d formatter_htmlish: Preserve `doctype` case in embedded (#28797) (leaysgur)
- ebfd40a formatter: Sort Tailwind calls printed as member chains (#28800) (Yuji Sugiura)
- e62e5cb formatter: Decide quotes of a Tailwind key printed as one class (#28798) (Yuji Sugiura)
- 959edc1 formatter: Don't sort templates in nested non-Tailwind calls (#28794) (Yuji Sugiura)
- 6ffbe32 formatter/jsdoc: Prevent `@tag` from being moved to the line start (#28835) (leaysgur)
- 94fbef5 formatter_css: Treat comments in `style` attr as fill items (#28832) (leaysgur)
- e4a80f7 formatter_css: Normalize selectors inside `:deep`, `:slotted` and `:local` (#28805) (leaysgur)
- 255c5cc formatter: Measure Tailwind class argument after collapsing whitespace (#28745) (Lee Jaeha / Adam)
- e6c4fef formatter: Decide template and object key layouts from collapsed Tailwind classes (#28791) (Yuji Sugiura)
- 0b44164 formatter: Decide JSX opening element layout from collapsed Tailwind class string (#28744) (Lee Jaeha / Adam)
- b8ba9ae formatter: Print decorators on rest parameters (#28731) (YT)

### ⚡ Performance

- 2766d07 oxfmt: Spawn Prettier workers on demand (#28789) (YT)
- 07627f7 oxfmt: Use worker_threads for tinypool again (#28787) (Yuji Sugiura)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter (oxlint): rules, config, diagnostics, fixes. Add L-* labels for details

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: react/only-export-components reports a file whose only JSX export is a non-component constant

2 participants