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.

Add rule to enforce new line for every parameter in a multi-line function call

See original GitHub issue

Please describe what the rule should do:

The rule should enforce one line per parameter for multi-line function calls.

What category of rule is this? (place an “X” next to just one item)

[X] Enforces code style [X] Warns about a potential error [ ] Suggests an alternate way of doing something [ ] Other (please specify:)

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

// Bad
someFunction(
    true, "abc",
    123
);

// Good
someFunction(
    true, 
    "abc",
    123
);

// Good
someFunction(
    true
);

// All parameters in one line should also be fine (imho)
someFunction(
    true, "abc", 123
);

Why should this rule be included in ESLint (instead of a plugin)? In multi-line function calls with more than one parameter it can be confusing if some parameters share a line and others have an own line. Especially if some parameters are very long and some function arguments are optional.

function doSomething(someBool, someText = "foo", someOtherText = "bar") {
    if (someBool) {
        console.log(someText);
    } else {
        console.log(someOtherText);
    }
}

// At first glance one might think, "oh geez" is used for someText
doSomething(
    $(".someElement").hasClass("barz") && !$(".someElement").hasClass("fooz"), "blah",
    "oh geez" 
);

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:11
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
finicocommented, Jul 26, 2019

Hello @platinumazure, it took a while, but I did it. I didn’t immediately realize what was wrong with the commit message, so there’s a little bit of a mess.

1reaction
aladdin-addcommented, Oct 20, 2018

now it’s accepted. 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

function-call-argument-newline - Pluggable JavaScript Linter
This rule enforces line breaks between arguments of a function call. Options. This rule has a string option: "always" (default) requires line breaks...
Read more >
Code Style: One argument per line in a multi-line function call
Feature request for adding code style setting: Only one argument is allowed per line in a multi-line function call. For both Function declaration...
Read more >
Require multiline parameters and arguments to start on a new ...
I'm configuring SwiftLint for a project, and one of our standards that I would like to enforce is this ...
Read more >
PEP-8: clarify if multiline argument list with a closing `)` on a ...
The rationale behind this exception (the closing brace of a multiline construct may be on a line by itself except for ): )...
Read more >
KtLint configuration
Code style¶ · ktlint_code_style = official ; Final newline¶ · insert_final_newline = true ; Force multiline function signature based on number of parameters¶....
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