2 title: array-element-newline
6 - array-bracket-spacing
7 - array-bracket-newline
8 - object-property-newline
10 - object-curly-newline
11 - max-statements-per-line
18 A number of style guides require or disallow line breaks between array elements.
22 This rule enforces line breaks between array elements.
26 This rule has either a string option:
28 * `"always"` (default) requires line breaks between array elements
29 * `"never"` disallows line breaks between array elements
30 * `"consistent"` requires consistent usage of linebreaks between array elements
32 Or an object option (Requires line breaks if any of properties is satisfied. Otherwise, disallows line breaks):
34 * `"multiline": <boolean>` requires line breaks if there are line breaks inside elements. If this is false, this condition is disabled.
35 * `"minItems": <number>` requires line breaks if the number of elements is at least the given integer. If this is 0, this condition will act the same as the option `"always"`. If this is `null` (the default), this condition is disabled.
37 Alternatively, different configurations can be specified for array expressions and array patterns:
41 "array-element-newline": ["error", {
42 "ArrayExpression": "consistent",
43 "ArrayPattern": { "minItems": 3 },
48 * `"ArrayExpression"` configuration for array expressions (if unspecified, this rule will not apply to array expressions)
49 * `"ArrayPattern"` configuration for array patterns of destructuring assignments (if unspecified, this rule will not apply to array patterns)
53 Examples of **incorrect** code for this rule with the default `"always"` option:
58 /*eslint array-element-newline: ["error", "always"]*/
78 Examples of **correct** code for this rule with the default `"always"` option:
83 /*eslint array-element-newline: ["error", "always"]*/
111 Examples of **incorrect** code for this rule with the `"never"` option:
116 /*eslint array-element-newline: ["error", "never"]*/
139 Examples of **correct** code for this rule with the `"never"` option:
144 /*eslint array-element-newline: ["error", "never"]*/
168 Examples of **incorrect** code for this rule with the `"consistent"` option:
173 /*eslint array-element-newline: ["error", "consistent"]*/
193 Examples of **correct** code for this rule with the `"consistent"` option:
198 /*eslint array-element-newline: ["error", "consistent"]*/
239 Examples of **incorrect** code for this rule with the `{ "multiline": true }` option:
244 /*eslint array-element-newline: ["error", { "multiline": true }]*/
259 Examples of **correct** code for this rule with the `{ "multiline": true }` option:
264 /*eslint array-element-newline: ["error", { "multiline": true }]*/
284 Examples of **incorrect** code for this rule with the `{ "minItems": 3 }` option:
289 /*eslint array-element-newline: ["error", { "minItems": 3 }]*/
306 Examples of **correct** code for this rule with the `{ "minItems": 3 }` option:
311 /*eslint array-element-newline: ["error", { "minItems": 3 }]*/
330 ### multiline and minItems
332 Examples of **incorrect** code for this rule with the `{ "multiline": true, "minItems": 3 }` options:
337 /*eslint array-element-newline: ["error", { "multiline": true, "minItems": 3 }]*/
353 Examples of **correct** code for this rule with the `{ "multiline": true, "minItems": 3 }` options:
358 /*eslint array-element-newline: ["error", { "multiline": true, "minItems": 3 }]*/
378 ### ArrayExpression and ArrayPattern
380 Examples of **incorrect** code for this rule with the `{ "ArrayExpression": "always", "ArrayPattern": "never" }` options:
385 /*eslint array-element-newline: ["error", { "ArrayExpression": "always", "ArrayPattern": "never" }]*/
402 var [i = function foo() {
412 Examples of **correct** code for this rule with the `{ "ArrayExpression": "always", "ArrayPattern": "never" }` options:
417 /*eslint array-element-newline: ["error", { "ArrayExpression": "always", "ArrayPattern": "never" }]*/
435 var [i = function foo() {
437 }, j = function bar() {
444 ## When Not To Use It
446 If you don't want to enforce linebreaks between array elements, don't enable this rule.
450 * **JSCS:** [validateNewlineAfterArrayElements](https://jscs-dev.github.io/rule/validateNewlineAfterArrayElements)