[英]Eslint: how to force multiline object literals and arrays to have the same indent?
Eg these should be allowed: 例如,应允许这些:
{ a: 1, b: 2, c: 3 };
{
a: 1,
b: 2,
c: 3,
};
{
a: 1, b: 2, c: 3,
};
[
1,
2,
3,
];
These should not be allowed: 这些不应该被允许:
{ a: 1,
b: 2,
c: 3,
};
{
a: 1, b: 2,
c: 3,
};
I added "object-property-newline": [2, { allowAllPropertiesOnSameLine: true }],
, but it's still allowing the 2 examples. 我添加了
"object-property-newline": [2, { allowAllPropertiesOnSameLine: true }],
,,但仍然允许这两个示例。 I also tried several key-spacing
options but it doesn't do what I want. 我也尝试了几种
key-spacing
选项,但它并不能满足我的要求。 How do I disallow the last 2 examples? 我如何不允许最后两个示例?
The first example is covered by another rule object-curly-newline
: 第一个示例由另一个规则
object-curly-newline
覆盖:
/* eslint object-curly-newline: 2 */
let foo = { a: 1,
b: 2,
c: 3,
};
// Unexpected line break before this closing brace. (object-curly-newline)
The second example works on my computer. 第二个示例在我的计算机上工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.