I have the following code snippet, where eslint indent lints my multiline ternary expression:
This is the error I am getting:
Expected indentation of 8 spaces but found 16. eslint(indent)
So eslint expects 2 spaces per indent, even though I specified that there should be 4. I had the same issue with Switch Case before, but that problem was easily solved by editing the .eslintrc.json
. This time, I could not find a fix like that.
My .eslintrc.json
:
{
"env": { "browser": true, "node": true },
"plugins": ["@typescript-eslint"],
"parser": "@typescript-eslint/parser",
"parserOptions": { "ecmaVersion": 2020 },
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
"rules": {
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/member-ordering": "error",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-use-before-define": ["error", { "functions": false }],
"@typescript-eslint/no-var-requires": "off",
"indent": ["error", 4, {"SwitchCase": 1}],
"prettier/prettier": ["error", { "endOfLine": "auto" }]
}
}
I would like to know how to fix this linting error.