question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Require padding depending on line count

See original GitHub issue

What rule do you want to change?

padded-blocks

Does this change cause the rule to produce more or fewer warnings?

It depends.

How will the change be implemented? (New option, new default behavior, etc.)?

New option: min-expression-count and max-expression-count. /*eslint padded-blocks: ["error", "always", { allowSingleLineBlocks: false, minExpressionCount: 3 }]*/ /*eslint padded-blocks: ["error", "never", { allowSingleLineBlocks: true, maxExpressionCount: 2 }]*/

Please provide some example code that this change will affect:


  // not allowed
  function foo() {
    bar();
    bar();
    bar();
  }

  // allowed
  function foo() {

    bar();
    bar();
    bar();

  }

  // allowed
  function foo() {
    bar();
    bar();
  }

  // allowed
  function foo() {
    bar();
  }

  // not allowed
  function foo() {

    bar();

  }

  // allowed
  function foo() { bar(); }

  // not allowed
  function foo() { bar(); bar(); bar(); }

What does the rule currently do for this code? Disregards the lines in blocks

What will the rule do after it’s changed? Consider if a body is long enough to see it worth padding

Are you willing to submit a pull request to implement this change? Yes, if pointed in the right direction

I know it’s not the most common style, bu we have a huge codebase that we want to switch to ESLint. It would be great if this is possible.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
anikethsahacommented, Apr 18, 2020

it’s not necessary to fork eslint repo. You can simply write your own eslint plugin and you can even extend the eslint’s base rule , refer this example on how to extend a base rule.

0reactions
ege24commented, Apr 22, 2020

Thanks a lot for the input, I’ll try extending the rule.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Column padding while using column-count and column-rule
I have considered using flex with wrapping, however, I believe that requires a fixed height. (Correct me if I'm wrong.) The aim is...
Read more >
padding-inline-end - CSS: Cascading Style Sheets | MDN
The padding-inline-end CSS property defines the logical inline end padding of an element, which maps to a physical padding depending on the ...
Read more >
Text QML Type | Qt Quick 6.4.1
These properties hold the padding around the content. This space is reserved in addition to the contentWidth and contentHeight. This QML property was...
Read more >
How to Set CSS Margins and Padding (And Cool Layout Tricks)
In case of em units, the computed value for margin and padding is based on the font size of the element. In the...
Read more >
box-sizing - CSS-Tricks
The padding and border are added to the outside of the box. ... The red line between the images represents the elements' width...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found