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

Add vue/no-unregistered-components rule #1114

Merged
merged 14 commits into from May 15, 2020
Merged

Add vue/no-unregistered-components rule #1114

merged 14 commits into from May 15, 2020

Conversation

jesusgn90
Copy link
Contributor

@jesusgn90 jesusgn90 commented May 5, 2020

Closes #1112

Inspired by rules/no-unused-components so thanks to Michał Sajnóg.

What are your thoughts @ota-meshi? let me know if this is missing something or you have some concerns, thanks!

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! I think this rule will helpful people in some cases!

I have change requests.

lib/rules/no-unregistered-components.js Outdated Show resolved Hide resolved
tests/lib/rules/no-unregistered-components.js Show resolved Hide resolved
tests/lib/rules/no-unregistered-components.js Outdated Show resolved Hide resolved
docs/rules/no-unregistered-components.md Show resolved Hide resolved
docs/rules/no-unregistered-components.md Outdated Show resolved Hide resolved
docs/rules/no-unregistered-components.md Outdated Show resolved Hide resolved
tests/lib/rules/no-unregistered-components.js Show resolved Hide resolved
lib/rules/no-unregistered-components.js Outdated Show resolved Hide resolved
lib/rules/no-unregistered-components.js Show resolved Hide resolved
lib/rules/no-unregistered-components.js Show resolved Hide resolved
- Correct rule categories (null)
- Ignore `component :is="..."` component for well known HTML tags.
- Ignore `component`, `suspense`, `teleport` as unknown components.
@jesusgn90
Copy link
Contributor Author

@ota-meshi I think all the concerns are now fixed, tests are passing locally but the CI is blocking for netlify parts somehow and I don't know why, node CIs are passing though.

@jesusgn90 jesusgn90 requested a review from ota-meshi May 9, 2020 11:09
@jesusgn90
Copy link
Contributor Author

Seems like netlify parts are now happy, maybe the suspense and teleport corrections did the trick

tests/lib/rules/no-unregistered-components.js Show resolved Hide resolved
lib/rules/no-unregistered-components.js Show resolved Hide resolved
lib/rules/no-unregistered-components.js Show resolved Hide resolved
lib/rules/no-unregistered-components.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@jesusgn90
Copy link
Contributor Author

Ok I think I'm almost there, just missing the <component is="div"> edge case (atm supports only <component :is="'div'">, I'll re-request review once done

@jesusgn90 jesusgn90 requested a review from ota-meshi May 9, 2020 13:34
usedComponentNodes.push({ node, name: node.value.value })
},
"VElement[name='template']" (rootNode) {
templateLocation = templateLocation || rootNode.loc.start
Copy link
Member

Choose a reason for hiding this comment

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

This variable is no longer needed.

Copy link
Member

Choose a reason for hiding this comment

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

Please remove the templateLocation variable.

lib/rules/no-unregistered-components.js Show resolved Hide resolved
lib/rules/no-unregistered-components.js Outdated Show resolved Hide resolved
- Remove no longer needed variable.
-  Handle edge case where a component is registered using kebab-case but later on is used using PascalCase. e.g: registered as `foo-bar` and used as `FooBar` is not valid.
- Handle edge case `<component is />`, where `node.value` would be `null`. See https://github.com/mysticatea/vue-eslint-parser/blob/master/docs/ast.md#vattribute
- Add more tests to prove all these changes
@jesusgn90 jesusgn90 requested a review from ota-meshi May 10, 2020 10:56
@jesusgn90
Copy link
Contributor Author

@ota-meshi great insights into this, thanks for it. I've just pushed 7c3198c fixing (hopefully) all the new concerns.

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 making the changes!

However, there is one request remaining.

usedComponentNodes.push({ node, name: node.value.value })
},
"VElement[name='template']" (rootNode) {
templateLocation = templateLocation || rootNode.loc.start
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the templateLocation variable.

@jesusgn90
Copy link
Contributor Author

Thank you for making the changes!

However, there is one request remaining.

Yep, code updated, I forgot that one 👍

@jesusgn90 jesusgn90 requested a review from ota-meshi May 12, 2020 07:41
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 your contribution! Looks good to me!

@ota-meshi ota-meshi merged commit a7c6696 into vuejs:master May 15, 2020
@yoyo837
Copy link

yoyo837 commented May 17, 2022

Hey guys, How to lint Layout not found:

<script setup>
// import Layout from '@/components/common/Layout.vue';
import { RouterView } from 'vue-router';
import '@/stores';
</script>

<template>
  <Layout>
    <RouterView />
  </Layout>
</template>
    'vue/no-unregistered-components': [
      'error',
      {
        ignorePatterns: ['van(\\-\\w+)+', 'el(\\-\\w+)+'],
      },
    ],

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

Successfully merging this pull request may close these issues.

Warns you that a not registered component is being used in the template
3 participants