JSHint - 括号缩进

JSHint - Indent to bracket

我将 JSHint 配置为验证代码中的缩进。这是规则 indent: 4

这条规则警告我有缩进括号的地方。我该如何解决这个问题?

这是我指的代码

slug            :   {
                        type: String,
                        required: true,
                        unique: true
                    }

这是错误:

[L12:C29] W015: Expected 'type' to have an indentation at 9 instead at 29.

你能帮忙吗?

jshint 的缩进对于捕获语法错误类型错误很有用

if (foo)
bar();

此处,bar仅在foo为真时执行。要修复上面的错误, 你希望第二行只缩进 4 个字符(见下文)。如果您的风格更倾向于将键/冒号与其他属性对齐,您也可以使用 indent:false 禁用此功能。

slug : {
    type: String,
    required: true,
    unique: true
}