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

⭐️ New: Add rule no-reserved-component-names #757

Merged
merged 10 commits into from Dec 26, 2019

Conversation

shadskii
Copy link
Contributor

@shadskii shadskii commented Jan 8, 2019

This rule addresses #486 and prevents name collisions with vue component and standard html elements. Both PascalCase names and kebab-case names of standard html elements are invalid. For example, 'div' and 'Div' are both treated as reserved names.

Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shadskii Thank you for this PR!

I have some requests.

lib/rules/no-reserved-component-names.js Outdated Show resolved Hide resolved
lib/rules/no-reserved-component-names.js Outdated Show resolved Hide resolved
docs/rules/no-reserved-component-names.md Outdated Show resolved Hide resolved
Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

@shadskii
Copy link
Contributor Author

shadskii commented Jan 9, 2019

I've added warnings for locally registered components as @michalsnik suggested in #486.
For example:

export default {
  components: {
    'font-face': {},
  }
}

Thanks for the suggestion!

@Mouvedia
Copy link

Mouvedia commented Jan 9, 2019

The nobr, strike and acronym tags are missing from this list.

@shadskii
Copy link
Contributor Author

The nobr, strike and acronym tags are missing from this list.

Originally, I chose to only check for non-obsolete elements. nobr, strike and acronym are all obsolete (see their MDN reference nobr, strike, and acronym ). You bring up a good question: Should we check for obsolete or deprecated tags? I'm inclined to believe the answer is yes. Browsers still render deprecated tags and this will result in a name collision if a vue component shares the same name.

MDN lists 31 obsolete and deprecated elements (see this list). I have added deprecated-html-elements.json with these elements and updated this rule to search for them.

Thank you for reviewing this pull request and please let me know if you agree with the updates I've made!

@Mouvedia
Copy link

Mouvedia commented Jan 10, 2019

I'm inclined to believe the answer is yes.

I agree as well, but I wanted to illustrate the need with elements that are obsolete but still heavily exploited nowadays.

Thank you for reviewing this pull request and please let me know if you agree with the updates I've made!

These were merely comments. I didn't review your code nor do I have the time to.
Thank you for the PR.

@ota-meshi ota-meshi merged commit b19843c into vuejs:master Dec 26, 2019
@vue-bot
Copy link

vue-bot commented Dec 26, 2019

Hey @shadskii, thank you for your time and effort spent on this PR, contributions like yours help make Vue better for everyone. Cheers! 💚

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

Successfully merging this pull request may close these issues.

None yet

4 participants