2 title: function-paren-newline
9 Many style guides require or disallow newlines inside of function parentheses.
13 This rule enforces consistent line breaks inside parentheses of function parameters or arguments.
17 This rule has a single option, which can either be a string or an object.
19 * `"always"` requires line breaks inside all function parentheses.
20 * `"never"` disallows line breaks inside all function parentheses.
21 * `"multiline"` (default) requires linebreaks inside function parentheses if any of the parameters/arguments have a line break between them. Otherwise, it disallows linebreaks.
22 * `"multiline-arguments"` works like `multiline` but allows linebreaks inside function parentheses if there is only one parameter/argument.
23 * `"consistent"` requires consistent usage of linebreaks for each pair of parentheses. It reports an error if one parenthesis in the pair has a linebreak inside it and the other parenthesis does not.
24 * `{ "minItems": value }` requires linebreaks inside function parentheses if the number of parameters/arguments is at least `value`. Otherwise, it disallows linebreaks.
26 Example configurations:
31 "function-paren-newline": ["error", "never"]
39 "function-paren-newline": ["error", { "minItems": 3 }]
44 Examples of **incorrect** code for this rule with the `"always"` option:
49 /* eslint function-paren-newline: ["error", "always"] */
51 function foo(bar, baz) {}
53 var foo = function(bar, baz) {};
55 var foo = (bar, baz) => {};
62 Examples of **correct** code for this rule with the `"always"` option:
67 /* eslint function-paren-newline: ["error", "always"] */
91 Examples of **incorrect** code for this rule with the `"never"` option:
96 /* eslint function-paren-newline: ["error", "never"] */
120 Examples of **correct** code for this rule with the `"never"` option:
125 /* eslint function-paren-newline: ["error", "never"] */
127 function foo(bar, baz) {}
132 var foo = function(bar, baz) {};
134 var foo = (bar, baz) => {};
144 Examples of **incorrect** code for this rule with the default `"multiline"` option:
149 /* eslint function-paren-newline: ["error", "multiline"] */
175 Examples of **correct** code for this rule with the default `"multiline"` option:
180 /* eslint function-paren-newline: ["error", "multiline"] */
182 function foo(bar, baz) {}
189 var foo = (bar, baz) => {};
206 Examples of **incorrect** code for this rule with the `"consistent"` option:
211 /* eslint function-paren-newline: ["error", "consistent"] */
217 var foo = function(bar,
237 Examples of **correct** code for this rule with the `"consistent"` option:
242 /* eslint function-paren-newline: ["error", "consistent"] */
247 var foo = function(bar, baz) {};
267 Examples of **incorrect** code for this rule with the `"multiline-arguments"` option:
272 /* eslint function-paren-newline: ["error", "multiline-arguments"] */
278 var foo = function(bar,
298 Examples of **correct** code for this rule with the consistent `"multiline-arguments"` option:
303 /* eslint function-paren-newline: ["error", "multiline-arguments"] */
310 var foo = function(bar, baz) {};
325 Examples of **incorrect** code for this rule with the `{ "minItems": 3 }` option:
330 /* eslint function-paren-newline: ["error", { "minItems": 3 }] */
337 function foo(bar, baz, qux) {}
352 Examples of **correct** code for this rule with the `{ "minItems": 3 }` option:
357 /* eslint function-paren-newline: ["error", { "minItems": 3 }] */
359 function foo(bar, baz) {}
380 ## When Not To Use It
382 If don't want to enforce consistent linebreaks inside function parentheses, do not turn on this rule.