question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rule proposal: `require-component-name`

See original GitHub issue

Please describe what the rule should do:

This rule warns you if the component’s name property is undefined

What category of rule is this?

[x] Enforces code style [ ] Warns about a potential error [ ] Suggests an alternate way of doing something [ ] Other (please specify:)

Provide 2-3 code examples that this rule will warn about:

// bad
export default {
  render(){
    return <div />
  }
}
// good
export default {
  name: 'div-component',
  render(){
    return <div />
  }
}

Why should this rule be included

Naming components is a good practice. It makes it easier to debug your code with Vue Devtools, and helps you to keep your code organized. So much so that at least 2 rules on the Style Guide address the issue of how to name your components - one of them is a essential rule.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:26 (17 by maintainers)

github_iconTop GitHub Comments

4reactions
LinusBorgcommented, Dec 2, 2017

The name is necessary when rendering a component recursively.

4reactions
chrisvfritzcommented, Dec 2, 2017

Hmm, I would probably leave this out of the style guide and keep it in the uncategorized section here, because a name option is not actually useful in the vast majority of cases. For example:

  • When registering a component locally, as the Vue devtools will use the component’s local name.
  • When registering a component globally, as providing a name is part of that process.
  • When importing a .vue component to be used in a render function, as a name will be derived from the __file property that’s added to the default export.

So now that I think about it actually, and especially since functional components can now be written in .vue files, I can’t think of a real use case where a component needs the name option to be specified. Did I miss any common (or even uncommon) scenarios?

Read more comments on GitHub >

github_iconTop Results From Across the Web

A different RequireComponent - Unity Forum
Hey guys, I made a simple script that adds a useful functionality for component fields in inspector, instead of the "RequireComponent...
Read more >
Scripting API: RequireComponent - Unity - Manual
The RequireComponent attribute automatically adds required components as dependencies. When you add a script which uses RequireComponent to a GameObject, the ...
Read more >
Conditions and Requirements for Relying on Component Part ...
Proposed § 1105.5(a)(1) would state that finished product certifiers may rely on testing of a component part of a consumer product only where ......
Read more >
vue/no-unsupported-features
This rule reports unsupported Vue.js syntax on the specified version. Options #. json { " ...
Read more >
Food and Drug Regulations ( CRC , c. 870) - Laws.justice.gc.ca
(10) Subsection (2) does not apply to the following common names if the common name appears on the principal display panel in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found