validateNewlineAfterArrayElements

Requires each element in array on a single line when array length is more than passed maximum number or array fills more than one line.

Types: Boolean, Integer, Object

Values:

  • true: setting this is the same as validating the rule using {maximum: Infinity, ignoreBrackets: false}
  • Integer: setting this is the same as validating the rule using {maximum: Integer, ignoreBrackets: false}
  • Object:
    • maximum
      • Integer specifies the maximum number of elements that a single line array can contain
    • ignoreBrackets
      • true specifies that the [ and ] brackets can be placed on the same line as the array elements

Example

"validateNewlineAfterArrayElements": {
  "maximum": 3
}
Valid for mode true
var x = [{a: 1}, [2], '3', 4, 5, 6];
var x = [
  {a: 1},
  [2],
  '3',
  4
];
Invalid for mode true
var x = [1,
  2];
Valid for mode 3
var x = [{a: 1}, [2], '3'];
var x = [
  1,
  2,
  3,
  4
];
Invalid for mode 3
var x = [1, 2, 3, 4];
var x = [1,
  2,
  3];
var x = [
    1, 2
];
Valid for mode {maximum: 2, ignoreBrackets: true}
var x = [{a: 1}, [2]];
var x = [1,
  2,
  3];
Invalid for mode {maximum: 2, ignoreBrackets: true}
var x = [1, 2, 3];
var x = [1, 2,
  3];
var x = [1,
  2, 3];
Rule source
Test source