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

Not detecting issues in template of a custom object component

Open taobojlen opened this issue 3 years ago • 0 comments

If I create two identical Vue components, one in a .vue file and one in a .js file annotated with the @vue/component comment, I get different results. Issues in the template of the .js file are missed.

Checklist

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

Tell us about your environment

  • ESLint version: 7.22.0
  • eslint-plugin-vue version: 7.7.0
  • Node version: 15.5.1
  • Operating System: Mac OS 11.2.3

Please show your full configuration:

{
    "env": {
        "browser": true,
        "es2021": true
    },
    "extends": [
        "plugin:vue/essential"
    ],
    "parserOptions": {
        "ecmaVersion": 12,
        "sourceType": "module"
    },
    "plugins": [
        "vue"
    ],
    "rules": {
    }
}

What did you do?

component.vue

<template>
  <div class="one" class="two"  />
</template>

<script>
export default {
  computed: {
    testFunction() {
      if (1 === 2) {
        return "abc"
      }
    }
  }
}
</script>

component.js

// @vue/component
const MyComponent = {
  template: `<div class="one" class="two" />`,
  computed: {
    testFunction() {
      if (1 === 2) {
        return "abc"
      }
    }
  }
}

What did you expect to happen? eslint-plugin-vue finds the same issues in the .js file and the single-file component.

What actually happened?

/Users/tao/dev/vue-eslint-demo/src/component.js
  5:17  error  Expected to return a value in "testFunction" computed property  vue/return-in-computed-property

/Users/tao/dev/vue-eslint-demo/src/component.vue
  2:20  error  Parsing error: duplicate-attribute                              vue/no-parsing-error
  2:20  error  Duplicate attribute 'class'                                     vue/no-duplicate-attributes
  8:17  error  Expected to return a value in "testFunction" computed property  vue/return-in-computed-property

Repository to reproduce this issue

https://github.com/taobojlen/vue-eslint-demo

taobojlen avatar Mar 18 '21 18:03 taobojlen