Add rule to enforce new line for every parameter in a multi-line function call
See original GitHub issuePlease 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:
- Created 5 years ago
- Reactions:11
- Comments:9 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
now it’s accepted. 😄