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.

Indent level for fat arrow functions

See original GitHub issue

Tell us about your environment

  • ESLint Version: 3.19.0
  • Node Version: 6.9.5
  • npm Version: 3.10.0

What parser (default, Babel-ESLint, etc.) are you using? default

Please show your full configuration:

{
    "extends": "standard",
    "plugins": [
        "standard",
        "promise"
    ]
}

What did you do? Please include the actual source code causing the issue.

describe('AuthenticationService', () => {
  describe('login', () => {
    it('should not be able to login with wrong credentials',
       inject([AuthenticationService, MockBackend], () => {
         failCheck(
           () => service.login('admin', 'admin'),
         );
       },
    ));

    it('should be able to login with correct credentials',
       inject([AuthenticationService, SessionService, MockBackend],
              () => {
         successCheck(
           () => service.login('admin', 'admin'),
         );
      }),
    );
  });
});

What did you expect to happen? The successCheck should be correctly indented.

It would be nice if the line break resets the indent to the value of inject + 2 instead of orientating at the indent level of the parameter.

What actually happened? Please include the actual, raw output from ESLint.

  14:10  error  Expected indentation of 16 spaces but found 9  indent
  17:7   error  Expected indentation of 14 spaces but found 6  indent

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
not-an-aardvarkcommented, May 11, 2017

@CSchulz In theory, yes. However, we generally only add options to rules if they meet a set of guidelines, such as being generally applicable to many developers. (We can’t add options for every possible preference, because maintaining all the options would impose a large maintenance burden .) It’s possible that this option meets those criteria, but I’m not sure whether it does.

Could you elaborate on what the flag would do? How would it affect arrow function indentations in general? For example, would it affect arrow functions that are not function arguments?

0reactions
not-an-aardvarkcommented, Jun 3, 2017

Closing because this is working as intended, but feel free to create a new issue if you’d like to make a proposal for a new option.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript Code Styling Best Practices — Arrow Functions ...
In this article, we'll look at how to return items from arrow functions implicitly and spacing and indentation to make our code easy...
Read more >
Arrow function indent · Issue #8144 · eslint/eslint - GitHub
It seems that arrow functions use the base indent. eslint --fix. test.js. module.exports = (() ...
Read more >
Which ESLint rule applies to Promise/Arrow function indent?
I suggest adding a new line before the fulfill handler. Since you give .then two handlers, doing so can keep them at the...
Read more >
Arrow function expressions - JavaScript - MDN Web Docs
An arrow function expression is a compact alternative to a traditional function expression, with some semantic differences and deliberate ...
Read more >
I Don't Hate Arrow Functions - David Walsh Blog
"You Don't Know JS: ES6 & Beyond", Ch2, "Arrow Functions" ... are what we value most, when we're level headed enough to make...
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