I have my eslinting rules as follows
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',
],
}
When I open a new file that is not properly formatted to tabs, I get:
Fair enough, so I change indentation to tabs using VScode and now I get:
???
I have my settings configured so that all the extensions read from just one eslintrc file in the project root...
As you didn't posted your hole .eslintrc.js
config i can only assume that you have extends to a few off the recommended rule sets which leads to your unwanted behavior that multiple rules are running...
Depending on which one of these two rules you want you can just simply deactivate the other one by adding this to you rules eg.:
"@typescript-eslint/indent": "off"
This will deactivate the @typescript-eslint/indent
rule for your project.
My preferred solution was to disable the base indent
rule and configure an overriding @typescript-eslint/indent
rule as suggested here: https://github.com/typescript-eslint/typescript-eslint/blob/87b7dbbc8d25d059e34888ec28026bfb4ade2215/packages/eslint-plugin/docs/rules/indent.md
"rules": {
"indent": "off",
"@typescript-eslint/indent": ["error", 2]
}
I found disabling the @typescript-eslint/indent
rule in favour of the base indent
rule simply hid the errors in the code editor, while still causing compilation to fail!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.