Repository: vuejs/eslint-plugin-vue (JavaScript)

Issue:
`vue/no-useless-v-bind` auto-fix adds extra whitespace
<!--
  ❗Please don't ignore this template.❗

  If you ignore it, we're just going to respond asking you to fill it out, which wastes everyone's time.
  The more relevant information you can include, the faster we can find the issue and fix it without asking you for more info.
-->

<!--
  Before posting the issue, please confirm that the problem you're getting
  is not related with your code editor configuration.
  To make sure it's not, run: yarn eslint src/your-file.vue
-->

**Checklist**

- [x] I have tried restarting my IDE and the issue persists.
- [x] I have read the [FAQ](https://eslint.vuejs.org/user-guide/#faq) and my problem is not listed.
<!-- If you do not read the FAQ and open an issue that is listed in the FAQ, we may silently close the issue. -->

**Tell us about your environment**

- **ESLint version:** 8.56.0
- **eslint-plugin-vue version:** 9.21.1
- **Vue version:** 
- **Node version:** 
- **Operating System:** 

**Please show your full configuration:**
<!-- Paste content of your .eslintrc file -->
```json5
module.exports = {
    extends: ['plugin:vue/recommended'],
    rules: {
        'vue/no-useless-v-bind': 'error',
    },
};
```

**What did you do?**	
<!-- Please include the actual source code causing the issue. -->
```vue
<template>
  <div 
    :title="
      'text'
    "
  />
</template>
```

**What did you expect to happen?**

```vue
<template>
  <div 
    title="text"
  />
</template>
```


**What actually happened?**
<!--
  Please include the actual, raw output from ESLint.
  If you are only looking at the results of your editor extension, also check the CLI results.
-->

```vue
<template>
  <div 
    title="
      text
    "
  />
</template>
```

**Repository to reproduce this issue**
<!--
  ❗ Please share a repository that can reproduce your issue.
  ❗ If you don't share it, we just label it as requesting a repository that can reproduce your issue.
  ❗ If you don't share it for a few days, we silently close this issue.
-->

[Playground](https://ota-meshi.github.io/eslint-plugin-vue-demo/#eJx1lMFynDAMhl9lh0su8WSmx0zaJ8lFmB9QYmwq27tLM3n3Csga2KanXX2yhfRL8kdlQ4PquXpJGEZHCb9e/en00vD5NP85nZ4TJ4efr9Vqnk4PCdf0sForfdI7L08lQPVYSXaI1fNHdc54smEY4JNpWGATn/VzPx4Xz1u8mhwRzZkkLtQGH5Nkm4KYmEfIQlu1vm4Hv5AOKUGMIGVZiQ+G4uStGSUMHGFwhc0a5+a1pLCBdSQ0x4nF4ShGvRy5K6E055EExqMzfyBh477556im/B0jrXk+zyXr1ZMkOM28w/UGG9S56yCb7ZAwq1KIamFIungAa+YDhhpy9MBpsdwe2Dum/SHHVru1yHKj2sE0HQxje5XLzlovHzs6R5q7UGrD9U4GHRQhU4fgQH7+Urp5WnIu9RJy1xeUtXnH+50LNbk7yMMY5F5w9l5T/K677M/kuFkFHwsVtbMeNpeeE+JItqjggooaWh0kWI673ulYaSEN++5/snhcTJyGOrhCgg82aRGaGw/6i2hpLN8K9Zvq4lyJsBy+GTrKKaRJe1dndom3qgRrrdiAlmeWOsqhCNfe6RS/25vYUxMuCnX1WItqjKdhF0Y3Ic7TJ7QNUOo5mhq6mdgtqjqyb9BuhmqOJeSQtQDHHptPQKpj7XYoUgvTsldJpjuqq0j7TfrCYZyhCquh2GtvNr8+LY1xVGOT9wuW92ZGKhO04zXZd0ELgd9m4ebUVbH9PTy28sJpPSH4nfWxMhPDNQvJ8zJGT2vu6zzObQ1teQp3Yc+mZj9f/Pz8C+Aj6Ao=)




Discussion:
Thanks for the report! PRs are welcome :)



Patch:
diff --git a/lib/rules/no-useless-v-bind.js b/lib/rules/no-useless-v-bind.js
index 34f0ad033..54584b389 100644
--- a/lib/rules/no-useless-v-bind.js
+++ b/lib/rules/no-useless-v-bind.js
@@ -132,14 +132,16 @@ module.exports = {
           let attrValue
           if (quoteChar === '"') {
             attrValue = strValue.replace(DOUBLE_QUOTES_RE, '&quot;')
+            attrValue = quoteChar + attrValue + quoteChar
           } else if (quoteChar === "'") {
             attrValue = strValue.replace(SINGLE_QUOTES_RE, '&apos;')
+            attrValue = quoteChar + attrValue + quoteChar
           } else {
             attrValue = strValue
               .replace(DOUBLE_QUOTES_RE, '&quot;')
               .replace(SINGLE_QUOTES_RE, '&apos;')
           }
-          yield fixer.replaceText(expression, attrValue)
+          yield fixer.replaceText(value, attrValue)
         }
       })
     }


Test patch:
diff --git a/tests/lib/rules/no-useless-v-bind.js b/tests/lib/rules/no-useless-v-bind.js
index 907125cc1..34a76d0df 100644
--- a/tests/lib/rules/no-useless-v-bind.js
+++ b/tests/lib/rules/no-useless-v-bind.js
@@ -136,6 +136,34 @@ tester.run('no-useless-v-bind', rule, {
         'Unexpected `v-bind` with a string literal value.',
         'Unexpected `v-bind` with a string literal value.'
       ]
+    },
+    {
+      code: `
+      <template>
+        <div :id="    'foo'    " />
+        <div :id='    "foo"    ' />
+        <div :id="   \`foo\`   " />
+        <div :id='   \`foo\`   ' />
+        <div :id="' \\'foo\\' '" />
+        <div :id='" \\"foo\\" "' />
+      </template>`,
+      output: `
+      <template>
+        <div id="foo" />
+        <div id='foo' />
+        <div id="foo" />
+        <div id='foo' />
+        <div id=" 'foo' " />
+        <div id=' "foo" ' />
+      </template>`,
+      errors: [
+        'Unexpected `v-bind` with a string literal value.',
+        'Unexpected `v-bind` with a string literal value.',
+        'Unexpected `v-bind` with a string literal value.',
+        'Unexpected `v-bind` with a string literal value.',
+        'Unexpected `v-bind` with a string literal value.',
+        'Unexpected `v-bind` with a string literal value.'
+      ]
     }
   ]
 })