eslint-config-node icon indicating copy to clipboard operation
eslint-config-node copied to clipboard

Discussion eslint rule `padding-line-between-statements`

Open danez opened this issue 2 years ago • 4 comments

In compute we have some styling rules that are currently not enforced, but somewhat manually requested in PRs. These two rules are:

  1. Add an empty line before a return statement:
 something
+
 return x
  1. Add an empty line after a variable declaration, unless next statement is also a variable declaration:
 var u = 3 
 const x = 1
 let y = 2
+
 something

In zip-it-and-ship-it we enabled the rule padding-line-between-statements with the following config

    'padding-line-between-statements': [
      'error',
      // Require newline before return
      { blankLine: 'always', prev: '*', next: 'return' },
      // Require newline after a batch of variable declarations
      { blankLine: 'always', prev: ['const', 'let', 'var'], next: '*' },
      { blankLine: 'any', prev: ['const', 'let', 'var'], next: ['const', 'let', 'var'] },
    ],

and this ensures that these exact two behaviors mentioned above are enforced.

Is this something that other teams are doing as well? Should we enable this globally in this eslint config for all nodejs projects? Are there any reasons against doing this?

I think if we can agree on this, this is one less thing to worry about when reviewing or writing nodejs code.

I brought this up in the dev tooling guild before and now here as a concrete issue.

cc @Skn0tt @eduardoboucas @ascorbic @khendrikse @lukasholzer @netlify/netlify-dev

danez avatar Jul 28 '22 12:07 danez

My vote is yes, pretty please.

eduardoboucas avatar Jul 28 '22 13:07 eduardoboucas

I mean, why not? 🤷 the less ambiguity, the better

Skn0tt avatar Jul 29 '22 05:07 Skn0tt

No objection here!

ascorbic avatar Jul 29 '22 15:07 ascorbic

Sounds good!

khendrikse avatar Aug 02 '22 15:08 khendrikse