ArtemM ArtemM - 1 year ago 82
Javascript Question

Has ESlint a rule about blank line before the first statement in function?

Due ESLint I found a rule newline-before-return about empty line before return statements. But did not see a rule about empty line before the first statement in function. F.e.:

function (a) {

var b = +a;

Has ESlint a rule about this? If it has, what is the name this rule?

Answer Source

The padded-blocks rule allows you to require newlines at the start and end of blocks, including function bodies. In addition to function bodies, it also covers the bodies of if statements, for and while loops, and other block-like structures, which you may or may not want.

Try pasting the following code in the demo to see if it works for you:

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

    if (bar) {




If you only want to check function bodies, you could follow @Dhananjay's suggestion and edit the rule's source code into your own custom rule.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download