[英]How do you resolve conflicting linting rules in VSCode between eslint and typescript-eslint
我的 eslinting 规则如下
module.exports = {
env: {
es6: true,
node: true,
mocha: true
},
extends: [
"standard-with-typescript"
],
parser: '@typescript-eslint/parser',
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
project: "./tsconfig.json"
},
rules: {
"quotes": ["warn", "single"],
"indent": ["warn", "tab", { "ignoreComments": true }],
"no-tabs": 0,
"padded-blocks": 0,
"semi": 0,
"no-trailing-spaces": 0,
"spaced-comment": 0,
"no-multiple-empty-lines": 0,
"space-before-function-paren": 0,
"camelcase": 0,
"prefer-const": "warn",
"space-infix-ops": "warn",
"@typescript-eslint/strict-boolean-expressions": ["warn", {"allowNullable": true}]
},
plugins: [
'@typescript-eslint',
],
}
当我打开一个没有正确格式化为标签的新文件时,我得到:
很公平,所以我使用 VScode 将缩进更改为制表符,现在我得到:
???
我配置了我的设置,以便所有扩展名都只从项目根目录中的一个 eslintrc 文件中读取...
由于您没有发布您的漏洞.eslintrc.js
配置,我只能假设您.eslintrc.js
一些推荐的规则集,这会导致您不想要的行为,即多个规则正在运行......
根据您想要的这两个规则中的哪一个,您可以通过将其添加到您的规则中来简单地停用另一个规则,例如:
"@typescript-eslint/indent": "off"
这将为您的项目停用@typescript-eslint/indent
规则。
我的首选解决方案是禁用基本indent
规则并按照此处的建议配置覆盖@typescript-eslint/indent
规则: https : //github.com/typescript-eslint/typescript-eslint/blob/87b7dbbc8d25d059e34888ec28026bfb4ade2215/packages/eslint /docs/rules/indent.md
"rules": {
"indent": "off",
"@typescript-eslint/indent": ["error", 2]
}
我发现禁用@typescript-eslint/indent
规则而支持基本indent
规则只会隐藏代码编辑器中的错误,同时仍然导致编译失败!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.