Skip to content

disallow name in Options API component #2087

Open
@privatenumber

Description

@privatenumber

Please describe what the rule should do:

Disallow name from being set on Option API style components.

The name property should generally be the file name, and since vue-loader defaults the component name with the file name, it's not necessary to set manually.

This rule will be helpful in discouraging the practice and removing unused strings in the codebase for a smaller bundle size.

FYI In Vue 3, there's no way to set the component name; it's just the file name.

What category should the rule belong to?

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

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

<script>
export default {
  name: 'ComponentName'
})
</script>

However, I think recursive components should be fine (unless vue-loader is able to resolve the self-recursion by file name):

<template>
	<div>
		<component-name />
	</div>
</template>
<script>
export default {
  name: 'ComponentName'
})
</script>

Additional context

Perhaps this rule can be merged with https://eslint.vuejs.org/rules/require-name-property.html

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions