`function-paren-newline` "multiline" errors for single arguments on their own line
See original GitHub issueTell us about your environment
- ESLint Version: v4.6.1
- Node Version: v8.3.0
- npm Version: v5.3.0
What parser (default, Babel-ESLint, etc.) are you using? babel-eslint
Please show your full configuration:
Configuration
// relevant section:
"function-paren-newline" : ["error", "multiline"],
What did you do? Please include the actual source code causing the issue.
function foo(
param1
)
// or
foo(
"some very long argument that I'd love to have on it's own line"
);
What did you expect to happen?
No errors
What actually happened? Please include the actual, raw output from ESLint.
1:13 error Unexpected newline after '(' function-paren-newline
3:1 error Unexpected newline before ')' function-paren-newline
7:4 error Unexpected newline after '(' function-paren-newline
9:1 error Unexpected newline before ')' function-paren-newline
Some elaboration: with the multiline
setting it is only allowed to have newlines in function parenthesis if there are at least 2 arguments. I would expect it to also accept newlines in function parenthesis for single arguments as well (as long as it’s done consistent).
I’m not sure if this is actually a bug or intended behaviour, if it’s the latter then an option to allow newlines for single-argument functions would be very welcome.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:7 (4 by maintainers)
Top GitHub Comments
@not-an-aardvark
I would echo @TiddoLangerak’s desires for a rule that merely enforces “either all parameters are on their own line, or none are”. The
multiline
option does nearly everything needed for that, with the exception of single arguments. There are times when an individual argument may be a bit verbose and sometimes it is cleaner for that parameter to live on its own line (typically when I write my React test cases).The
consistent
option, while permitting a single parameter on a newline, is insufficient, because it allows cases that would be unacceptable:Should I go ahead and create a new issue requesting an additional option to this rule or can we re-open this one?
Feel free to create a new issue. That said, keep in mind that you can always implement your preference as a custom rule without it being implemented as part of ESLint itself.