I need to add eslint rule for the following case:
// bad
[
'onClickSave',
'onClickCancel'].forEach(bind(this));
// good
[
'onClickSave',
'onClickCancel'
].forEach(bind(this));
When defining an object or array with multiple lines, brackets must be on a new line.
Is there such rule in eslint or how could I accomplish it?
As far as I know there are no eslint rules for that. But there are proposals for array-bracket-newline
and array-element-newline
.
If you want to try JSCS, it already has a rule validateNewlineAfterArrayElements
which can be configured as below:
"validateNewlineAfterArrayElements": {
"maximum": 1
}
ie, if you have more than one element in the array, each should be on a new line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With