-
-
Notifications
You must be signed in to change notification settings - Fork 681
Some rules are not working while using vue-class-component #1000
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
Comments
Thank you for this issue. Currently, this plugin does not support vue-class-component. In order for this plugin to support vue-class-component, it is necessary to first identify the issues with each rule. I want you to help with this task. |
@ota-meshi class-component and property-decorator is not only used for typescript (but mostly). Main issue is with helper functions, there is no support for classes in them, in case of typescript + class some of rules are useless or they can be replaced by enforcing additional syntax on typescript, eg. if examples of rules that should be used in typescript + class: require-readonly-prop
module.exports = {
meta: {
fixable: 'code'
},
create (context) {
function checkClassProperty (node) {
const parent = node.parent
if (parent.type === 'ClassProperty') {
if (!parent.readonly) {
context.report({
message: '@Prop decorator should be readonly',
node: parent.key,
fix (fixer) {
return fixer.insertTextBefore(parent.key, 'readonly ')
}
})
}
} else {
context.report({
message: '@Prop decorator can be present only on ClassProperty',
node
})
}
}
return {
"Decorator[expression.type='Identifier'][expression.name='Prop']" (node) {
checkClassProperty(node)
},
"Decorator[expression.type='CallExpression'][expression.callee.type='Identifier'][expression.callee.name='Prop']" (node) {
checkClassProperty(node)
}
}
}
} no-undefined-data
module.exports = {
meta: {
fixable: undefined,
messages: {
error: 'Component data must have value, otherwise it\'s not going to be reactive'
}
},
create (context) {
function isUndefined (node) {
if (!node) {
return true
}
return node.type === 'Identifier' && node.name === 'undefined'
}
function hasComponentDecorator (node) {
if (!node || !node.decorators || !node.decorators.length) {
return false
}
return node.decorators.some((el) => {
return (
el.type === 'Decorator' &&
el.expression &&
(
(
el.expression.type === 'Identifier' &&
el.expression.name === 'Component'
) || (
el.expression.type === 'CallExpression' &&
el.expression.callee &&
el.expression.callee.type === 'Identifier' &&
el.expression.callee.name === 'Component'
)
)
)
})
}
return {
'ClassDeclaration > ClassBody > ClassProperty' (node) {
if (
(!node.decorators || !node.decorators.length) &&
hasComponentDecorator(node.parent.parent) &&
isUndefined(node.value)
) {
context.report({
messageId: 'error',
node
})
}
}
}
}
}
|
@ota-meshi "Currently, this plugin does not support vue-class-component." - Can you provide more information please? |
Another rule doesn't work: Doc: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/match-component-file-name.md <script lang="ts">
// components/Normal.vue
import { Component, Vue } from 'vue-property-decorator';
// @vue/component
@Component
export default class Lol extends Vue {
render(): null { return null; }
}
</script> with the rule declared as {
'vue/match-component-file-name': ['error', {
extensions: ['.vue', 'vue', 'vue.ts', 'jsx'],
shouldMatchCase: true,
}]
} |
This is still an issue, are there plans to fix it? |
Vue Class Component is no longer actively maintained and not recommended for Vue 3: https://class-component.vuejs.org/
So I suggest to not invest time in eslint-plugin-vue to start supporting this. |
My environment
Please show your full configuration:
What did you do?
import { Vue } from "vue-property-decorator" interface IState { arr: [] } interface IProps { 'prop-a': number } export default class Home extends Vue<IState, IProps> { // todo:eslint message: string = 'hello' message = 'hello' activated () { this.$el = 'nnn' console.log('actived') } onClick (): void { const message = 'dd' console.log(message) console.log(this.message) const longStr = 'str1234567…………189190191……str1………189190191……189190191……str1234567…………18919019str1234567…………189190191……str1234567…………189190191……str1234567…………189190191……1……' console.log(longStr) } get valA () { return Promise.all([new Promise((resolve) => {resolve('hhh')})]) } }
What did you expect to happen?
It should show some errors.
What actually happened?
Nothing errors are shown.
More description
I just import vue and typescript without using vue-cli. And i want using eslint-plugin-vue to lint my vue files which using vue-class-component.
The text was updated successfully, but these errors were encountered: