-
-
Notifications
You must be signed in to change notification settings - Fork 666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rule vue/v-on-handler-style
default auto fix will bring breaking change into code
#2538
Comments
vue/v-on-handler-style
default auto fix will bring breaking change into code
I guess changing the fix to a suggestion that has to be manually applied makes sense here. PRs welcome for that! |
I believe this rule will stop unsafe auto-fixes if the method is specific and the number of arguments is known. But it seems to do an unsafe auto-fix if it can't find the method. |
@ota-meshi Thank you for your response. Based on my understanding, a better approach to improve the current code would be as follows:
Please let me know if I've misunderstood anything. Thanks again! |
There was a similar issue a while ago #1345 |
I think it could probably be auto-fixed if the number of arguments and parameters matched. <template>
<MyButton @click="(a) => fn1(a)" />
<MyButton @click="(a, b) => fn2(a, b)" />
<!-- Can't auto-fix -->
<MyButton @click="(a) => fn2(a)" />
</template>
<script setup>
function fn1(a) {}
function fn2(a, b) {}
</script> |
What rule do you want to change?
vue/v-on-handler-style
Does this change cause the rule to produce more or fewer warnings?
More
How will the change be implemented? (New option, new default behavior, etc.)?
What does the rule currently do for this code?
In the current default configuration, such as
vue/v-on-handler-style: 'warn'
, the rule will apply the following formatting by default:When the first argument of
changeFunc
is not anevent
and can beundefined
, this auto-fix may lead to a breaking change in the code logic. This is because using@click="changeFunc"
will pass the event object to changeFunc by default, causing logic errors in the subsequent code.What will the rule do after it's changed?
By default, the rule will no longer automatically fix the following two types of
v-on
syntax:The text was updated successfully, but these errors were encountered: