【发布时间】:2021-08-28 02:39:23
【问题描述】:
我有一个带有 ESLint 和更漂亮配置的 vue 项目,如下所示:
"@typescript-eslint/eslint-plugin": "^4.26.1",
"@typescript-eslint/parser": "^4.26.1",
"@vue/eslint-config-prettier": "^6.0.0",
"@vue/eslint-config-typescript": "^7.0.0",
"eslint": "^7.28.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-vue": "^7.9.0",
"prettier": "^2.3.1",
所有的包都应该是最新的。
我在 VSCode 和控制台中收到此错误,我想抑制它,因为我希望允许这样的括号以便更好地阅读:
据我所知,这就是 no-extra-parens 规则的用途,但我无法让它发挥作用。 文档 (https://eslint.org/docs/rules/no-extra-parens) 声明它有一个对象选项,该选项对此规则进行了多次调整。例如,如果我尝试以下任何选项:
"no-extra-parens": "0",
或
"no-extra-parens" :{
"returnAssign": false,
"nestedBinaryExpressions": false,
"ignoreJSX": "none|all|multi-line|single-line",
"enforceForArrowConditionals": false,
"enforceForSequenceExpressions": false,
"enforceForNewInMemberExpressions": false,
"enforceForFunctionPrototypeMethods": false
},
... VSCode 中的错误消失了,一切似乎都运行良好。但是在服务控制台时会抛出这个错误:
我试过了
"no-extra-parens": 0,
正如控制台所说,但随后规则被忽略并显示第一个规则破坏错误。
我尝试使用数组和对象以多种不同的方式定义规则,将其设置为“关闭”等。但是规则在 VSCode 中不起作用,或者控制台指出规则定义无效.
这是我的 .eslintrc.js 文件:
module.exports = {
root: true,
env: {
node: true
},
extends: [
"plugin:vue/essential",
"eslint:recommended",
"@vue/typescript/recommended",
"@vue/prettier",
"@vue/prettier/@typescript-eslint"
],
parserOptions: {
ecmaVersion: 2020,
ecmaFeatures: {
"jsx": false
},
},
rules: {
"no-extra-parens": 0,
"no-console": ["warn", { allow: ["warn", "error"] }],
"no-debugger": "warn",
"curly": "error",
"quotes": [
"error",
"single"
],
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-use-before-define" : "off",
"@typescript-eslint/consistent-type-assertions" : "off",
"@typescript-eslint/no-empty-function": "warn",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-var-requires" : "off",
"@typescript-eslint/no-extra-parens": ["error"]
}
};
有什么线索吗? ????
【问题讨论】:
标签: vue.js visual-studio-code eslint prettier