Does ESlint have an empty line rule before the first statement in a function?

Due ESLint I found the newline-before-return rule about an empty line before return statements. But there was no rule about an empty line before the first statement in a function. Fe :.

function (a) {

    var b = +a;
}

Does ESlint have a rule about this? If so, what is the name of this rule? Thanks

+4
source share
3 answers

The padded-blocks rule allows you to require new lines at the beginning and end of blocks, including function bodies. In addition to function bodies, it also encompasses operator bodies if, loops for, whileand other block-like structures that you may or may not want.

demo, , :

/* eslint padded-blocks: "error" */
function foo(bar) {

    if (bar) {

        foo();

    }

}

, @Dhananjay .

+4

, . ,

+2

HAPI ESLint, :

npm install eslint-plugin-hapi --save-dev
// Add in your `.eslintrc`
{
  "plugins": [
    "hapi"
  ],
  "rules": {
    "hapi/hapi-scope-start": ["error"]
  }
}

HAPI ESLint config.
, Airbnb .

0
source

Source: https://habr.com/ru/post/1652176/


All Articles