Open rezelute opened 1 year ago
I can confirm, there is a regression between versions 10.0.0 and 11.0.0 that breaks linting many TypeScript lints in *.vue
files. I'm using a vue3/vue-cli with TypeScript.
To answer the question: Yes, @typescript-eslint/no-floating-promises
needs knowledge of types, which needs the TypeScript compiler/parser. Many other lints from @typescript-eslint
do not need that and make do with a JS parser.
How to reproduce (almost minimal example):
vue-cli
with the following .vuerc
preset.package.json
and .eslintrc.js
to the following content..eslintignore
with the following content.@vue/eslint-config-typescript
versions 10.0.0
and 11.0.0
to observe the regression.Content of .vuerc
:
{
"useTaobaoRegistry": false,
"presets": {
"with-regression": {
"useConfigFiles": true,
"plugins": {
"@vue/cli-plugin-typescript": {
"classComponent": false
},
"@vue/cli-plugin-router": {
"historyMode": false
},
"@vue/cli-plugin-eslint": {
"config": "prettier",
"lintOn": [
"save"
]
},
"@vue/cli-plugin-unit-jest": {}
},
"vueVersion": "3",
"cssPreprocessor": "dart-sass"
}
}
}
Content of package.json
:
{
"name": "testproj",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"lint": "vue-cli-service lint"
},
"dependencies": {
"vue": "^3.2.13",
"vue-router": "^4.0.3"
},
"devDependencies": {
"@types/jest": "*",
"@typescript-eslint/eslint-plugin": "*",
"@typescript-eslint/parser": "*",
"@vue/cli-plugin-eslint": "*",
"@vue/cli-plugin-router": "*",
"@vue/cli-plugin-typescript": "*",
"@vue/cli-plugin-unit-jest": "*",
"@vue/cli-service": "*",
"@vue/eslint-config-prettier": "*",
"@vue/eslint-config-typescript": "11.0.0",
"@vue/test-utils": "*",
"@vue/vue3-jest": "*",
"babel-jest": "*",
"eslint": "*",
"eslint-config-prettier": "*",
"eslint-plugin-prettier": "*",
"eslint-plugin-sort-class-members": "*",
"eslint-plugin-vue": "*",
"eslint-plugin-vuejs-accessibility": "*",
"jest": "*",
"prettier": "*",
"sass": "*",
"sass-loader": "*",
"ts-jest": "*",
"typescript": "*"
}
}
Content of .eslintrc.js
:
module.exports = {
env: {
node: true,
},
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/strict",
"plugin:vue/vue3-essential",
"plugin:vue/vue3-recommended",
"plugin:vuejs-accessibility/recommended",
"plugin:prettier/recommended",
"eslint:recommended",
"@vue/prettier",
"@vue/typescript/recommended",
"@vue/eslint-config-typescript/recommended",
],
overrides: [
{
env: {
jest: true,
},
files: [
"**/__tests__/*.{j,t}s?(x)",
"**/tests/unit/**/*.spec.{j,t}s?(x)",
],
},
],
parserOptions: {
ecmaVersion: 2020,
project: ["./tsconfig.json"],
},
plugins: ["sort-class-members", "@typescript-eslint"],
root: true,
rules: {
"@typescript-eslint/strict-boolean-expressions": "warn",
},
};
Content of .eslintignore
:
.eslintrc.js
*.js
Did anyone find a workaround to get @typescript-eslint/no-floating-promises
working with @vue/eslint-config-typescript
?
I tried setting parserOptions.project
but I can't seem to get it working.
any update on that ?
For those who have the same problem.
I managed to solve this issue with the solution presented in this comment: https://github.com/microsoft/vscode-eslint/issues/1537#issuecomment-1281209527
The readme says that we can use any rule in @typescript-eslint/eslint-plugin however when I try using no-floating-promises, I keep getting the following error:
This is what I have in my eslint config file:
I am using vue3/vite with Typescript. Any other rule that I have used in the past for example:
@typescript-eslint/no-unused-vars
or@typescript-eslint/no-explicit-any
seems to work fine. Is there something special abouttypescript-eslint/no-floating-promises
?Thanks!