5

我正在尝试使用 Typescript 配置 eslint 以支持 Java 的多行if缩进标准。

作为记录,Java 标准指定if用于复杂ifs 的多行条件应该缩进两次:

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

似乎没有if特定条件,所以我尝试使用MemberExpression,CallExpressionFunctionExpression类型,但似乎都不起作用:

我的缩小版.eslintrc.json看起来像这样:

{
  "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 */
  }
}

我在控制台上收到以下错误:

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

我在 Typescript 中是否缺少任何用于配置所述ifs 的设置?

4

0 回答 0