Skip to content
Advertisement

Eslint – No empty first and last lines for function bodies

Which rule is used for converting this code

function sayHello() {

   console.log("Hello world!");

}

into

function sayHello() {
   console.log("Hello world!"); // No empty lines at the end and beginning
}

?

Advertisement

Answer

There’s a rule for blocks: padded-blocks.

If enabled, an option is:

“blocks” require or disallow padding within block statements, function bodies, and class static blocks

There doesn’t look to be a configurable option for functions in particular.

You’ll want the config option:

[2, 'never']

or

[2, { blocks: 'never' }]
Advertisement