oxc icon indicating copy to clipboard operation
oxc copied to clipboard

feat(linter): implement react/display-name rule

Open taearls opened this issue 5 months ago • 4 comments

I implemented the react/display-name rule. I categorized it as style because it's more idiomatic to add displayNames and helps with debugging, but it does not affect functionality and is not required for React to work.

In order to get all the tests to pass, I needed to add a version and a component_wrapper_functions setting to the react.rs module. This resulted in some snapshot updates.

All the options available for this rule are supported with this change. However, I commented out one specific test from the eslint-plugin-react test suite because when it's enabled, it throws an unexpected token error. It seems like their test suite is expecting Flow rather than TypeScript. I figure that it's out of scope for this project to support Flow, so I didn't bother with this test.

I added some utility functions to the react utils file that were useful for checking for the presence of jsx or a HOC.

I tried to use CompactStr and FxHashSet rather than vec and String where possible. I also tried to make this implementation as simple as possible, but there are a lot of use cases to account for.

I'm open to any feedback you have!

taearls avatar Jul 04 '25 21:07 taearls

CodSpeed Performance Report

Merging #12084 will not alter performance

Comparing taearls:linter/react-display-name (7b0f0d8) with main (e01c551)

Summary

✅ 4 untouched
⏩ 33 skipped[^skipped]

[^skipped]: 33 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.

codspeed-hq[bot] avatar Jul 04 '25 21:07 codspeed-hq[bot]

@camc314 I fixed the build on this branch and rebased off of main. this is ready for review whenever you get a chance!

taearls avatar Oct 04 '25 16:10 taearls

This'll be great to have, thank you!

connorshea avatar Oct 22 '25 06:10 connorshea

@camc314 when you get a chance could you give this PR another look? Thanks!

taearls avatar Nov 13 '25 22:11 taearls