From d1660232b0525cb96299c036a90cb8dfaf1eec2a Mon Sep 17 00:00:00 2001 From: HEGGRIA Date: Thu, 29 Aug 2024 21:31:08 +0800 Subject: [PATCH 1/3] Fix the `vue/v-on-handler-style` breaking change (#2538) --- lib/rules/v-on-handler-style.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/rules/v-on-handler-style.js b/lib/rules/v-on-handler-style.js index 10ff9b6b1..c4b862c81 100644 --- a/lib/rules/v-on-handler-style.js +++ b/lib/rules/v-on-handler-style.js @@ -314,6 +314,10 @@ module.exports = { return null } const paramCount = methodParamCountMap.get(idCallExpr.callee.name) + // disable the auto-fixed when the node does't have params + if (paramCount == 0) { + return null + } if (paramCount != null && paramCount > 0) { // The behavior of target method can change given the arguments. return null @@ -368,7 +372,8 @@ module.exports = { ) { return null } - if (!isSameParamsAndArgs(idCallExpr)) { + // disable the auto-fixed when the node does't have params + if (node.params.length === 0 || !isSameParamsAndArgs(idCallExpr)) { // It is not a call with the arguments given as is. return null } From 6498a892493bb8c6e34139e8a68882500cd64cba Mon Sep 17 00:00:00 2001 From: HEGGRIA Date: Fri, 30 Aug 2024 11:09:45 +0800 Subject: [PATCH 2/3] Modify test of`vue/v-on-handler-style` (#2538) --- lib/rules/v-on-handler-style.js | 2 +- tests/lib/rules/v-on-handler-style.js | 65 +++++---------------------- 2 files changed, 13 insertions(+), 54 deletions(-) diff --git a/lib/rules/v-on-handler-style.js b/lib/rules/v-on-handler-style.js index c4b862c81..5b43fac97 100644 --- a/lib/rules/v-on-handler-style.js +++ b/lib/rules/v-on-handler-style.js @@ -315,7 +315,7 @@ module.exports = { } const paramCount = methodParamCountMap.get(idCallExpr.callee.name) // disable the auto-fixed when the node does't have params - if (paramCount == 0) { + if (idCallExpr.arguments.length === 0 || paramCount === 0) { return null } if (paramCount != null && paramCount > 0) { diff --git a/tests/lib/rules/v-on-handler-style.js b/tests/lib/rules/v-on-handler-style.js index a169402f7..7859596c8 100644 --- a/tests/lib/rules/v-on-handler-style.js +++ b/tests/lib/rules/v-on-handler-style.js @@ -81,11 +81,7 @@ tester.run('v-on-handler-style', rule, {