运行linter命令时,以下配置有效。 但是,当我运行我的react dev服务器时,它会编译并显示警告-“ @ typescript-eslint / no-unused-vars”。
如何删除警告?
这是我的 .eslintrc.js 配置。
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
ecmaFeatures: {
jsx: true
}
},
settings: {
react: {
version: "detect"
}
},
extends: [
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
],
rules: {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off"
}
};
答案 0 :(得分:-1)
您需要先禁用no-unused-vars
,如in the docs所述。
{
// note you must disable the base rule as it can report incorrect errors
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error"]
}
答案 1 :(得分:-2)
尝试将"@typescript-eslint/no-unused-vars": "off"
替换为"@typescript-eslint/no-unused-vars": 0,