随着TSLint被弃用,我正在将项目转换为使用ESLint。
我想设置我的缩进规则来允许这样做:
type HtmlColor = 'attrib' | 'background' | 'bg_whitespace' | 'comment' | 'entity' | 'error' | 'foreground' |
'invalid' | 'markup' | 'tag' | 'value' | 'warning' | 'whitespace';
我目前收到一个关于第二行缩进的错误,它应该是0个空格而不是17个。我可能以为这个错误会抱怨它不是2个空格,但肯定不是0。
无论如何,如果我不能得到我想要识别的特定缩进,在这种情况下,我至少希望忽略缩进。
我试着用
ignoredNodes
ESLint的选项
indent
规则如下:
"@typescript-eslint/indent": [
"error",
2,
{
"ArrayExpression": "first",
"FunctionDeclaration": { parameters: "first" },
"ignoredNodes": [
"ArrowFunction > Block",
"NoSubstitutionTemplateLiteral",
"TemplateLiteral",
"TypeAliasDeclaration *"
],
"ObjectExpression": "first",
"VariableDeclarator": "first",
"SwitchCase": 1
}
],
我看得出来
零件
的
忽略节点
列表正在按我的预期工作,例如
"TemplateLiteral"
部分,但我无法找出正确的AST语法来处理
type
声明和其他类似箭头函数的东西。
我用过
AST Explorer
以帮助弄清楚AST选择器应该是什么,但到目前为止还没有成功。