jsx_tag_auto_close: Fix <Foo.Bar> component auto-close (#27374)

- **support alternate tag name node names to fix autoclosing of
`<Foo.Bar>` style tags in TSX**
- **remove checks against close tag name while checking if tag is
closed**
- **move jsx tag auto close tests into jsx_tag_auto_close.rs**

Closes #27335

Release Notes:

- Fixed an issue with JSX tag auto-close where components containing a
`.` access like `<Foo.Bar>` would be auto-closed as `</>` instead of
`</Foo.Bar>`
This commit is contained in:
Ben Kunkle 2025-03-24 10:43:06 -05:00 committed by GitHub
parent 43712285bf
commit f2be201495
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 271 additions and 257 deletions

View file

@ -727,6 +727,11 @@ pub struct JsxTagAutoCloseConfig {
/// The name of the node found within both opening and closing
/// tags that describes the tag name
pub tag_name_node_name: String,
/// Alternate Node names for tag names.
/// Specifically needed as TSX represents the name in `<Foo.Bar>`
/// as `member_expression` rather than `identifier` as usual
#[serde(default)]
pub tag_name_node_name_alternates: Vec<String>,
/// Some grammars are smart enough to detect a closing tag
/// that is not valid i.e. doesn't match it's corresponding
/// opening tag or does not have a corresponding opening tag