Skip to content
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 suggestion: vue/no-restricted-v-on #2243

Closed
ericuldall opened this issue Jul 19, 2023 · 2 comments · Fixed by #2367
Closed

Rule suggestion: vue/no-restricted-v-on #2243

ericuldall opened this issue Jul 19, 2023 · 2 comments · Fixed by #2367

Comments

@ericuldall
Copy link

What rule do you want to change?
no-restricted-static-attribute

Does this change cause the rule to produce more or fewer warnings?
More warnings

How will the change be implemented? (New option, new default behavior, etc.)?
It would be nice to optionally allow directive matching

Please provide some example code that this change will affect:

<div @click="foo">Why you clicking a div?</div>

What does the rule currently do for this code?
Nothing

What will the rule do after it's changed?
Allow matching key to be @click

Additional context
I'm trying to implement it like so:

{
  "vue/no-restricted-static-attribute": ["error",
    {
      "key": "@click",
      "element": "div",
      "message": "Using \"@click\" is not allowed on div's. Use interactive elements instead."
    }
  ]
}

Perhaps this makes sense as a new rule like vue/no-handlers-on-non-interactive-elements
but for now the flexibility of just grouping the directives as an attribute would work as well.

@FloEdelmann
Copy link
Member

FloEdelmann commented Jul 25, 2023

I think it should be a new rule vue/no-restricted-v-on that works similarly to the vue/no-restricted-v-bind rule and other vue/no-restricted-* rules.

Would you like to give it a try in a PR?

@FloEdelmann FloEdelmann changed the title no-restricted-static-attribute allow directives Rule suggestion: vue/no-restricted-v-on Jul 25, 2023
@thesheppard
Copy link
Contributor

@FloEdelmann @ericuldall I've taken a shot at this and have attached a PR

@FloEdelmann FloEdelmann linked a pull request Jan 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants