Skip to content

Conversation

@takuji
Copy link
Contributor

@takuji takuji commented Aug 14, 2025

This PR adds the react/jsx-handler-names rule.

Dropped test cases

Test cases where the bind-this operator :: is used are dropped because the current oxc parser doesn't seem to understand it.
For example, if you test the following code:

<TestComponent onChange={props::handleChange} />

You'll get an output like this:

-------- source --------

<TestComponent onChange={props::handleChange} />

-------- error --------

  × Expected `}` but found `:`
   ╭─[jsx_handler_names.tsx:1:31]
 1 │ <TestComponent onChange={props::handleChange} />
   ·                               ┬
   ·                               ╰── `}` expected
   ╰────

All the dropped test cases are in this commit: d80dcfa

works towards #1022

@takuji takuji requested a review from camc314 as a code owner August 14, 2025 06:11
@graphite-app
Copy link
Contributor

graphite-app bot commented Aug 14, 2025

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 hot fixes, skip the queue and merge this PR next

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 A-linter Area - Linter C-enhancement Category - New feature or request labels Aug 14, 2025
@takuji takuji force-pushed the jsx-handler-names branch from d6dba5f to b3dd362 Compare August 14, 2025 08:33
@camc314 camc314 self-assigned this Aug 14, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Aug 14, 2025

CodSpeed Instrumentation Performance Report

Merging #13079 will not alter performance

Comparing takuji:jsx-handler-names (82fd8df) with main (b2d59a2)

Summary

✅ 34 untouched benchmarks

@camc314
Copy link
Contributor

camc314 commented Aug 14, 2025

Test cases where the bind-this operator is used are dropped because the current oxc parser doesn't seem to understand it.

mind expanding on this with an example of what the parser is failing to parse

@takuji
Copy link
Contributor Author

takuji commented Aug 14, 2025

@camc314 I've added details in the PR description.

@camc314
Copy link
Contributor

camc314 commented Aug 14, 2025

@camc314 I've added details in the PR description.

thanks, not sure why the library has test cases like that, the proposal hasn't been updated in 8 yrs and was never shipped

@camc314 camc314 requested a review from Copilot August 14, 2025 17:00

This comment was marked as outdated.

@takuji takuji force-pushed the jsx-handler-names branch from ef80ff4 to e810b2d Compare August 15, 2025 12:07
@takuji takuji force-pushed the jsx-handler-names branch from e810b2d to 6043ccf Compare August 15, 2025 15:08
@camc314 camc314 requested a review from Copilot August 15, 2025 15:14

This comment was marked as outdated.

@takuji takuji force-pushed the jsx-handler-names branch from d4a9191 to 6043ccf Compare August 15, 2025 15:47
@camc314 camc314 requested a review from Copilot August 18, 2025 15:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements the react/jsx-handler-names rule to enforce consistent naming conventions for JSX event handlers and their corresponding props. The rule ensures handler functions start with specified prefixes (default "handle") and prop names start with specified prefixes (default "on").

  • Adds complete implementation of the jsx-handler-names rule with configurable options
  • Includes comprehensive test coverage for various scenarios and edge cases
  • Handles component name ignore patterns using glob matching

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
crates/oxc_linter/src/rules/react/jsx_handler_names.rs Complete rule implementation with configuration parsing, regex compilation, and handler/prop validation logic
crates/oxc_linter/src/rules.rs Rule registration in the linter module system
crates/oxc_linter/src/snapshots/react_jsx_handler_names.snap Test output snapshots showing expected diagnostic messages

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Copy link
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

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

thank you

@camc314 camc314 merged commit cc7f088 into oxc-project:main Aug 20, 2025
25 checks passed
This was referenced Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants