简体   繁体   English

在JSCS或ESLint中指定特定数量的换行符

[英]Specify specific amount of line breaks in JSCS or ESLint

JSCS has a disallowMultipleLineBreaks rule. JSCS具有disallowMultipleLineBreaks规则。 This asserts that there is no more than 1 line break between statements in JavaScript. 这断言JavaScript中的语句之间的换行符不超过1个。 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. 我想在方法声明之间允许2个换行符,但不能超过2个。我还想在不是方法声明的语句之间不允许1个换行符。 An example: 一个例子:

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


  // ok
  bar : function () {},

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


    // not ok
  }
}

Is this possible in either ESLint or JSCS? ESLint或JSCS是否可能?

Here is the appropriate rule from ESLint : http://eslint.org/docs/rules/no-multiple-empty-lines .... 这是来自ESLint的适当规则: http : ESLint ....

But its very generic and not very specific like you want. 但是它非常通用,并不是您想要的那么具体。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM