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 proposal: component-name-in-template-casing #250

Closed
michalsnik opened this issue Nov 26, 2017 · 6 comments
Closed

Rule proposal: component-name-in-template-casing #250

michalsnik opened this issue Nov 26, 2017 · 6 comments

Comments

@michalsnik
Copy link
Member

Style guide:
https://vuejs.org/v2/style-guide/#Component-name-casing-in-templates-strongly-recommended

Description:
This rule would ensure proper component names in templates. As we only check .vue files in terms of templates we can provide both options: kebab-case and PascalCase

Good examples:

  • kebab-case
<the-component />
  • PascalCase
<TheComponent />

Bad examples:

<theComponent />
<Thecomponent />
<The-component />

and obviously with kebab-case option it would warn about PascalCase and vice-versa.

Default option would be PascalCase.

@michalsnik michalsnik changed the title Rule proposal: component-name-casing Rule proposal: component-name-in-template-casing Nov 26, 2017
@michalsnik michalsnik self-assigned this Jan 3, 2018
@ota-meshi
Copy link
Member

I'm sorry. I made a mistake in refs at PR 402 m(_ _)m

@Mouvedia
Copy link

Mouvedia commented Apr 14, 2018

@probil
Copy link

probil commented Jun 8, 2018

@Mouvedia, It should https://vuejs.org/v2/style-guide/#Component-name-casing-in-templates-strongly-recommended
And vue components are not custom elements

@Mouvedia
Copy link

Mouvedia commented Jun 8, 2018

@probil The rule is called component-name-in-template-casing and the style guide that you have linked just above support the kebab-case for DOM templates and "everywhere" else but single file components. It concludes with:

using kebab-case everywhere is also acceptable

Why? Because using PascalCase in SFC and kebab-case everywhere else would be inconsistent: we should recommend and support a solution that doesn't require to make that distinction.

@probil
Copy link

probil commented Jun 8, 2018

@Mouvedia Agree with you. PascalCase is not the best option for everyone. But the same for kebab-case.
I don't think this eslint plugin is able to parse DOM templates at all. Because currently it relies on *.vue extension and // @vue/component comment so only SFC will be checked. But DOM templates are usually hidden somewhere in the back-end templates. Correct me please, if I'm wrong here.

In most projects, component names should always be PascalCase in single-file components

This plugin tries to follow official Vue Style Guide so PascalCase should be default. But of course. there should be configuration for this rule. So you can easily configure it to use kebab-case or both if you like

@Mouvedia
Copy link

Mouvedia commented Jun 8, 2018

It depends on what matters the most to you:

  • one is official and recent (september 2017)
  • the other has precedence and hence is wide spread (january 2017)

Both are valid options and have CONs/PROs.
One reason we should go with one or the other is if a convention exists on the React side: it would be detrimental to not follow their lead.

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

No branches or pull requests

4 participants