disallowPaddingNewlinesInBlocks

Disallows blocks from beginning or ending with 2 newlines.

Type: Boolean or Object

Values:

  • true validates all non-empty blocks.
  • Object:
    • '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

"disallowPaddingNewlinesInBlocks": true
"disallowPaddingNewlinesInBlocks": { "open": true, "close": false }
"disallowPaddingNewlinesInBlocks": { "allExcept": [ "conditionals" ] }
"disallowPaddingNewlinesInBlocks": { "open": true, "close": false, allExcept: ['conditionals'] }
Valid for true
if (true) {
    doSomething();
}
if (true) {doSomething();}
var abc = function() {};
Valid for mode { "open": true, "close": false }
if (true) {
    doSomething();

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

    doSomething();

}

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

}

if (true) {

    doSomething();

}
Invalid
if (true) {

    doSomething();

}
Rule source
Test source