requirePaddingNewlinesInBlocks

Requires blocks to begin and end with 2 newlines

Types: Boolean, Integer, Object

Values:

  • true validates all non-empty blocks
  • Integer specifies a minimum number of lines containing elements in the block before validating
  • Object (at least one of properties must be true):
    • 'open'
      • true validates that there is a newline after the opening brace in a block
      • false ignores the newline validation after the opening brace in a block
    • 'close'
      • true validates that there is a newline before the closing brace in a block
      • false ignores the newline validation before the closing brace in a block
    • 'allExcept' array of exceptions:
      • 'conditionals' ignores conditional (if, else if, else) blocks
      • 'functions' ignores function blocks

Example

"requirePaddingNewlinesInBlocks": true
"requirePaddingNewlinesInBlocks": 1
"requirePaddingNewlinesInBlocks": { "open": true, "close": false }
"requirePaddingNewlinesInBlocks": { "allExcept": [ "conditionals" ] }
"requirePaddingNewlinesInBlocks": { "open": true, "close": false, allExcept: ['conditionals'] }
Valid for mode true or { "open": true, "close": true }
if (true) {

    doSomething();

}
var abc = function() {};
Invalid
if (true) {doSomething();}
if (true) {
    doSomething();
}
Valid for mode 1
if (true) {

    doSomething();
    doSomethingElse();

}
if (true) {
    doSomething();
}
if (true) { doSomething(); }
var abc = function() {};
Invalid
if (true) { doSomething(); doSomethingElse(); }
if (true) {
    doSomething();
    doSomethingElse();
}
Valid for mode { "open": true, "close": false }
if (true) {

    doSomething();
}
var abc = function() {};
Invalid
if (true) {doSomething();}
if (true) {
    doSomething();
}
if (true) {
    doSomething();

}
Valid for { allExcept: ['conditionals'] }
if (true) {
    doSomething();
}

function (foo) {

    return bar;

}
Invalid
function (foo) {
    return bar;
}
Valid for { "open": true, "close": false, allExcept: ['conditionals'] }
function (foo) {

    return bar;
}

if (true) {
    doSomething();
}
Invalid
function (foo) {
    return bar;

}
Rule source
Test source