Skip to content

πŸ’₯ Force camelCase in Vue everywhere, including props/attrsΒ #1219

@ShGKme

Description

@ShGKme

Proposal

  • 'vue/component-name-in-template-casing': ['error', 'PascalCase] (βœ… default, used)
  • 'vue/custom-event-name-casing': ['error', 'camelCase'] (βœ… default, used)
  • 'vue/slot-name-casing': ['error', 'camelCase'] (βž• default, add the rule)
  • 'vue/attribute-hyphenation': ['error', 'never'] (πŸ’₯ opposite, change)

Motivation

  1. Having different cases in template and script makes it harder to find prop usage with a simple search
  2. Different tooling handle kebab-case worse, for example, with the new v-bind shortcut syntax <Tag :foo-bar /> from fooBar property, with refactoring and etc.
  3. After introducing slot-name-casing, attributes are the only with kebab-case

Isn't it against Vue Style Guide?

Not really, now both styles are correct if consistent: https://vuejs.org/style-guide/rules-strongly-recommended.html#prop-name-casing

In addition, the Vue Style Guide is:

  • Not permanent: just recently <kebab-case> was the recommended default to component names in the template
  • Not consistent: PascalCase/camelCase for components, event, slots and kebab for props
  • Sometimes slow to adapt: before supporting in-dom templates was more important than nowadays, Vue 3 Style Guide was in active development for a long time after the Vue 3 release

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions