eslint-plugin-vue
eslint-plugin-vue copied to clipboard
no-unused-components with class-components does not work
.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>
- 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 Here is my workaround. https://github.com/negibouze/customize-no-unused-components-rule
Any official fix for this ?
No progress has been made on this so far.
do you still plan to support this?
@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
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.