How to enforce multiline "if" condition indentation in Typescript using eslint?

Viewed 507

I am trying to configure eslint with Typescript to support Java's standard for multiline if indentation.

For the record, the Java standard specifies that a multiline if condition, used for complex ifs, is supposed to be indented twice:

if (
        a >= MIN && a <= MAX ||
        b >= MIN && b <= MAX
) {
    alert("Either value is out of range");
}

There doesn't seem to be if-specific condition, so I've tried to using the MemberExpression, CallExpression and FunctionExpression types but neither seems to work:

A reduced version of my .eslintrc.json looks like this:

{
  "extends": [
    "eslint:recommended",
    "plugin:@typescript-eslint/recommended"
  ],
  "env": {
    "browser": true,
    "mocha": true
  },
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 2015,
    "sourceType": "module",
    "project": "tsconfig.json"
  },
  "plugins": [
    "@typescript-eslint/eslint-plugin"
  ],
  "rules": {
        /* here goes more rules */
    "@typescript-eslint/indent": ["warn", "tab", { "MemberExpression": 2, "CallExpression": {"arguments": 2}, "SwitchCase": 1, "FunctionExpression": {"body": 1, "parameters": 2} }]
        /* more rules here too */
  }
}

I am getting the following error on the console:

256:1 warning Expected indentation of 3 tabs but found 4 @typescript-eslint/indent

Is there any setting I'm missing in Typescript for configuring said ifs?

0 Answers
Related