feat(linter): implement react/display-name rule#12084
feat(linter): implement react/display-name rule#12084taearls wants to merge 29 commits intooxc-project:mainfrom
Conversation
CodSpeed Performance ReportMerging #12084 will not alter performanceComparing Summary
Footnotes
|
5a17d37 to
59cf2bd
Compare
59cf2bd to
97eacca
Compare
|
@camc314 I fixed the build on this branch and rebased off of main. this is ready for review whenever you get a chance! |
cadebe7 to
919325b
Compare
8ff9ca2 to
927c171
Compare
Replace full AST iteration with symbol-based semantic analysis for better performance and cleaner architecture. Changes: - Use semantic symbol iteration instead of iterating all AST nodes - Leverage semantic references to detect displayName assignments - Add helper functions for component detection and validation - Detect Higher-Order Functions that return components with JSX - Handle nested arrow functions and curried component patterns Key improvements: - Reduced iterations: Only process symbols + specific anonymous cases - Semantic-based: Use reference tracking instead of manual HashMaps - Better separation: Component detection vs displayName validation - Maintained functionality: All 805 tests pass including HOF patterns Implementation details: - is_react_component_node(): Consolidates all component detection logic - has_display_name_via_semantic(): Checks displayName via symbol references - check_function_expression_component(): Detects direct JSX and HOF patterns - Three-phase approach: symbols → anonymous exports → diagnostics Addresses: oxc-project#12084 (comment)
f2d4321 to
02d4f44
Compare
Replace full AST iteration with symbol-based semantic analysis for better performance and cleaner architecture. Changes: - Use semantic symbol iteration instead of iterating all AST nodes - Leverage semantic references to detect displayName assignments - Add helper functions for component detection and validation - Detect Higher-Order Functions that return components with JSX - Handle nested arrow functions and curried component patterns Key improvements: - Reduced iterations: Only process symbols + specific anonymous cases - Semantic-based: Use reference tracking instead of manual HashMaps - Better separation: Component detection vs displayName validation - Maintained functionality: All 805 tests pass including HOF patterns Implementation details: - is_react_component_node(): Consolidates all component detection logic - has_display_name_via_semantic(): Checks displayName via symbol references - check_function_expression_component(): Detects direct JSX and HOF patterns - Three-phase approach: symbols → anonymous exports → diagnostics Addresses: oxc-project#12084 (comment)
Replace full AST iteration with symbol-based semantic analysis for better performance and cleaner architecture. Changes: - Use semantic symbol iteration instead of iterating all AST nodes - Leverage semantic references to detect displayName assignments - Add helper functions for component detection and validation - Detect Higher-Order Functions that return components with JSX - Handle nested arrow functions and curried component patterns Key improvements: - Reduced iterations: Only process symbols + specific anonymous cases - Semantic-based: Use reference tracking instead of manual HashMaps - Better separation: Component detection vs displayName validation - Maintained functionality: All 805 tests pass including HOF patterns Implementation details: - is_react_component_node(): Consolidates all component detection logic - has_display_name_via_semantic(): Checks displayName via symbol references - check_function_expression_component(): Detects direct JSX and HOF patterns - Three-phase approach: symbols → anonymous exports → diagnostics Addresses: oxc-project#12084 (comment)
1063655 to
0bc0383
Compare
|
This'll be great to have, thank you! |
|
@camc314 when you get a chance could you give this PR another look? Thanks! |
0bc0383 to
6a3e915
Compare
Replace full AST iteration with symbol-based semantic analysis for better performance and cleaner architecture. Changes: - Use semantic symbol iteration instead of iterating all AST nodes - Leverage semantic references to detect displayName assignments - Add helper functions for component detection and validation - Detect Higher-Order Functions that return components with JSX - Handle nested arrow functions and curried component patterns Key improvements: - Reduced iterations: Only process symbols + specific anonymous cases - Semantic-based: Use reference tracking instead of manual HashMaps - Better separation: Component detection vs displayName validation - Maintained functionality: All 805 tests pass including HOF patterns Implementation details: - is_react_component_node(): Consolidates all component detection logic - has_display_name_via_semantic(): Checks displayName via symbol references - check_function_expression_component(): Detects direct JSX and HOF patterns - Three-phase approach: symbols → anonymous exports → diagnostics Addresses: oxc-project#12084 (comment)
Replace full AST iteration with symbol-based semantic analysis for better performance and cleaner architecture. Changes: - Use semantic symbol iteration instead of iterating all AST nodes - Leverage semantic references to detect displayName assignments - Add helper functions for component detection and validation - Detect Higher-Order Functions that return components with JSX - Handle nested arrow functions and curried component patterns Key improvements: - Reduced iterations: Only process symbols + specific anonymous cases - Semantic-based: Use reference tracking instead of manual HashMaps - Better separation: Component detection vs displayName validation - Maintained functionality: All 805 tests pass including HOF patterns Implementation details: - is_react_component_node(): Consolidates all component detection logic - has_display_name_via_semantic(): Checks displayName via symbol references - check_function_expression_component(): Detects direct JSX and HOF patterns - Three-phase approach: symbols → anonymous exports → diagnostics Addresses: oxc-project#12084 (comment)
17023eb to
7b0f0d8
Compare
camchenry
left a comment
There was a problem hiding this comment.
Truly sorry this hasn't been reviewed earlier. I think this looks pretty good overall. The logic seems generally sound to me, and if the tests are passing then I think this rule is in good shape.
I've left some comments to improve the style a little bit and also be slightly more idiomatic for our codebase, but I don't think there's anything major that needs to be addressed. I believe if the merge conflicts are resolved as well, we can try to get this merged.
@camc314 Do you mind taking a look at this as well and see if you agree?
Thanks for your feedback! I'll try to address it this week. |
|
Thanks for working so hard on this, it's a complex rule. Apologies for the delay in getting to it
Yeah, I agree - thank you for reviewing. |
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Update display_name rule to use the new structured ReactVersion type from main instead of string-based version parsing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
c069a1b to
14816e8
Compare
- Remove .idea/ IDE configuration files - Reset Cargo.lock to main's version (napi packages were incorrectly downgraded) - Revert unrelated changes to tasks/website_formatter and tasks/website_linter 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Change is_hoc_call to use exact matching instead of ends_with pattern - Matches ESLint react/display-name behavior - Only matches: memo, forwardRef, React.memo, React.forwardRef - Also fix documentation typo for componentWrapperFunctions setting 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
… fix 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
This file was accidentally modified during a previous rebase. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Local tsgolint binary panics with "unknown rule" errors, causing corrupted snapshot output. Restore proper snapshots from main branch. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Another snapshot corrupted by outdated local tsgolint binary. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
I have addressed all the feedback and rebased onto main. thanks for your patience! this is ready for another review when you get a chance @camc314 @camchenry |
|
@camc314 @camchenry when you can, could I get a review on this? I think it's ready to go. |
This is a fixed up version of #12084 with merge conflicts resolved.
I understand! I get that there have been higher priorities. Thanks for reviewing and accepting my PR! |
I implemented the
react/display-namerule. 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
versionand acomponent_wrapper_functionssetting to thereact.rsmodule. 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-reacttest 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!