eslint-plugin-vue icon indicating copy to clipboard operation
eslint-plugin-vue copied to clipboard

no-unused-components with class-components does not work

Open D3-FC opened this issue 6 years ago • 6 comments

.eslintrc.js:

module.exports = {
  root: true,
  env: {
    node: true
  },
  'extends': [
    'plugin:vue/essential',
    '@vue/standard',
    '@vue/typescript'
  ],
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
  },
  parserOptions: {
    parser: '@typescript-eslint/parser'
  }
}

**eslint-plugin-vue version: ** ^5.0.0

Node version: v8.12.0

My Actions:

1. Created new vue-cli project

2. Created component

<template>
  <div>
  </div>
</template>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
import TestComponent from '@/components/TestComponent.vue'
@Component({
  components: { TestComponent }
})
export default class HelloWorld extends Vue {

}
</script>
  1. Ran linter with command: 'vue-cli-service lint'

What actually happened?:

linter log: DONE No lint errors found!

Expecting Error:

Component TestComponent was registered, but never used

D3-FC avatar Mar 15 '19 17:03 D3-FC

@D3-FC Here is my workaround. https://github.com/negibouze/customize-no-unused-components-rule

negibouze avatar Sep 11 '19 04:09 negibouze

Any official fix for this ?

tomiiide avatar May 27 '21 11:05 tomiiide

No progress has been made on this so far.

ota-meshi avatar May 27 '21 12:05 ota-meshi

do you still plan to support this?

beit46 avatar Jul 21 '21 14:07 beit46

@negibouze Has a great solution but it didn't work for me because I was using the following ESLint config

{
        parser: require.resolve("vue-eslint-parser"),
	parserOptions: {
		parser: "@typescript-eslint/parser"
        }
}

So I updated his rule and the updated code is here - https://gist.github.com/NikhilVerma/7613191dfffb38011ebb3c95468a423a

Follow his repo example to see how to use it : https://github.com/negibouze/customize-no-unused-components-rule

NikhilVerma avatar Oct 05 '21 17:10 NikhilVerma

Vue Class Component is no longer actively maintained and not recommended for Vue 3: https://class-component.vuejs.org/

This library is no longer actively maintained. It is no longer recommend to use Class-based components in Vue 3. The recommended way to use Vue 3 in large applications is Single-File Components, Composition API, and <script setup>.

So I suggest to not invest time in eslint-plugin-vue to start supporting this.

FloEdelmann avatar Dec 06 '23 16:12 FloEdelmann