Skip to content

vue/no-undef-components is expected to report error if component is type only #1963

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

Closed
2 tasks done
Amorites opened this issue Sep 8, 2022 · 1 comment · Fixed by #1967
Closed
2 tasks done

vue/no-undef-components is expected to report error if component is type only #1963

Amorites opened this issue Sep 8, 2022 · 1 comment · Fixed by #1967

Comments

@Amorites
Copy link
Contributor

Amorites commented Sep 8, 2022

Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: 8.23.0
  • eslint-plugin-vue version: 9.4.0
  • Node version: 16.17.0
  • Operating System: MacOS 12.5

Please show your full configuration:

module.exports = {
  extends: [
    // add more generic rulesets here, such as:
    // 'eslint:recommended',
    'plugin:vue/vue3-recommended',
    // 'plugin:vue/recommended' // Use this if you are using Vue.js 2.x.
  ],
  rules: {
    // override/add rules settings here, such as:
    // 'vue/no-unused-vars': 'error'
    'vue/no-undef-components': 'error',
  },
  parser: 'vue-eslint-parser',
  parserOptions: {
    extraFileExtensions: ['.vue'],
    parser: '@typescript-eslint/parser',
    ecmaVersion: 2022, // Allows for the parsing of modern ECMAScript features
    sourceType: 'module', // Allows for the use of imports
  },
};

What did you do?

<script setup lang="ts">
import type HelloWorld from './components/HelloWorld.vue';
</script>

<template>
  <div>
    <a href="https://vitejs.dev" target="_blank">
      <img src="/vite.svg" class="logo" alt="Vite logo" />
    </a>
    <a href="https://vuejs.org/" target="_blank">
      <img src="./assets/vue.svg" class="logo vue" alt="Vue logo" />
    </a>
  </div>
  <HelloWorld msg="Vite + Vue" />
  <Foo></Foo>
</template>

What did you expect to happen?

<HelloWorld msg="Vite + Vue" /> is expected to report no-undef-component error like <Foo></Foo>

What actually happened?

<HelloWorld msg="Vite + Vue" /> doesn't trigger a eslint error

Repository to reproduce this issue

https://github.com/Amorites/eslint-plugin-vue-repro/blob/main/src/App.vue

@Amorites
Copy link
Contributor Author

After doing some inspect, I found that it might be possible to use importKind to distinguish whether it's a type-only import or not.

With any luck, I can make a PR today.

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

Successfully merging a pull request may close this issue.

2 participants