From 8a781f0ca28a1dd415c7e5d10886816bf6d628a5 Mon Sep 17 00:00:00 2001 From: claneo Date: Fri, 23 Feb 2024 10:50:07 +0800 Subject: [PATCH] fix(no-useless-v-bind): remove spaces around string in fixes (#2408) Co-authored-by: Flo Edelmann --- lib/rules/no-useless-v-bind.js | 4 +++- tests/lib/rules/no-useless-v-bind.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) 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, '"') + attrValue = quoteChar + attrValue + quoteChar } else if (quoteChar === "'") { attrValue = strValue.replace(SINGLE_QUOTES_RE, ''') + attrValue = quoteChar + attrValue + quoteChar } else { attrValue = strValue .replace(DOUBLE_QUOTES_RE, '"') .replace(SINGLE_QUOTES_RE, ''') } - yield fixer.replaceText(expression, attrValue) + yield fixer.replaceText(value, attrValue) } }) } 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: ` + `, + output: ` + `, + 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.' + ] } ] })