Requires newline before opening curly brace of all block statements.
Type: Boolean
or Array
Values:
true
always requires newline before curly brace of block statementsArray
specifies block-type keywords after which newlines are required before curly brace['if', 'else', 'try', 'catch', 'finally', 'do', 'while', 'for', 'function', 'switch']
"requireNewlineBeforeBlockStatements": true
function good()
{
var obj =
{
val: true
};
return {
data: obj
};
}
if (cond)
{
foo();
}
for (var e in elements)
{
bar(e);
}
while (cond)
{
foo();
}
function bad(){
var obj = {
val: true
};
return {
data: obj
};
}
if (cond){
foo();
}
for (var e in elements){
bar(e);
}
while (cond){
foo();
}
"requireNewlineBeforeBlockStatements": ["if", "else", "for"]
if (i > 0)
{
positive = true;
}
if (i < 0)
{
negative = true;
}
else
{
negative = false;
}
for (var i = 0, len = myList.length; i < len; ++i)
{
newList.push(myList[i]);
}
// this is fine, since "function" wasn't configured
function myFunc(x) {
return x + 1;
}
if (i < 0) {
negative = true;
}
if (i < 0) {
negative = true;
} else {
negative = false;
}
for (var i = 0, len = myList.length; i < len; ++i) {
newList.push(myList[i]);
}
"requireNewlineBeforeBlockStatements": ["function", "while"]
function myFunc(x)
{
return x + 1;
}
var z = function(x)
{
return x - 1;
}
// this is fine, since "for" wasn't configured
for (var i = 0, len = myList.length; i < len; ++i) {
newList.push(myList[i]);
}
function myFunc(x) {
return x + 1;
}
var z = function(x) {
return x - 1;
}