Skip to content

attribute-hyphenation rule has no effect on event attributes #586

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

Closed
churkin opened this issue Sep 26, 2018 · 2 comments
Closed

attribute-hyphenation rule has no effect on event attributes #586

churkin opened this issue Sep 26, 2018 · 2 comments

Comments

@churkin
Copy link

churkin commented Sep 26, 2018

ESLint Version: 5.4.0
eslint-plugin-vue Version: 4.7.1

Rule:
"vue/attribute-hyphenation": [2, "always"]

Code:

<data-grid
  :showBorders="true"
  keyExpr="ID"
  @selectionChanged="onSelectionChanged"
>

I get two errors, but should three:

6:7 error Attribute ':showBorders' must be hyphenated vue/attribute-hyphenation
8:7 error Attribute 'keyExpr' must be hyphenated vue/attribute-hyphenation

✖ 2 problems (2 errors, 0 warnings)
2 errors and 0 warnings potentially fixable with the --fix option.

@michalsnik
Copy link
Member

This is an expected behaviour @churkin But it might be worth it to add an extra rule for forcing hypenation in events too, the rule could both report:

  • listener @someEvent=""
  • emitter this.$emit('someEvent') (in template and script tag)
    and automatically fix all of them 👍

This seems like a good rule proposition, especially in regard to info from official documentation: https://vuejs.org/v2/guide/components-custom-events.html

Unlike components and props, event names will never be used as variable or property names in JavaScript, so there’s no reason to use camelCase or PascalCase. Additionally, v-on event listeners inside DOM templates will be automatically transformed to lowercase (due to HTML’s case-insensitivity), so v-on:myEvent would become v-on:myevent – making myEvent impossible to listen to.

I looked at the opened issues, and it seems we already have this proposal here: #356

So I'm closing this issue in favour of the former one, let's continue discussion there :)

@acacia314
Copy link

@michalsnik I don't think #356 addressed the hyphenation of the event listener attribute, eg @someEvent is still allowed and there's no rule to enforce '@some-event' format like there is for attributes with attribute-hyphenation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants