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.

Pad nested callbacks with newlines

See original GitHub issue

Please describe what the rule should do: Pad large callbacks with new lines.

What new ECMAScript feature does this rule relate to? Not applicable - general formatting.

What category of rule is this? (place an “X” next to just one item) [ ] Warns about a potential error (problem) [x] Suggests an alternate way of doing something (suggestion) [ ] Other (please specify:)

Provide 2-3 code examples that this rule will warn about:

const assert = require('assert');
const pg = require('pg');
const DBManager = require('../../src/database/DBManager.js');

describe('DBManager', () => {
// pad with new line here
    describe('#get', () => {
// pad with new line here
        it('should return an instance of pg.Pool', done => {
            assert.equal(true, DBManager.get() instanceof pg.Pool);
            done();
        });
// pad with new line here
    });
// pad with new line here
});

Why should this rule be included in ESLint (instead of a plugin)? It helps break up large function callback nesting as seen in mocha tests.

Are you willing to submit a pull request to implement this rule? I’m juggling a handful of projects currently, so unfortunately no.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
mdjermanoviccommented, Jul 28, 2020

@brenr thanks for the rule proposal!

Given the changes to our rules policy, I’d suggest making a custom rule, which could be based on the padded-blocks rule.

0reactions
eslint-deprecated[bot]commented, Aug 29, 2020

Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach accepted status after 21 days tend to never be accepted, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dealing with nested callbacks - Zell Liew
It's mind-boggling to see nested callbacks, but I don't think it's a “hell”. The “hell” can be manageable if you know what to...
Read more >
String — Elixir v1.13.4 - HexDocs
Divides a string into substrings at each Unicode whitespace occurrence with leading and trailing whitespace ignored. Groups of whitespace are treated as a ......
Read more >
EditText - Android Developers
Returns if the text is constrained to a single horizontally scrolling line ignoring new line characters instead of letting it wrap onto multiple...
Read more >
strip_tags - Manual - PHP
This function tries to return a string with all NULL bytes, HTML and PHP tags stripped from a given string . It uses...
Read more >
Helpers - Laravel - The PHP Framework For Web Artisans
... lower ltrim markdown mask match matchAll newLine padBoth padLeft padRight ... The Arr::get method retrieves a value from a deeply nested array...
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