Skip to content
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

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

Open
Binote opened this issue Nov 16, 2020 · 4 comments
Open

Comments

@Binote
Copy link

Binote commented Nov 16, 2020

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,
    },
};
@koooge
Copy link
Contributor

koooge commented Jan 21, 2021

@SlyDave
Copy link

SlyDave commented Sep 2, 2021

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

Only <script lang="ts"> should be parsed with the typescript-eslint/parser in a Vue SingleFileComponent (*.vue file)

@Darkproduct
Copy link

Darkproduct commented Oct 19, 2021

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'

@MatthiasKunnen
Copy link

Also related: vuejs/vue-eslint-parser#125 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants