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.

Proposed Rule: align function arguments

See original GitHub issue

When does this rule warn? Please describe and show example code:

The rule warns when arguments in a multi-line function call are not aligned.

This code will warn:

var result = myFunc('some long string that will cause someone to want to wrap',
  bar
  baz);

The following will not warn:

var result = myFunc(somethingLongThatMightCauseSomeoneToWantToWrap,
                    bar
                    baz);

If an argument is itself multiline (for example, an inline function) then the rule does not fire for the next argument. This means this code will not warn even though the second argument (100) is not aligned with the first (the function):

setTimeout(function () {
  // do some stuff
}, 100);

Is this rule preventing an error or is it stylistic?

Stylistic

Why is this rule a candidate for inclusion instead of creating a custom rule?

It is a widespread practice that some developers will want to enable linting for. Some developers may already expect this to be possible.

Are you willing to create the rule yourself?

Sure. I have a first implementation here: https://github.com/Trott/io.js/blob/align-multiline-function-call/tools/eslint-rules/align-function-arguments.js

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:30 (28 by maintainers)

github_iconTop GitHub Comments

1reaction
platinumazurecommented, Nov 10, 2016

@ronjouch I think #7473 should work for you (the title says multiline array indentation, but multiline object indentation is mentioned there as well and hopefully we can cover both).

0reactions
ronjouchcommented, Nov 10, 2016

@platinumazure thanks for the fast answer 😃 . Unfortunately, inline-disabling is not an option as this is far from being a one-timer; I have tons of such indents and it would be very invasive.

For now I’ll disable the whole inline or will stick to 3.8.1. Are there any plans to support disabling options (as opposed to a whole rule)? Mabe a bug I could follow / subscribe to?

Read more comments on GitHub >

github_iconTop Results From Across the Web

In C is it possible to control the alignment of function ...
The alignment attribute is a property of the test object, not of its value. Arguments are passed in a platform-specified way. Usually, small ......
Read more >
Aligning function arguments in "algorithm" environment. - TeX
In the "algorithm" environment, when a function call spans multiple lines, I would like to have its arguments aligned, like so:
Read more >
New option for "Align multiline parameter" - JetBrains YouTrack
What steps will reproduce the problem? Enable parameters alignment like this http://joxi.ru/4AkjpRRTkOZjV2. press ctrl+alt+L (autoformat).
Read more >
[llvm-dev] Controlling parameter alignment - Google Groups
I think what we need here is a new attribute, or a repurposed attribute, to control argument alignment. The original patch uses alignstack(n)...
Read more >
Alignment with argument-networks and assessment-predictions
Argument -network score-functions: Argument networks would receive a ... And these inference-rules would be presented in a human-friendly ...
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