requireBlocksOnNewline

Requires blocks to begin and end with a newline

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:
    • 'includeComments'
      • true includes comments as part of the validation
    • 'minLines'
      • Integer specifies a minimum number of lines containing elements in the block before validating

Examples

"requireBlocksOnNewline": true
"requireBlocksOnNewline": 1
"requireBlocksOnNewline": {
     "includeComments": true
}
"requireBlocksOnNewline": {
     "includeComments": true,
     "minLines": 1
}
Valid for mode true
if (true) {
    doSomething();
}
var abc = function() {};
// or
if (true) { //comments
    doSomething();
}
var abc = function() {};
// or
if (true) {
    doSomething();
/** comments */
}
var abc = function() {};
Invalid
if (true) {doSomething();}
Valid for mode 1
if (true) {
    doSomething();
    doSomethingElse();
}
if (true) { doSomething(); }
var abc = function() {};
// or
if (true) { //comments
    doSomething();
    doSomethingElse();
}
if (true) { doSomething(); }
var abc = function() {};
if (true) {
    doSomething();
    doSomethingElse();
    /** comments */
}
if (true) { doSomething(); }
var abc = function() {};
Invalid
if (true) { doSomething(); doSomethingElse(); }
Valid for mode { includeComments: true }
if (true) {
    //comments
    doSomething();
}
var abc = function() {};
// or
if (true) {
    doSomething();
     //comments
}
var abc = function() {};
Invalid
if (true) { //comments
    doSomething();
}
var abc = function() {};
// or
if (true) {
    doSomething();
/** comments */}
var abc = function() {};
Valid for mode { includeComments: true, minLines: 1 }
if (true) {
    //comments
    doSomething();
    doSomethingElse();
}
if (true) { doSomething(); }
var abc = function() {};
// or
if (true) {
    doSomething();
    doSomethingElse();
    //comments
}
if (true) { doSomething(); }
var abc = function() {};
Invalid
if (true) { //comments
    doSomething();
    doSomethingElse();
}
if (true) { doSomething(); }
var abc = function() {};
// or
if (true) {
    doSomething();
    doSomethingElse();
    /** comments */}
if (true) { doSomething(); }
var abc = function() {};
Rule source
Test source