Proposed Rule: align function arguments
See original GitHub issueWhen 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:
- Created 7 years ago
- Comments:30 (28 by maintainers)
@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).
@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?