eslint-config-typescript icon indicating copy to clipboard operation
eslint-config-typescript copied to clipboard

Why @ vue/typescript, it will error checking my vue script without ts lang

Open Binote opened this issue 4 years ago • 4 comments

When I use js components in a TS project, why check the JS script in a VUE file

编辑器截图

comp.vue

<script>
export default {
// Missing return type on function. eslint(@typescript-eslint/explicit-module-boundary-types)
  data(){}
}
</script>

.eslintrc.js

module.exports = {
    root: true,
    env: {
        node: true,
    },
    "plugins": ["@typescript-eslint"],
    extends: [
        '@vue/typescript/recommended',
    ],
    parserOptions: {
        parser: '@typescript-eslint/parser',
        ecmaVersion: 2020,
    },
};

Binote avatar Nov 16 '20 08:11 Binote

https://github.com/vuejs/vue-eslint-parser/issues/49

koooge avatar Jan 21 '21 22:01 koooge

#49 was closed in #116 but doesn't fix the issue expressed here.

Only

SlyDave avatar Sep 02 '21 13:09 SlyDave

I have the exact same issue. As far as my understanding goes @typescript-eslint/parser should now be used for js and ts to enable type linting. See vuejs/vue-eslint-parser#104.

To differ between the lang tags this config was introduced

{
    "parser": "vue-eslint-parser",
    "parserOptions": {
        "parser": {
            "ts": "@typescript-eslint/parser",
            "js": "espree",
            "<template>": "espree"
        }
    }
}

but now, you should use @typescript-eslint/parser for js and ts and then you could just to parserOptions.parser: '@typescript-eslint/parser'

Darkproduct avatar Oct 19 '21 15:10 Darkproduct

Also related: https://github.com/vuejs/vue-eslint-parser/issues/125#issuecomment-913620026

MatthiasKunnen avatar Nov 03 '21 13:11 MatthiasKunnen