Repository: dprint/dprint-plugin-typescript (rust)

Issue:
Extra space in JSX self-closing components
**Describe the bug**

dprint-plugin-typescript version: 0.76.0

It seems like the new `jsx.bracketPosition` setting is adding an extra space to self-closing elements.

**Input Code**
```json
// dprint file
{
    "indentWidth": 4,
    "typescript": {
        "quoteStyle": "alwaysSingle",
        "jsx.quoteStyle": "preferDouble",
        "trailingCommas": "never",
        "jsx.bracketPosition": "sameLine"
    },
    "includes": [
        "**/*.{ts,tsx,js,jsx,cjs,mjs}"
    ],
    "excludes": [
        "**/node_modules",
        "**/*-lock.json"
    ],
    "plugins": [
        "https://plugins.dprint.dev/typescript-0.76.0.wasm"
    ]
}
```

```tsx
<MyComponent someProp={value} />
```

**Expected Output**

```tsx
<MyComponent someProp={value} />
```

**Actual Output**

```tsx
<MyComponent someProp={value}  />
```


Pull request:
fix: jsx.bracketPosition - Was adding an extra space when single line
Will add the split up config in a separate pr.

Closes #445

Patch:
diff --git a/src/generation/generate.rs b/src/generation/generate.rs
index a4d1430..cc76d15 100644
--- a/src/generation/generate.rs
+++ b/src/generation/generate.rs
@@ -3611,13 +3611,9 @@ fn gen_jsx_opening_element<'a>(node: &'a JSXOpeningElement, context: &mut Contex
     items.extend(gen_node(type_args.into(), context));
   }
 
-  let single_line_space_at_end = node.self_closing() && space_before_self_closing_tag_slash;
   if node.attrs.len() == 1 && node.type_args.is_none() && is_jsx_attr_with_string(&node.attrs[0]) {
     items.push_str(" ");
     items.extend(gen_node(node.attrs[0].into(), context));
-    if single_line_space_at_end {
-      items.push_str(" ");
-    }
   } else if !node.attrs.is_empty() {
     let mut multi_line_options = ir_helpers::MultiLineOptions::surround_newlines_indented();
     multi_line_options.newline_at_end = prefer_newline_before_close_bracket;
@@ -3629,7 +3625,7 @@ fn gen_jsx_opening_element<'a>(node: &'a JSXOpeningElement, context: &mut Contex
         allow_blank_lines: false,
         separator: Separator::none(),
         single_line_space_at_start: true,
-        single_line_space_at_end,
+        single_line_space_at_end: false,
         custom_single_line_separator: None,
         multi_line_options,
         force_possible_newline_at_start: false,
@@ -3653,7 +3649,7 @@ fn gen_jsx_opening_element<'a>(node: &'a JSXOpeningElement, context: &mut Contex
   }
 
   if node.self_closing() {
-    if (node.attrs.is_empty() || !prefer_newline_before_close_bracket) && space_before_self_closing_tag_slash {
+    if space_before_self_closing_tag_slash {
       items.push_str(""); // force current line indentation
       items.extend(space_if_not_start_line());
     }


Test patch:
diff --git a/tests/specs/jsx/JsxElement/JsxElement_BracketPosition_Maintain.txt b/tests/specs/jsx/JsxElement/JsxElement_BracketPosition_Maintain.txt
index 75a4aa0..2d15853 100644
--- a/tests/specs/jsx/JsxElement/JsxElement_BracketPosition_Maintain.txt
+++ b/tests/specs/jsx/JsxElement/JsxElement_BracketPosition_Maintain.txt
@@ -62,3 +62,11 @@ const x = (
         prop={5}
         other={10} />
 );
+
+== should maintain for single line ==
+const t = <MyComponent someProp={value} />;
+const u = <MyComponent></MyComponent>;
+
+[expect]
+const t = <MyComponent someProp={value} />;
+const u = <MyComponent></MyComponent>;
diff --git a/tests/specs/jsx/JsxElement/JsxElement_BracketPosition_NextLine.txt b/tests/specs/jsx/JsxElement/JsxElement_BracketPosition_NextLine.txt
index 0494161..0d78b54 100644
--- a/tests/specs/jsx/JsxElement/JsxElement_BracketPosition_NextLine.txt
+++ b/tests/specs/jsx/JsxElement/JsxElement_BracketPosition_NextLine.txt
@@ -53,3 +53,11 @@ const w = (
         other={10}
     />
 );
+
+== should maintain for single line ==
+const t = <MyComponent someProp={value} />;
+const u = <MyComponent></MyComponent>;
+
+[expect]
+const t = <MyComponent someProp={value} />;
+const u = <MyComponent></MyComponent>;
diff --git a/tests/specs/jsx/JsxElement/JsxElement_BracketPosition_SameLine.txt b/tests/specs/jsx/JsxElement/JsxElement_BracketPosition_SameLine.txt
index 3c1feb0..735d063 100644
--- a/tests/specs/jsx/JsxElement/JsxElement_BracketPosition_SameLine.txt
+++ b/tests/specs/jsx/JsxElement/JsxElement_BracketPosition_SameLine.txt
@@ -50,3 +50,11 @@ const w = (
         prop={5}
         other={10} />
 );
+
+== should maintain for single line ==
+const t = <MyComponent someProp={value} />;
+const u = <MyComponent></MyComponent>;
+
+[expect]
+const t = <MyComponent someProp={value} />;
+const u = <MyComponent></MyComponent>;