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

Make rule vue/no-unregistered-components ignore recursive components #1305

Conversation

arrudaje
Copy link
Contributor

@arrudaje arrudaje commented Sep 21, 2020

Right now when we use recursive components (when we want to use the current component inside of itself - with the example of a Note component that can have a number of replies, that look and behave exactly like the Note component, and they stack inside of one another), eslint-plugin-vue complains against it, making us disable this rule every time we want to use a recursive component.

The suggestion is to include a new argument to the rule, ignoreRecursive, which, if true, checks whether the name of the parent component is the same as the child component (making it thus a recursive component), not warning about this rule on it.

Resolves #1304

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.

Thank you for this PR and report! Sorry for the late reply.

I didn't know that I could use self component in <template> using the same name as name option.
I think it's a bug, so I don't think it's necessary to add option.

lib/rules/no-unregistered-components.js Outdated Show resolved Hide resolved
lib/rules/no-unregistered-components.js Outdated Show resolved Hide resolved
lib/rules/no-unregistered-components.js Outdated Show resolved Hide resolved
@arrudaje
Copy link
Contributor Author

arrudaje commented Oct 5, 2020

Thank you for this PR and report! Sorry for the late reply.

I didn't know that I could use self component in <template> using the same name as name option.
I think it's a bug, so I don't think it's necessary to add option.

@ota-meshi Thank you for your reply!
Actually it's a feature in Vue. I don't know why they decided to remove the guide (v2) for recursive components in v3, but I found a mention in this page https://v3.vuejs.org/api/options-misc.html#name.
Also, it's very useful when you want to render a tree-like component, such as a comment thread (with many replies one inside the other) or an expandable menu.
Please tell me what you think, and this probably can clear out some of the comments you made here also, although I will try to work on them.

lib/rules/no-unregistered-components.js Outdated Show resolved Hide resolved
lib/rules/no-unregistered-components.js Outdated Show resolved Hide resolved
lib/rules/no-unregistered-components.js 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!

@ota-meshi ota-meshi added the bug label Oct 9, 2020
@ota-meshi ota-meshi merged commit d626ec1 into vuejs:master Oct 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optionally ignore vue/no-unregistered-components warnings against recursive components
2 participants