array-bracket-newline
在打开数组括号之后和关闭数组括号之前强制换行
一些该规则报告的问题可以通过 --fix 命令行选项 自动修复
许多样式指南要求或不允许在数组括号内换行。
规则详情
此规则在打开数组括号之后和关闭数组括号之前强制换行。
选项
此规则有一个字符串选项:
- QWqMp2YEiEN2EoNjBDcBL2Nat5/GrhD9Zsm90x/jqdqsdSjSHrU+kKSi6b3+L3xiPFz3geQ6lYTIRvCMOmbPd3YWhzhIIFKgTB6AQRatoyXvNzZj5gDJ0vMw5bdd0kweeGna3x+QWFNTE86yqS7rJ+VcLa8gaiIG8KJhsi9uCXSe6sGL/a0bMG+HnNLmTXL7vVzvulOBhrj5oCY6JtXxWOIDfda2+6nGH3VuA70Wir2fh6OvQwRP79JE6Wzgr9wUVHedIroxCFQTUKDNr9dGclivT6lcbdXh4cZaz8XNfQ0rylH3k6mgLUOuttyfFAB6lhDV3z/33xD7gkau0352FrP+Ln1rv/zv4HFV21nYG9hRkcxSlSITmwQuz4MQVtCW7GKs3vUSOOWQPgRAX07iHw==
XOM+GeqxQe13NTP+xWEbO6n+zartN6sl991f0aJT5BNbT0W9tm9AeqmI9TH0H+MEx49fVPg5EdYXARBV5odM5Lm+m9Jui0M5ZYTTOwdTBgkXgVuHWkhmUvtDY3jMQxgNTXQww3B7DF/A8cRf1r00qA==
- elGcz8r1agsvLCAJNB7ZdVP4Tk60F0Gfc1cXgb41FAaNNhiO6gJ0CQyx010j9zkfgFbzd8NjLvdsMmTG3VCZ1zvq+/zCip7A7olj5iWtUTpgEokMkWn2j9/MDdQHuq53kFUG6ev+9eHE+1FfBzJk9FUDrNSED85mpbIUOyPB07MaCggbX/pkstZa/nLPJU1n3AaqQmk/PM9KmjJZ8WnjbKEFtRt0aK/mZ3IQA/83LmUD3w1T4QhPy24LE5brImvO/LuRBfXZ4uzxZqiCj1f6K8HOzkZ7qD6qzCChRQResjhScNmtDPUtK3u5KcLYD3cJbj4ns8mr2sCi8Spez3xgOU/CJUBt816reaK9PvAPQ6Ky/xkz9nYgCJJITpt3Nj7A+qivdI9J8uJA/DLmIDF24WgpbIoRjXgjeFQd8ZlMBRSvOPCHkvaZInPV4t5qDv5xXcweh2fx5RJLijKHGcsnihIUEQ55yqwBO6RBm4X2n2SD39Rcon+vpW/x61NXOx0ajduKG3h7mafMzLLa9gTt8NAPTi+P/cLrYiKPaYZicdW/0IHnyMH5RgWYyPG6qUjm
always
7xDYtjDnSQq8pZ502SNO6rUSXeAhG44JRQMyC8lfzF0rjfjztQFoqRNg761ca1W+vlYb9H9qSbjE2cjizhSJ8pDt3WkRXtZ+R2AnNkF38Sk=
/*eslint array-bracket-newline: ["error", "always"]*/
var a = [];
var b = [1];
var c = [1, 2];
var d = [1,
2];
var e = [function foo() {
dosomething();
}];
7xDYtjDnSQq8pZ502SNO6rUSXeAhG44JRQMyC8lfzF2qx+Cin4ZY4h7DD32Zaey9Snt1xBtRxEQZKtjKUCFK3BFFC+UO088o8zdUEeFG7VA=
/*eslint array-bracket-newline: ["error", "always"]*/
var a = [
];
var b = [
1
];
var c = [
1, 2
];
var d = [
1,
2
];
var e = [
function foo() {
dosomething();
}
];
never
7xDYtjDnSQq8pZ502SNO6iSbSSgf88JvINV+VW/7mjjjFiN9kgk1SZeCsyIjd2Dk8k6MmZcA+2HbZXyreFXjTqy/sqwbdiiEliJLfZHfH0U=
/*eslint array-bracket-newline: ["error", "never"]*/
var a = [
];
var b = [
1
];
var c = [
1, 2
];
var d = [
1,
2
];
var e = [
function foo() {
dosomething();
}
];
7xDYtjDnSQq8pZ502SNO6iSbSSgf88JvINV+VW/7mjglYsFdA9pWHwqRpV9joLGkNKHwlcyw6ZkK4XHAI0leF18G96W/FEOjyH7wSDDTYP0=
/*eslint array-bracket-newline: ["error", "never"]*/
var a = [];
var b = [1];
var c = [1, 2];
var d = [1,
2];
var e = [function foo() {
dosomething();
}];
consistent
7xDYtjDnSQq8pZ502SNO6hPXG5S4UaAf7yMtpTDvFZWh1IjNfv1evYKh2riEOrOakKdyN4Gp9PC4rrftIMXJnuk+R67+T3/t6AU/HFU3saE=
/*eslint array-bracket-newline: ["error", "consistent"]*/
var a = [1
];
var b = [
1];
var c = [function foo() {
dosomething();
}
]
var d = [
function foo() {
dosomething();
}]
7xDYtjDnSQq8pZ502SNO6hPXG5S4UaAf7yMtpTDvFZWh1IjNfv1evYKh2riEOrOaMwwu/R9NRy0mzN1n5FZVDPUdKLjr/jqZeme7/TUp8jU=
/*eslint array-bracket-newline: ["error", "consistent"]*/
var a = [];
var b = [
];
var c = [1];
var d = [
1
];
var e = [function foo() {
dosomething();
}];
var f = [
function foo() {
dosomething();
}
];
multiline
6OjE+A1hvEglXN51x/s/8pxWUZWFQraLfNUblnh+TDGwPMSWkQVh0uMNWDAg0wMGgMQWk5y6HEbpjouDqCgovatKR6G89pEouHjkn+6iOFoL9BxnXVst8kAH/QTgJUaZ
/*eslint array-bracket-newline: ["error", { "multiline": true }]*/
var a = [
];
var b = [
1
];
var c = [
1, 2
];
var d = [1,
2];
var e = [function foo() {
dosomething();
}];
6OjE+A1hvEglXN51x/s/8pxWUZWFQraLfNUblnh+TDGwPMSWkQVh0uMNWDAg0wMGgMQWk5y6HEbpjouDqCgovawMQHbezHT1d5J0wvAfA8mX8zKAnDHwPc1wZPstdCR+
/*eslint array-bracket-newline: ["error", { "multiline": true }]*/
var a = [];
var b = [1];
var c = [1, 2];
var d = [
1,
2
];
var e = [
function foo() {
dosomething();
}
];
minItems
7xDYtjDnSQq8pZ502SNO6pHfQo8T+okXgCrw2rRqzOXInrOrWlQ0y1yYhAeb3fHYADmoJ4gn1TRddrIa5/0cRLkVaWBT6/QZiv5p2xq6fUA=
/*eslint array-bracket-newline: ["error", { "minItems": 2 }]*/
var a = [
];
var b = [
1
];
var c = [1, 2];
var d = [1,
2];
var e = [
function foo() {
dosomething();
}
];
7xDYtjDnSQq8pZ502SNO6pHfQo8T+okXgCrw2rRqzOXInrOrWlQ0y1yYhAeb3fHY7qiwZhWTssxrDgdg2DhrOjJE5UQXW90AttTw7EKEhOw=
/*eslint array-bracket-newline: ["error", { "minItems": 2 }]*/
var a = [];
var b = [1];
var c = [
1, 2
];
var d = [
1,
2
];
var e = [function foo() {
dosomething();
}];
multiline 和 minItems
7xDYtjDnSQq8pZ502SNO6q7Z0ywh8gBbeKcXOWsg0k7znIrfds9DuI75Pr8VP+kMyBkx1obKOMpl81ql90s/H5DYC4+Sin+Er1PLtqyLg2RqfvN1SZVMrCb6HvSf6CQYXPI5zesSkkOEUWYhe8opiw==
/*eslint array-bracket-newline: ["error", { "multiline": true, "minItems": 2 }]*/
var a = [
];
var b = [
1
];
var c = [1, 2];
var d = [1,
2];
var e = [function foo() {
dosomething();
}];
7xDYtjDnSQq8pZ502SNO6q7Z0ywh8gBbeKcXOWsg0k7znIrfds9DuI75Pr8VP+kMyBkx1obKOMpl81ql90s/H261LSjtdkeb57D/snw5cmr/E7PdyH9PBu0UMNB44KaPYPi+Vwp837GmbndXb8bI8w==
/*eslint array-bracket-newline: ["error", { "multiline": true, "minItems": 2 }]*/
var a = [];
var b = [1];
var c = [
1, 2
];
var d = [
1,
2
];
var e = [
function foo() {
dosomething();
}
];
何时不使用
LlvfTlGNiqWwT39ynjGQIQjlZXvV44RgOH37gOYKP3ioifNECd636tgT0i2FbBBR2TGPc+3+nmYU5CXClX3cV/TXSHMDkT+pvNb2byo6QgnTG1Ozj4A/ufP3YwbDxfnn
兼容性
- V0QOsqqMGL+OBNItGtHgQEyNadtujPpY1/jdNqdyB12LanuFtv/lqSdhZfx9n6OvujUsCvv7cq7M8cHRWek7lFxCkZNxOEgs7dS+84q2e4kTlC+2UUHtbVUBIWxqzBMXnYyGrZ01dTIT7MlSuBKXp++q1knICSAjh2SEdNnBwn8=