我正在尝试使用 Typescript 配置 eslint 以支持 Java 的多行if
缩进标准。
作为记录,Java 标准指定if
用于复杂if
s 的多行条件应该缩进两次:
if (
a >= MIN && a <= MAX ||
b >= MIN && b <= MAX
) {
alert("Either value is out of range");
}
似乎没有if
特定条件,所以我尝试使用MemberExpression
,CallExpression
和FunctionExpression
类型,但似乎都不起作用:
我的缩小版.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 中是否缺少任何用于配置所述if
s 的设置?