Search code examples
javascripteslintjscs

Specify specific amount of line breaks in JSCS or ESLint


JSCS has a disallowMultipleLineBreaks rule. This asserts that there is no more than 1 line break between statements in JavaScript. I would like to allow 2 line breaks between method declarations, but no more than 2. I'd also like to disallow more than 1 line break between statements that are not method declarations. An example:

module.exports = {
  foo : function () { },


  // ok
  bar : function () {},

  baz : function () {
    const QUX = 'QUX'


    // not ok
  }
}

Is this possible in either ESLint or JSCS?


Solution

  • Here is the appropriate rule from ESLint: http://eslint.org/docs/rules/no-multiple-empty-lines ....

    But its very generic and not very specific like you want.