eslint-config-typescript
eslint-config-typescript copied to clipboard
Why @ vue/typescript, it will error checking my vue script without ts lang
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,
},
};
https://github.com/vuejs/vue-eslint-parser/issues/49
#49 was closed in #116 but doesn't fix the issue expressed here.
Only
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'
Also related: https://github.com/vuejs/vue-eslint-parser/issues/125#issuecomment-913620026