多个条件的eslint规则

时间:2018-01-12 07:23:47

标签: eslint

是否有针对 if语句的多个条件强制执行换行的eslint规则?

例如,

if (
    foo &&
    bar &&
    baz
) {
  ...
}

1 个答案:

答案 0 :(得分:1)

您最接近强制执行换行符:/*eslint operator-linebreak: ["error", "after"]*/

if (someCondition 
  || otherCondition) {
}

有条件会抛出eslint错误,但这不会:

if (someCondition ||
  otherCondition) {
}

Eslint Prettier plugin可能会帮助您进行格式化,我自己也会使用它。