2 title: function-paren-newline
8 Many style guides require or disallow newlines inside of function parentheses.
12 This rule enforces consistent line breaks inside parentheses of function parameters or arguments.
16 This rule has a single option, which can either be a string or an object.
18 * `"always"` requires line breaks inside all function parentheses.
19 * `"never"` disallows line breaks inside all function parentheses.
20 * `"multiline"` (default) requires linebreaks inside function parentheses if any of the parameters/arguments have a line break between them. Otherwise, it disallows linebreaks.
21 * `"multiline-arguments"` works like `multiline` but allows linebreaks inside function parentheses if there is only one parameter/argument.
22 * `"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.
23 * `{ "minItems": value }` requires linebreaks inside function parentheses if the number of parameters/arguments is at least `value`. Otherwise, it disallows linebreaks.
25 Example configurations:
30 "function-paren-newline": ["error", "never"]
38 "function-paren-newline": ["error", { "minItems": 3 }]
43 Examples of **incorrect** code for this rule with the `"always"` option:
48 /* eslint function-paren-newline: ["error", "always"] */
50 function foo(bar, baz) {}
52 var foo = function(bar, baz) {};
54 var foo = (bar, baz) => {};
61 Examples of **correct** code for this rule with the `"always"` option:
66 /* eslint function-paren-newline: ["error", "always"] */
90 Examples of **incorrect** code for this rule with the `"never"` option:
95 /* eslint function-paren-newline: ["error", "never"] */
119 Examples of **correct** code for this rule with the `"never"` option:
124 /* eslint function-paren-newline: ["error", "never"] */
126 function foo(bar, baz) {}
131 var foo = function(bar, baz) {};
133 var foo = (bar, baz) => {};
143 Examples of **incorrect** code for this rule with the default `"multiline"` option:
148 /* eslint function-paren-newline: ["error", "multiline"] */
174 Examples of **correct** code for this rule with the default `"multiline"` option:
179 /* eslint function-paren-newline: ["error", "multiline"] */
181 function foo(bar, baz) {}
188 var foo = (bar, baz) => {};
205 Examples of **incorrect** code for this rule with the `"consistent"` option:
210 /* eslint function-paren-newline: ["error", "consistent"] */
216 var foo = function(bar,
236 Examples of **correct** code for this rule with the `"consistent"` option:
241 /* eslint function-paren-newline: ["error", "consistent"] */
246 var foo = function(bar, baz) {};
266 Examples of **incorrect** code for this rule with the `"multiline-arguments"` option:
271 /* eslint function-paren-newline: ["error", "multiline-arguments"] */
277 var foo = function(bar,
297 Examples of **correct** code for this rule with the consistent `"multiline-arguments"` option:
302 /* eslint function-paren-newline: ["error", "multiline-arguments"] */
309 var foo = function(bar, baz) {};
324 Examples of **incorrect** code for this rule with the `{ "minItems": 3 }` option:
329 /* eslint function-paren-newline: ["error", { "minItems": 3 }] */
336 function foo(bar, baz, qux) {}
351 Examples of **correct** code for this rule with the `{ "minItems": 3 }` option:
356 /* eslint function-paren-newline: ["error", { "minItems": 3 }] */
358 function foo(bar, baz) {}
379 ## When Not To Use It
381 If don't want to enforce consistent linebreaks inside function parentheses, do not turn on this rule.