operator-linebreak
为操作员强制执行一致的换行样式
一些该规则报告的问题可以通过 --fix 命令行选项 自动修复
当一条语句太长而不能放在一行中时,通常会在分隔表达式的运算符旁边插入换行符。想到的第一个样式是将运算符放在行尾,遵循英语标点规则。
var fullHeight = borderTop +
innerHeight +
borderBottom;
一些开发人员发现将运算符放在行首会使代码更具可读性。
var fullHeight = borderTop
+ innerHeight
+ borderBottom;
规则详情
此规则为运算符强制执行一致的换行样式。
选项
vh3Y4E2L3RScPKP9nmts5s8qsvokoJzzK45zyzFfEeasqNDiFms2C3CcqTbbGJt8/gwJN/P8BQhGOpzK9o4he9/T/eTRDrOJR8VocVmf5/E=
9En+/ReRbNYzXEda1PwNnCcuRFPnhId3lIC9Gqx4aWU=
- 05VHUybY3v++Bnl5LzrVpQo7fHObSeC+97AAjgCr47pzsxreWb5m7cr8DK3w7b87QmqXCD68g3/qp8VfSCkKUQulF3tqytevSZTxkdQt+q3ToZaTt+vUukHWpgQmt3upoydyjMnV4j2lYS2LqOQfdsyPjWw0A1f975JXCV19M9hzYgT3grMvgQr2/SODfPHXO/lVxaXL6sYuctYiT4KsNzTw3sqwO2tDIAgbFNdvn18MEgIBfEc1kgflHX5ZpsuLMwvemPsvoBqEVOjMKNxutuVboO+eMvX/xoQ15Usnprk=
hyLF8um9EO4VhXjzQok1yg==
- j4jM6J+N5QRuoauObEQlvWnWuoTL/6NnQUfXsJutR/747UP0V+dUvoIHTqTK40YtDpP33ZHGtJW0cXT+FU6zIJFyzdzqCrqqoSX3zNpb2UI=
+gmDLUGiZvk9UVcPKUSv+mcIzx+vR+VLvjXvC8SzdxjQ/Suw9NGVGR3mizQRteSHjfwDD9eF6bgAsqLJmZ26iLlYmpz0xyPbNA1JN4nvq40Vos/7LxtW1ooTNiKg/Yqd
after
1tb+eDg9lr3kv3DONP/OObSuk6aZO9aEjdXhGxbbjPquKIrLUlIkl6oBreRCXkHNc9lXbYtFY2cFhZepkCoihWP0D92XRHRy7WgBaMzlnl8=
/*eslint operator-linebreak: ["error", "after"]*/
foo = 1
+
2;
foo = 1
+ 2;
foo
= 5;
if (someCondition
|| otherCondition) {
}
answer = everything
? 42
: foo;
class Foo {
a
= 1;
[b]
= 2;
[c
]
= 3;
}
1tb+eDg9lr3kv3DONP/OObSuk6aZO9aEjdXhGxbbjPoHGJTP1fCxabHyy5I+ND7kPnAkNU6tlDG6VcoJ4xbEoBPP3C8dW4x4/qyFKkuOamg=
/*eslint operator-linebreak: ["error", "after"]*/
foo = 1 + 2;
foo = 1 +
2;
foo =
5;
if (someCondition ||
otherCondition) {
}
answer = everything ?
42 :
foo;
class Foo {
a =
1;
[b] =
2;
[c
] =
3;
d = 4;
}
before
1tb+eDg9lr3kv3DONP/OOQ9YvX9pDbGr05sVsXRFUSFVTISzomhonHczbYZjrHyfH4IISBLqX3gFsppwSAf2znn+savL8up+IV9w5+kHCRg=
/*eslint operator-linebreak: ["error", "before"]*/
foo = 1 +
2;
foo =
5;
if (someCondition ||
otherCondition) {
}
answer = everything ?
42 :
foo;
class Foo {
a =
1;
[b] =
2;
[c
] =
3;
}
1tb+eDg9lr3kv3DONP/OOQ9YvX9pDbGr05sVsXRFUSHU25O5HmsOq+q78PIU1fpxP0z1bt7/ZbiSS471WP1mmh1X9F7yWOf5CFNLwlPDqfk=
/*eslint operator-linebreak: ["error", "before"]*/
foo = 1 + 2;
foo = 1
+ 2;
foo
= 5;
if (someCondition
|| otherCondition) {
}
answer = everything
? 42
: foo;
class Foo {
a
= 1;
[b]
= 2;
[c
]
= 3;
d = 4;
}
none
1tb+eDg9lr3kv3DONP/OOd3shW4oET76epOWpPS3cItvHyAheA0V/p3GkmpPsfw6yTr3p+PGZdnn8mrx9joaw25nNghiESl/HigbxTnsvfo=
/*eslint operator-linebreak: ["error", "none"]*/
foo = 1 +
2;
foo = 1
+ 2;
if (someCondition ||
otherCondition) {
}
if (someCondition
|| otherCondition) {
}
answer = everything
? 42
: foo;
answer = everything ?
42 :
foo;
class Foo {
a =
1;
[b] =
2;
[c
] =
3;
d
= 4;
[e]
= 5;
[f
]
= 6;
}
1tb+eDg9lr3kv3DONP/OOd3shW4oET76epOWpPS3cItzIPIcwZLZ7IGEdiB0hre2ybcb3blsrawvxn+M/AIqSNiJJPp/Na4TVqKbVaXZKpo=
/*eslint operator-linebreak: ["error", "none"]*/
foo = 1 + 2;
foo = 5;
if (someCondition || otherCondition) {
}
answer = everything ? 42 : foo;
class Foo {
a = 1;
[b] = 2;
[c
] = 3;
d = 4;
[e] = 5;
[f
] = 6;
}
overrides
F23nqTp9hb4Vd8m/iEN1DG1OUvL/sDCYcdhTK2/XB7dnmqOeB+a4Uheq1okufRkKSHIYw8Ki+EF4nsuMt3pJK5vQL9jyGXhang+EwMWi7DQN1qsCRPDRidIM1C7EMa7kuDTqycmIT+TO+qNDqVahLA==
/*eslint operator-linebreak: ["error", "after", { "overrides": { "+=": "before" } }]*/
var thing = 'thing';
thing +=
's';
1tb+eDg9lr3kv3DONP/OOX9atnnBsyAudPAesCzPu6TMBZMwtHFiwEGERbpaYNLoQEmYjgIwdoHDu+KbQ/paaCEoCmffOhoeLeJuT39m+rUsE1aQKtNtutun6z054QOfG8bAbP+lLS+v5wghsnmfAg==
/*eslint operator-linebreak: ["error", "after", { "overrides": { "+=": "before" } }]*/
var thing = 'thing';
thing
+= 's';
1tb+eDg9lr3kv3DONP/OOX9atnnBsyAudPAesCzPu6TvBWs/5i3TL8e6pVvlPdfwpXEAhq6uasQzwRM2yNKSKq9rpLhMYtJNbAb/rCp51VAro6UXud2Erh4zNwJ/TLs5kCOaoVB/1zjbHVuJPp3jSBvCIPkM8nOAWpDiFq2uRYY=
/*eslint operator-linebreak: ["error", "after", { "overrides": { "?": "ignore", ":": "ignore" } }]*/
answer = everything ?
42
: foo;
answer = everything
?
42
:
foo;
L+G0pIYY6HS+68htOSqeL28y5hlfvDHE/jKyKCbX4Xm3LVCxMscjJXuz6VEqwtZwDrscvXnLy1FmbaaSvhl11PnNrUjZQmoFHm380WAHfs1bA5MbzJlCRSZvVyfjeaB5vg4ndcCLlVqwueHcbfi3Zl93EiCxsCiSWBfGcsA1Vaw=
/*eslint operator-linebreak: ["error", "after", { "overrides": { "?": "before", ":": "before" } }]*/
foo = 1
+
2;
foo = 1
+ 2;
foo
= 5;
if (someCondition
|| otherCondition) {
}
answer = everything ?
42 :
foo;
L+G0pIYY6HS+68htOSqeL28y5hlfvDHE/jKyKCbX4Xm3LVCxMscjJXuz6VEqwtZwDrscvXnLy1FmbaaSvhl11PnNrUjZQmoFHm380WAHfs1bA5MbzJlCRSZvVyfjeaB5w4W6LbxjdI6K7HGQtyrh7+xi5wt5wBEe6Q4QS/eQHic=
/*eslint operator-linebreak: ["error", "after", { "overrides": { "?": "before", ":": "before" } }]*/
foo = 1 + 2;
foo = 1 +
2;
foo =
5;
if (someCondition ||
otherCondition) {
}
answer = everything
? 42
: foo;
何时不使用
bXwn3C5b/3ZiP/zBB3b+PXbSEPJc08JvjNeyb0kQ1uMbkxRrZW2V5kefF3e7KYzlxQ3WUp1RKWUWIKpfuhEwdE5YepPZKB2U8dXboSuD+pHj47O1b8fbSM+QeSRNVE/2