From 641f404f74331c96c826f0869e7206f0ebe1806b Mon Sep 17 00:00:00 2001 From: claneo Date: Wed, 21 Feb 2024 09:54:43 +0800 Subject: [PATCH 1/3] fix(no-useless-v-bind): remove spaces around string in fixes --- lib/rules/no-useless-v-bind.js | 4 +++- tests/lib/rules/no-useless-v-bind.js | 16 ++++++++++++++++ 2 files changed, 19 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..f0c57f0e0 100644 --- a/tests/lib/rules/no-useless-v-bind.js +++ b/tests/lib/rules/no-useless-v-bind.js @@ -136,6 +136,22 @@ 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.' + ] } ] }) From 4a901816e211bec325e2a4ce095703902231bd64 Mon Sep 17 00:00:00 2001 From: claneo Date: Thu, 22 Feb 2024 10:12:29 +0800 Subject: [PATCH 2/3] add more testcase --- tests/lib/rules/no-useless-v-bind.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tests/lib/rules/no-useless-v-bind.js b/tests/lib/rules/no-useless-v-bind.js index f0c57f0e0..e0edb17bc 100644 --- a/tests/lib/rules/no-useless-v-bind.js +++ b/tests/lib/rules/no-useless-v-bind.js @@ -140,15 +140,35 @@ tester.run('no-useless-v-bind', rule, { { 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.' ] From d6e3a33d596aabff5dffd4651587507499325315 Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Thu, 22 Feb 2024 09:50:05 +0100 Subject: [PATCH 3/3] Remove test cases using invalid code --- tests/lib/rules/no-useless-v-bind.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/lib/rules/no-useless-v-bind.js b/tests/lib/rules/no-useless-v-bind.js index e0edb17bc..34a76d0df 100644 --- a/tests/lib/rules/no-useless-v-bind.js +++ b/tests/lib/rules/no-useless-v-bind.js @@ -146,10 +146,6 @@ tester.run('no-useless-v-bind', rule, {
-
-
-
-
`, output: ` `, errors: [ 'Unexpected `v-bind` with a string literal value.',