]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/rules/array-bracket-newline.js
90ee8213b7780d8c4c2c995d011df2d497d687d6
2 * @fileoverview Tests for array-bracket-newline rule.
3 * @author Jan Peer Stöcklmair <https://github.com/JPeer264>
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
12 const rule
= require("../../../lib/rules/array-bracket-newline");
13 const { RuleTester
} = require("../../../lib/rule-tester");
16 //------------------------------------------------------------------------------
18 //------------------------------------------------------------------------------
20 const ruleTester
= new RuleTester();
22 ruleTester
.run("array-bracket-newline", rule
, {
28 * "default" { multiline: true }
32 "var foo = /* any comment */[1];",
33 "var foo = /* any comment */\n[1];",
35 "var foo = [ // any comment\n1, 2\n];",
36 "var foo = [\n// any comment\n1, 2\n];",
37 "var foo = [\n1, 2\n// any comment\n];",
38 "var foo = [\n1,\n2\n];",
39 "var foo = [\nfunction foo() {\nreturn dosomething();\n}\n];",
40 "var foo = [/* \nany comment\n */];",
41 "var foo = [/* single line multiline comment for no real reason */];",
45 { code
: "var foo = [\n];", options
: ["always"] },
46 { code
: "var foo = [\n1\n];", options
: ["always"] },
47 { code
: "var foo = [\n// any\n1\n];", options
: ["always"] },
48 { code
: "var foo = [\n/* any */\n1\n];", options
: ["always"] },
49 { code
: "var foo = [\n1, 2\n];", options
: ["always"] },
50 { code
: "var foo = [\n1, 2 // any comment\n];", options
: ["always"] },
52 code
: "var foo = [\n1, 2 /* any comment */\n];",
55 { code
: "var foo = [\n1,\n2\n];", options
: ["always"] },
57 code
: "var foo = [\nfunction foo() {\ndosomething();\n}\n];",
84 { code
: "var foo = [];", options
: ["never"] },
85 { code
: "var foo = [1];", options
: ["never"] },
86 { code
: "var foo = [/* any comment */1];", options
: ["never"] },
87 { code
: "var foo = [1, 2];", options
: ["never"] },
88 { code
: "var foo = [1,\n2];", options
: ["never"] },
89 { code
: "var foo = [1,\n/* any comment */\n2];", options
: ["never"] },
91 code
: "var foo = [function foo() {\ndosomething();\n}];",
95 code
: "var foo = [[1,2],3];",
100 { code
: "var a = []", options
: ["consistent"] },
101 { code
: "var a = [\n]", options
: ["consistent"] },
102 { code
: "var a = [1]", options
: ["consistent"] },
103 { code
: "var a = [\n1\n]", options
: ["consistent"] },
104 { code
: "var a = [//\n1\n]", options
: ["consistent"] },
105 { code
: "var a = [/**/\n1\n]", options
: ["consistent"] },
106 { code
: "var a = [/*\n*/1\n]", options
: ["consistent"] },
107 { code
: "var a = [//\n]", options
: ["consistent"] },
112 options
: ["consistent"]
118 options
: ["consistent"]
121 // { multiline: true }
122 { code
: "var foo = [];", options
: [{ multiline
: true }] },
123 { code
: "var foo = [1];", options
: [{ multiline
: true }] },
125 code
: "var foo = /* any comment */[1];",
126 options
: [{ multiline
: true }]
129 code
: "var foo = /* any comment */\n[1];",
130 options
: [{ multiline
: true }]
132 { code
: "var foo = [1, 2];", options
: [{ multiline
: true }] },
134 code
: "var foo = [ // any comment\n1, 2\n];",
135 options
: [{ multiline
: true }]
138 code
: "var foo = [\n// any comment\n1, 2\n];",
139 options
: [{ multiline
: true }]
142 code
: "var foo = [\n1, 2\n// any comment\n];",
143 options
: [{ multiline
: true }]
145 { code
: "var foo = [\n1,\n2\n];", options
: [{ multiline
: true }] },
147 code
: "var foo = [\nfunction foo() {\nreturn dosomething();\n}\n];",
148 options
: [{ multiline
: true }]
151 code
: "var foo = [/* \nany comment\n */];",
152 options
: [{ multiline
: true }]
155 code
: "var foo = [\n1,\n2,\n[3,4],\n];",
156 options
: [{ multiline
: true }]
159 code
: "var foo = [\n1,\n2,\n[\n3,\n4\n],\n];",
160 options
: [{ multiline
: true }]
163 // { multiline: false }
164 { code
: "var foo = [];", options
: [{ multiline
: false }] },
165 { code
: "var foo = [1];", options
: [{ multiline
: false }] },
167 code
: "var foo = [1]/* any comment*/;",
168 options
: [{ multiline
: false }]
171 code
: "var foo = [1]\n/* any comment*/\n;",
172 options
: [{ multiline
: false }]
174 { code
: "var foo = [1, 2];", options
: [{ multiline
: false }] },
175 { code
: "var foo = [1,\n2];", options
: [{ multiline
: false }] },
177 code
: "var foo = [function foo() {\nreturn dosomething();\n}];",
178 options
: [{ multiline
: false }]
180 { code
: "var foo = [1,\n2,[3,\n4]];", options
: [{ multiline
: false }] },
183 { code
: "var foo = [];", options
: [{ minItems
: 2 }] },
184 { code
: "var foo = [1];", options
: [{ minItems
: 2 }] },
185 { code
: "var foo = [\n1, 2\n];", options
: [{ minItems
: 2 }] },
186 { code
: "var foo = [\n1,\n2\n];", options
: [{ minItems
: 2 }] },
188 code
: "var foo = [function foo() {\ndosomething();\n}];",
189 options
: [{ minItems
: 2 }]
197 options
: [{ minItems
: 2 }]
203 options
: [{ minItems
: 2 }]
207 { code
: "var foo = [\n];", options
: [{ minItems
: 0 }] },
208 { code
: "var foo = [\n1\n];", options
: [{ minItems
: 0 }] },
209 { code
: "var foo = [\n1, 2\n];", options
: [{ minItems
: 0 }] },
210 { code
: "var foo = [\n1,\n2\n];", options
: [{ minItems
: 0 }] },
212 code
: "var foo = [\nfunction foo() {\ndosomething();\n}\n];",
213 options
: [{ minItems
: 0 }]
216 // { minItems: null }
217 { code
: "var foo = [];", options
: [{ minItems
: null }] },
218 { code
: "var foo = [1];", options
: [{ minItems
: null }] },
219 { code
: "var foo = [1, 2];", options
: [{ minItems
: null }] },
220 { code
: "var foo = [1,\n2];", options
: [{ minItems
: null }] },
222 code
: "var foo = [function foo() {\ndosomething();\n}];",
223 options
: [{ minItems
: null }]
226 // { multiline: true, minItems: null }
228 code
: "var foo = [];",
229 options
: [{ multiline
: true, minItems
: null }]
232 code
: "var foo = [1];",
233 options
: [{ multiline
: true, minItems
: null }]
236 code
: "var foo = [1, 2];",
237 options
: [{ multiline
: true, minItems
: null }]
240 code
: "var foo = [\n1,\n2\n];",
241 options
: [{ multiline
: true, minItems
: null }]
244 code
: "var foo = [\nfunction foo() {\ndosomething();\n}\n];",
245 options
: [{ multiline
: true, minItems
: null }]
248 // { multiline: true, minItems: 2 }
249 { code
: "var a = [];", options
: [{ multiline
: true, minItems
: 2 }] },
250 { code
: "var b = [1];", options
: [{ multiline
: true, minItems
: 2 }] },
252 code
: "var b = [ // any comment\n1\n];",
253 options
: [{ multiline
: true, minItems
: 2 }]
256 code
: "var b = [ /* any comment */ 1];",
257 options
: [{ multiline
: true, minItems
: 2 }]
260 code
: "var c = [\n1, 2\n];",
261 options
: [{ multiline
: true, minItems
: 2 }]
264 code
: "var c = [\n/* any comment */1, 2\n];",
265 options
: [{ multiline
: true, minItems
: 2 }]
268 code
: "var c = [\n1, /* any comment */ 2\n];",
269 options
: [{ multiline
: true, minItems
: 2 }]
272 code
: "var d = [\n1,\n2\n];",
273 options
: [{ multiline
: true, minItems
: 2 }]
276 code
: "var e = [\nfunction foo() {\ndosomething();\n}\n];",
277 options
: [{ multiline
: true, minItems
: 2 }]
282 * default { multiline: true }
284 { code
: "var [] = foo", parserOptions
: { ecmaVersion
: 6 } },
285 { code
: "var [a] = foo;", parserOptions
: { ecmaVersion
: 6 } },
287 code
: "var /* any comment */[a] = foo;",
288 parserOptions
: { ecmaVersion
: 6 }
291 code
: "var /* any comment */\n[a] = foo;",
292 parserOptions
: { ecmaVersion
: 6 }
294 { code
: "var [a, b] = foo;", parserOptions
: { ecmaVersion
: 6 } },
296 code
: "var [ // any comment\na, b\n] = foo;",
297 parserOptions
: { ecmaVersion
: 6 }
300 code
: "var [\n// any comment\na, b\n] = foo;",
301 parserOptions
: { ecmaVersion
: 6 }
304 code
: "var [\na, b\n// any comment\n] = foo;",
305 parserOptions
: { ecmaVersion
: 6 }
307 { code
: "var [\na,\nb\n] = foo;", parserOptions
: { ecmaVersion
: 6 } },
311 code
: "var [\n] = foo;",
313 parserOptions
: { ecmaVersion
: 6 }
316 code
: "var [\na\n] = foo;",
318 parserOptions
: { ecmaVersion
: 6 }
321 code
: "var [\n// any\na\n] = foo;",
323 parserOptions
: { ecmaVersion
: 6 }
326 code
: "var [\n/* any */\na\n] = foo;",
328 parserOptions
: { ecmaVersion
: 6 }
331 code
: "var [\na, b\n] = foo;",
333 parserOptions
: { ecmaVersion
: 6 }
336 code
: "var [\na, b // any comment\n] = foo;",
338 parserOptions
: { ecmaVersion
: 6 }
341 code
: "var [\na, b /* any comment */\n] = foo;",
343 parserOptions
: { ecmaVersion
: 6 }
346 code
: "var [\na,\nb\n] = foo;",
348 parserOptions
: { ecmaVersion
: 6 }
353 code
: "var [] = foo",
354 options
: ["consistent"],
355 parserOptions
: { ecmaVersion
: 6 }
358 code
: "var [\n] = foo",
359 options
: ["consistent"],
360 parserOptions
: { ecmaVersion
: 6 }
363 code
: "var [a] = foo",
364 options
: ["consistent"],
365 parserOptions
: { ecmaVersion
: 6 }
368 code
: "var [\na\n] = foo",
369 options
: ["consistent"],
370 parserOptions
: { ecmaVersion
: 6 }
373 code
: "var [//\na\n] = foo",
374 options
: ["consistent"],
375 parserOptions
: { ecmaVersion
: 6 }
378 code
: "var [/**/\na\n] = foo",
379 options
: ["consistent"],
380 parserOptions
: { ecmaVersion
: 6 }
383 code
: "var [/*\n*/a\n] = foo",
384 options
: ["consistent"],
385 parserOptions
: { ecmaVersion
: 6 }
388 code
: "var [//\n] = foo",
389 options
: ["consistent"],
390 parserOptions
: { ecmaVersion
: 6 }
393 // { multiline: true }
395 code
: "var [] = foo;",
396 options
: [{ multiline
: true }],
397 parserOptions
: { ecmaVersion
: 6 }
400 code
: "var [a] = foo;",
401 options
: [{ multiline
: true }],
402 parserOptions
: { ecmaVersion
: 6 }
405 code
: "var /* any comment */[a] = foo;",
406 options
: [{ multiline
: true }],
407 parserOptions
: { ecmaVersion
: 6 }
410 code
: "var /* any comment */\n[a] = foo;",
411 options
: [{ multiline
: true }],
412 parserOptions
: { ecmaVersion
: 6 }
415 code
: "var [a, b] = foo;",
416 options
: [{ multiline
: true }],
417 parserOptions
: { ecmaVersion
: 6 }
420 code
: "var [ // any comment\na, b\n] = foo;",
421 options
: [{ multiline
: true }],
422 parserOptions
: { ecmaVersion
: 6 }
425 code
: "var [\n// any comment\na, b\n] = foo;",
426 options
: [{ multiline
: true }],
427 parserOptions
: { ecmaVersion
: 6 }
430 code
: "var [\na, b\n// any comment\n] = foo;",
431 options
: [{ multiline
: true }],
432 parserOptions
: { ecmaVersion
: 6 }
435 code
: "var [\na,\nb\n] = foo;",
436 options
: [{ multiline
: true }],
437 parserOptions
: { ecmaVersion
: 6 }
443 // default : { mutliline : true}
448 output
: "var foo = [[1,2]]",
451 messageId
: "unexpectedOpeningLinebreak",
452 type
: "ArrayExpression",
459 messageId
: "unexpectedClosingLinebreak",
460 type
: "ArrayExpression",
469 code
: "var foo = [[2,\n3]]",
470 output
: "var foo = [\n[\n2,\n3\n]\n]",
475 messageId
: "missingOpeningLinebreak",
482 messageId
: "missingOpeningLinebreak",
489 messageId
: "missingClosingLinebreak",
496 messageId
: "missingClosingLinebreak",
508 code
: "var foo = [[1,2]]",
509 output
: "var foo = [\n[\n1,2\n]\n]",
515 messageId
: "missingOpeningLinebreak",
522 messageId
: "missingOpeningLinebreak",
529 messageId
: "missingClosingLinebreak",
536 messageId
: "missingClosingLinebreak",
543 code
: "var foo = [];",
544 output
: "var foo = [\n];",
548 messageId
: "missingOpeningLinebreak",
549 type
: "ArrayExpression",
556 messageId
: "missingClosingLinebreak",
557 type
: "ArrayExpression",
566 code
: "var foo = [1];",
567 output
: "var foo = [\n1\n];",
571 messageId
: "missingOpeningLinebreak",
572 type
: "ArrayExpression",
577 messageId
: "missingClosingLinebreak",
578 type
: "ArrayExpression",
585 code
: "var foo = [ // any comment\n1];",
586 output
: "var foo = [ // any comment\n1\n];",
590 messageId
: "missingClosingLinebreak",
591 type
: "ArrayExpression",
600 code
: "var foo = [ /* any comment */\n1];",
601 output
: "var foo = [ /* any comment */\n1\n];",
605 messageId
: "missingClosingLinebreak",
606 type
: "ArrayExpression",
613 code
: "var foo = [1, 2];",
614 output
: "var foo = [\n1, 2\n];",
618 messageId
: "missingOpeningLinebreak",
619 type
: "ArrayExpression",
626 messageId
: "missingClosingLinebreak",
627 type
: "ArrayExpression",
636 code
: "var foo = [1, 2 // any comment\n];",
637 output
: "var foo = [\n1, 2 // any comment\n];",
641 messageId
: "missingOpeningLinebreak",
642 type
: "ArrayExpression",
649 code
: "var foo = [1, 2 /* any comment */];",
650 output
: "var foo = [\n1, 2 /* any comment */\n];",
654 messageId
: "missingOpeningLinebreak",
655 type
: "ArrayExpression",
660 messageId
: "missingClosingLinebreak",
661 type
: "ArrayExpression",
668 code
: "var foo = [1,\n2];",
669 output
: "var foo = [\n1,\n2\n];",
673 messageId
: "missingOpeningLinebreak",
674 type
: "ArrayExpression",
679 messageId
: "missingClosingLinebreak",
680 type
: "ArrayExpression",
687 code
: "var foo = [function foo() {\ndosomething();\n}];",
688 output
: "var foo = [\nfunction foo() {\ndosomething();\n}\n];",
692 messageId
: "missingOpeningLinebreak",
693 type
: "ArrayExpression",
698 messageId
: "missingClosingLinebreak",
699 type
: "ArrayExpression",
710 output
: "var foo = [[1,2],3];",
716 messageId
: "unexpectedOpeningLinebreak",
723 code
: "var foo = [\n];",
724 output
: "var foo = [];",
728 messageId
: "unexpectedOpeningLinebreak",
729 type
: "ArrayExpression",
734 messageId
: "unexpectedClosingLinebreak",
735 type
: "ArrayExpression",
742 code
: "var foo = [\n1\n];",
743 output
: "var foo = [1];",
747 messageId
: "unexpectedOpeningLinebreak",
748 type
: "ArrayExpression",
755 messageId
: "unexpectedClosingLinebreak",
756 type
: "ArrayExpression",
765 code
: "var foo = [\n1\n];",
766 output
: "var foo = [1];",
770 messageId
: "unexpectedOpeningLinebreak",
771 type
: "ArrayExpression",
776 messageId
: "unexpectedClosingLinebreak",
777 type
: "ArrayExpression",
784 code
: "var foo = [ /* any comment */\n1, 2\n];",
785 output
: "var foo = [ /* any comment */\n1, 2];",
789 messageId
: "unexpectedOpeningLinebreak",
790 type
: "ArrayExpression",
795 messageId
: "unexpectedClosingLinebreak",
796 type
: "ArrayExpression",
803 code
: "var foo = [\n1, 2\n/* any comment */];",
804 output
: "var foo = [1, 2\n/* any comment */];",
808 messageId
: "unexpectedOpeningLinebreak",
809 type
: "ArrayExpression",
814 messageId
: "unexpectedClosingLinebreak",
815 type
: "ArrayExpression",
822 code
: "var foo = [ // any comment\n1, 2\n];",
823 output
: "var foo = [ // any comment\n1, 2];",
827 messageId
: "unexpectedOpeningLinebreak",
828 type
: "ArrayExpression",
833 messageId
: "unexpectedClosingLinebreak",
834 type
: "ArrayExpression",
841 code
: "var foo = [\n1,\n2\n];",
842 output
: "var foo = [1,\n2];",
846 messageId
: "unexpectedOpeningLinebreak",
847 type
: "ArrayExpression",
852 messageId
: "unexpectedClosingLinebreak",
853 type
: "ArrayExpression",
860 code
: "var foo = [\nfunction foo() {\ndosomething();\n}\n];",
861 output
: "var foo = [function foo() {\ndosomething();\n}];",
865 messageId
: "unexpectedOpeningLinebreak",
866 type
: "ArrayExpression",
871 messageId
: "unexpectedClosingLinebreak",
872 type
: "ArrayExpression",
881 code
: `var a = [[1,2]
883 output
: "var a = [[1,2]]",
884 options
: ["consistent"],
889 messageId
: "unexpectedClosingLinebreak",
896 code
: "var a = [\n[\n[1,2]]\n]",
897 output
: "var a = [\n[\n[1,2]\n]\n]",
898 options
: ["consistent"],
903 messageId
: "missingClosingLinebreak",
910 code
: "var foo = [\n1]",
911 output
: "var foo = [\n1\n]",
912 options
: ["consistent"],
915 messageId
: "missingClosingLinebreak",
916 type
: "ArrayExpression",
925 code
: "var foo = [1\n]",
926 output
: "var foo = [1]",
927 options
: ["consistent"],
930 messageId
: "unexpectedClosingLinebreak",
931 type
: "ArrayExpression",
940 code
: "var foo = [//\n1]",
941 output
: "var foo = [//\n1\n]",
942 options
: ["consistent"],
945 messageId
: "missingClosingLinebreak",
946 type
: "ArrayExpression",
955 // { multiline: true }
957 code
: "var foo = [\n];",
958 output
: "var foo = [];",
959 options
: [{ multiline
: true }],
962 messageId
: "unexpectedOpeningLinebreak",
963 type
: "ArrayExpression",
968 messageId
: "unexpectedClosingLinebreak",
969 type
: "ArrayExpression",
976 code
: "var foo = [\n// any comment\n];",
978 options
: [{ multiline
: true }],
981 messageId
: "unexpectedOpeningLinebreak",
982 type
: "ArrayExpression",
987 messageId
: "unexpectedClosingLinebreak",
988 type
: "ArrayExpression",
995 code
: "var foo = [\n1\n];",
996 output
: "var foo = [1];",
997 options
: [{ multiline
: true }],
1000 messageId
: "unexpectedOpeningLinebreak",
1001 type
: "ArrayExpression",
1006 messageId
: "unexpectedClosingLinebreak",
1007 type
: "ArrayExpression",
1014 code
: "var foo = [\n1, 2\n];",
1015 output
: "var foo = [1, 2];",
1016 options
: [{ multiline
: true }],
1019 messageId
: "unexpectedOpeningLinebreak",
1020 type
: "ArrayExpression",
1025 messageId
: "unexpectedClosingLinebreak",
1026 type
: "ArrayExpression",
1033 code
: "var foo = [1,\n2];",
1034 output
: "var foo = [\n1,\n2\n];",
1035 options
: [{ multiline
: true }],
1038 messageId
: "missingOpeningLinebreak",
1039 type
: "ArrayExpression",
1044 messageId
: "missingClosingLinebreak",
1045 type
: "ArrayExpression",
1052 code
: "var foo = [function foo() {\ndosomething();\n}];",
1053 output
: "var foo = [\nfunction foo() {\ndosomething();\n}\n];",
1054 options
: [{ multiline
: true }],
1057 messageId
: "missingOpeningLinebreak",
1058 type
: "ArrayExpression",
1063 messageId
: "missingClosingLinebreak",
1064 type
: "ArrayExpression",
1073 code
: "var foo = [1,[\n2,3\n]\n];",
1074 output
: "var foo = [\n1,[\n2,3\n]\n];",
1075 options
: [{ minItems
: 2 }],
1080 messageId
: "missingOpeningLinebreak",
1087 code
: "var foo = [[1,2\n]]",
1088 output
: "var foo = [[\n1,2\n]]",
1089 options
: [{ minItems
: 2 }],
1094 messageId
: "missingOpeningLinebreak",
1101 code
: "var foo = [\n];",
1102 output
: "var foo = [];",
1103 options
: [{ minItems
: 2 }],
1106 messageId
: "unexpectedOpeningLinebreak",
1107 type
: "ArrayExpression",
1112 messageId
: "unexpectedClosingLinebreak",
1113 type
: "ArrayExpression",
1120 code
: "var foo = [\n1\n];",
1121 output
: "var foo = [1];",
1122 options
: [{ minItems
: 2 }],
1125 messageId
: "unexpectedOpeningLinebreak",
1126 type
: "ArrayExpression",
1131 messageId
: "unexpectedClosingLinebreak",
1132 type
: "ArrayExpression",
1139 code
: "var foo = [1, 2];",
1140 output
: "var foo = [\n1, 2\n];",
1141 options
: [{ minItems
: 2 }],
1144 messageId
: "missingOpeningLinebreak",
1145 type
: "ArrayExpression",
1150 messageId
: "missingClosingLinebreak",
1151 type
: "ArrayExpression",
1158 code
: "var foo = [1,\n2];",
1159 output
: "var foo = [\n1,\n2\n];",
1160 options
: [{ minItems
: 2 }],
1163 messageId
: "missingOpeningLinebreak",
1164 type
: "ArrayExpression",
1169 messageId
: "missingClosingLinebreak",
1170 type
: "ArrayExpression",
1177 code
: "var foo = [\nfunction foo() {\ndosomething();\n}\n];",
1178 output
: "var foo = [function foo() {\ndosomething();\n}];",
1179 options
: [{ minItems
: 2 }],
1182 messageId
: "unexpectedOpeningLinebreak",
1183 type
: "ArrayExpression",
1188 messageId
: "unexpectedClosingLinebreak",
1189 type
: "ArrayExpression",
1198 code
: "var foo = [];",
1199 output
: "var foo = [\n];",
1200 options
: [{ minItems
: 0 }],
1203 messageId
: "missingOpeningLinebreak",
1204 type
: "ArrayExpression",
1209 messageId
: "missingClosingLinebreak",
1210 type
: "ArrayExpression",
1217 code
: "var foo = [1];",
1218 output
: "var foo = [\n1\n];",
1219 options
: [{ minItems
: 0 }],
1222 messageId
: "missingOpeningLinebreak",
1223 type
: "ArrayExpression",
1228 messageId
: "missingClosingLinebreak",
1229 type
: "ArrayExpression",
1236 code
: "var foo = [1, 2];",
1237 output
: "var foo = [\n1, 2\n];",
1238 options
: [{ minItems
: 0 }],
1241 messageId
: "missingOpeningLinebreak",
1242 type
: "ArrayExpression",
1247 messageId
: "missingClosingLinebreak",
1248 type
: "ArrayExpression",
1255 code
: "var foo = [1,\n2];",
1256 output
: "var foo = [\n1,\n2\n];",
1257 options
: [{ minItems
: 0 }],
1260 messageId
: "missingOpeningLinebreak",
1261 type
: "ArrayExpression",
1266 messageId
: "missingClosingLinebreak",
1267 type
: "ArrayExpression",
1274 code
: "var foo = [function foo() {\ndosomething();\n}];",
1275 output
: "var foo = [\nfunction foo() {\ndosomething();\n}\n];",
1276 options
: [{ minItems
: 0 }],
1279 messageId
: "missingOpeningLinebreak",
1280 type
: "ArrayExpression",
1285 messageId
: "missingClosingLinebreak",
1286 type
: "ArrayExpression",
1293 // { minItems: null }
1295 code
: "var foo = [\n];",
1296 output
: "var foo = [];",
1297 options
: [{ minItems
: null }],
1300 messageId
: "unexpectedOpeningLinebreak",
1301 type
: "ArrayExpression",
1306 messageId
: "unexpectedClosingLinebreak",
1307 type
: "ArrayExpression",
1314 code
: "var foo = [\n1\n];",
1315 output
: "var foo = [1];",
1316 options
: [{ minItems
: null }],
1319 messageId
: "unexpectedOpeningLinebreak",
1320 type
: "ArrayExpression",
1325 messageId
: "unexpectedClosingLinebreak",
1326 type
: "ArrayExpression",
1333 code
: "var foo = [\n1, 2\n];",
1334 output
: "var foo = [1, 2];",
1335 options
: [{ minItems
: null }],
1338 messageId
: "unexpectedOpeningLinebreak",
1339 type
: "ArrayExpression",
1344 messageId
: "unexpectedClosingLinebreak",
1345 type
: "ArrayExpression",
1352 code
: "var foo = [\n1,\n2\n];",
1353 output
: "var foo = [1,\n2];",
1354 options
: [{ minItems
: null }],
1357 messageId
: "unexpectedOpeningLinebreak",
1358 type
: "ArrayExpression",
1363 messageId
: "unexpectedClosingLinebreak",
1364 type
: "ArrayExpression",
1371 code
: "var foo = [\nfunction foo() {\ndosomething();\n}\n];",
1372 output
: "var foo = [function foo() {\ndosomething();\n}];",
1373 options
: [{ minItems
: null }],
1376 messageId
: "unexpectedOpeningLinebreak",
1377 type
: "ArrayExpression",
1382 messageId
: "unexpectedClosingLinebreak",
1383 type
: "ArrayExpression",
1390 // { multiline: true, minItems: null }
1392 code
: "var foo = [\n];",
1393 output
: "var foo = [];",
1394 options
: [{ multiline
: true, minItems
: null }],
1397 messageId
: "unexpectedOpeningLinebreak",
1398 type
: "ArrayExpression",
1403 messageId
: "unexpectedClosingLinebreak",
1404 type
: "ArrayExpression",
1411 code
: "var foo = [\n1\n];",
1412 output
: "var foo = [1];",
1413 options
: [{ multiline
: true, minItems
: null }],
1416 messageId
: "unexpectedOpeningLinebreak",
1417 type
: "ArrayExpression",
1422 messageId
: "unexpectedClosingLinebreak",
1423 type
: "ArrayExpression",
1430 code
: "var foo = [\n1, 2\n];",
1431 output
: "var foo = [1, 2];",
1432 options
: [{ multiline
: true, minItems
: null }],
1435 messageId
: "unexpectedOpeningLinebreak",
1436 type
: "ArrayExpression",
1441 messageId
: "unexpectedClosingLinebreak",
1442 type
: "ArrayExpression",
1449 code
: "var foo = [1,\n2];",
1450 output
: "var foo = [\n1,\n2\n];",
1451 options
: [{ multiline
: true, minItems
: null }],
1454 messageId
: "missingOpeningLinebreak",
1455 type
: "ArrayExpression",
1460 messageId
: "missingClosingLinebreak",
1461 type
: "ArrayExpression",
1468 code
: "var foo = [function foo() {\ndosomething();\n}];",
1469 output
: "var foo = [\nfunction foo() {\ndosomething();\n}\n];",
1470 options
: [{ multiline
: true, minItems
: null }],
1473 messageId
: "missingOpeningLinebreak",
1474 type
: "ArrayExpression",
1479 messageId
: "missingClosingLinebreak",
1480 type
: "ArrayExpression",
1487 // { multiline: true, minItems: 2 }
1489 code
: "var foo = [\n];",
1490 output
: "var foo = [];",
1491 options
: [{ multiline
: true, minItems
: 2 }],
1494 messageId
: "unexpectedOpeningLinebreak",
1495 type
: "ArrayExpression",
1500 messageId
: "unexpectedClosingLinebreak",
1501 type
: "ArrayExpression",
1508 code
: "var foo = [\n1\n];",
1509 output
: "var foo = [1];",
1510 options
: [{ multiline
: true, minItems
: 2 }],
1513 messageId
: "unexpectedOpeningLinebreak",
1514 type
: "ArrayExpression",
1519 messageId
: "unexpectedClosingLinebreak",
1520 type
: "ArrayExpression",
1527 code
: "var foo = [1, 2];",
1528 output
: "var foo = [\n1, 2\n];",
1529 options
: [{ multiline
: true, minItems
: 2 }],
1532 messageId
: "missingOpeningLinebreak",
1533 type
: "ArrayExpression",
1538 messageId
: "missingClosingLinebreak",
1539 type
: "ArrayExpression",
1546 code
: "var foo = [1,\n2];",
1547 output
: "var foo = [\n1,\n2\n];",
1548 options
: [{ multiline
: true, minItems
: 2 }],
1551 messageId
: "missingOpeningLinebreak",
1552 type
: "ArrayExpression",
1557 messageId
: "missingClosingLinebreak",
1558 type
: "ArrayExpression",
1565 code
: "var foo = [function foo() {\ndosomething();\n}];",
1566 output
: "var foo = [\nfunction foo() {\ndosomething();\n}\n];",
1567 options
: [{ multiline
: true, minItems
: 2 }],
1570 messageId
: "missingOpeningLinebreak",
1571 type
: "ArrayExpression",
1576 messageId
: "missingClosingLinebreak",
1577 type
: "ArrayExpression",
1589 code
: "var foo = [\n1, 2];",
1590 output
: "var foo = [\n1, 2\n];",
1591 options
: ["always"],
1594 messageId
: "missingClosingLinebreak",
1595 type
: "ArrayExpression",
1602 code
: "var foo = [\t1, 2];",
1603 output
: "var foo = [\n\t1, 2\n];",
1604 options
: ["always"],
1607 messageId
: "missingOpeningLinebreak",
1608 type
: "ArrayExpression",
1613 messageId
: "missingClosingLinebreak",
1614 type
: "ArrayExpression",
1621 code
: "var foo = [1,\n2\n];",
1622 output
: "var foo = [\n1,\n2\n];",
1623 options
: ["always"],
1626 messageId
: "missingOpeningLinebreak",
1627 type
: "ArrayExpression",
1634 // { multiline: false }
1636 code
: "var foo = [\n];",
1637 output
: "var foo = [];",
1638 options
: [{ multiline
: false }],
1641 messageId
: "unexpectedOpeningLinebreak",
1642 type
: "ArrayExpression",
1647 messageId
: "unexpectedClosingLinebreak",
1648 type
: "ArrayExpression",
1655 code
: "var foo = [\n1\n];",
1656 output
: "var foo = [1];",
1657 options
: [{ multiline
: false }],
1660 messageId
: "unexpectedOpeningLinebreak",
1661 type
: "ArrayExpression",
1666 messageId
: "unexpectedClosingLinebreak",
1667 type
: "ArrayExpression",
1674 code
: "var foo = [\n1, 2\n];",
1675 output
: "var foo = [1, 2];",
1676 options
: [{ multiline
: false }],
1679 messageId
: "unexpectedOpeningLinebreak",
1680 type
: "ArrayExpression",
1685 messageId
: "unexpectedClosingLinebreak",
1686 type
: "ArrayExpression",
1693 code
: "var foo = [\n1,\n2\n];",
1694 output
: "var foo = [1,\n2];",
1695 options
: [{ multiline
: false }],
1698 messageId
: "unexpectedOpeningLinebreak",
1699 type
: "ArrayExpression",
1704 messageId
: "unexpectedClosingLinebreak",
1705 type
: "ArrayExpression",
1712 code
: "var foo = [\nfunction foo() {\ndosomething();\n}\n];",
1713 output
: "var foo = [function foo() {\ndosomething();\n}];",
1714 options
: [{ multiline
: false }],
1717 messageId
: "unexpectedOpeningLinebreak",
1718 type
: "ArrayExpression",
1723 messageId
: "unexpectedClosingLinebreak",
1724 type
: "ArrayExpression",
1736 code
: "var [] = foo;",
1737 output
: "var [\n] = foo;",
1738 options
: ["always"],
1739 parserOptions
: { ecmaVersion
: 6 },
1742 messageId
: "missingOpeningLinebreak",
1743 type
: "ArrayPattern",
1748 messageId
: "missingClosingLinebreak",
1749 type
: "ArrayPattern",
1756 code
: "var [a] = foo;",
1757 output
: "var [\na\n] = foo;",
1758 options
: ["always"],
1759 parserOptions
: { ecmaVersion
: 6 },
1762 messageId
: "missingOpeningLinebreak",
1763 type
: "ArrayPattern",
1768 messageId
: "missingClosingLinebreak",
1769 type
: "ArrayPattern",
1776 code
: "var [ // any comment\na] = foo;",
1777 output
: "var [ // any comment\na\n] = foo;",
1778 options
: ["always"],
1779 parserOptions
: { ecmaVersion
: 6 },
1782 messageId
: "missingClosingLinebreak",
1783 type
: "ArrayPattern",
1790 code
: "var [ /* any comment */\na] = foo;",
1791 output
: "var [ /* any comment */\na\n] = foo;",
1792 options
: ["always"],
1793 parserOptions
: { ecmaVersion
: 6 },
1796 messageId
: "missingClosingLinebreak",
1797 type
: "ArrayPattern",
1804 code
: "var [a, b] = foo;",
1805 output
: "var [\na, b\n] = foo;",
1806 options
: ["always"],
1807 parserOptions
: { ecmaVersion
: 6 },
1810 messageId
: "missingOpeningLinebreak",
1811 type
: "ArrayPattern",
1816 messageId
: "missingClosingLinebreak",
1817 type
: "ArrayPattern",
1824 code
: "var [a, b // any comment\n] = foo;",
1825 output
: "var [\na, b // any comment\n] = foo;",
1826 options
: ["always"],
1827 parserOptions
: { ecmaVersion
: 6 },
1830 messageId
: "missingOpeningLinebreak",
1831 type
: "ArrayPattern",
1838 code
: "var [a, b /* any comment */] = foo;",
1839 output
: "var [\na, b /* any comment */\n] = foo;",
1840 options
: ["always"],
1841 parserOptions
: { ecmaVersion
: 6 },
1844 messageId
: "missingOpeningLinebreak",
1845 type
: "ArrayPattern",
1850 messageId
: "missingClosingLinebreak",
1851 type
: "ArrayPattern",
1858 code
: "var [a,\nb] = foo;",
1859 output
: "var [\na,\nb\n] = foo;",
1860 options
: ["always"],
1861 parserOptions
: { ecmaVersion
: 6 },
1864 messageId
: "missingOpeningLinebreak",
1865 type
: "ArrayPattern",
1870 messageId
: "missingClosingLinebreak",
1871 type
: "ArrayPattern",
1880 code
: "var [\na] = foo",
1881 output
: "var [\na\n] = foo",
1882 options
: ["consistent"],
1883 parserOptions
: { ecmaVersion
: 6 },
1886 messageId
: "missingClosingLinebreak",
1887 type
: "ArrayPattern",
1896 code
: "var [a\n] = foo",
1897 output
: "var [a] = foo",
1898 options
: ["consistent"],
1899 parserOptions
: { ecmaVersion
: 6 },
1902 messageId
: "unexpectedClosingLinebreak",
1903 type
: "ArrayPattern",
1912 code
: "var [//\na] = foo",
1913 output
: "var [//\na\n] = foo",
1914 options
: ["consistent"],
1915 parserOptions
: { ecmaVersion
: 6 },
1918 messageId
: "missingClosingLinebreak",
1919 type
: "ArrayPattern",
1930 code
: "var [\n] = foo;",
1931 output
: "var [] = foo;",
1932 options
: [{ minItems
: 2 }],
1933 parserOptions
: { ecmaVersion
: 6 },
1936 messageId
: "unexpectedOpeningLinebreak",
1937 type
: "ArrayPattern",
1942 messageId
: "unexpectedClosingLinebreak",
1943 type
: "ArrayPattern",
1950 code
: "var [\na\n] = foo;",
1951 output
: "var [a] = foo;",
1952 options
: [{ minItems
: 2 }],
1953 parserOptions
: { ecmaVersion
: 6 },
1956 messageId
: "unexpectedOpeningLinebreak",
1957 type
: "ArrayPattern",
1962 messageId
: "unexpectedClosingLinebreak",
1963 type
: "ArrayPattern",
1970 code
: "var [a, b] = foo;",
1971 output
: "var [\na, b\n] = foo;",
1972 options
: [{ minItems
: 2 }],
1973 parserOptions
: { ecmaVersion
: 6 },
1976 messageId
: "missingOpeningLinebreak",
1977 type
: "ArrayPattern",
1982 messageId
: "missingClosingLinebreak",
1983 type
: "ArrayPattern",
1990 code
: "var [a,\nb] = foo;",
1991 output
: "var [\na,\nb\n] = foo;",
1992 options
: [{ minItems
: 2 }],
1993 parserOptions
: { ecmaVersion
: 6 },
1996 messageId
: "missingOpeningLinebreak",
1997 type
: "ArrayPattern",
2002 messageId
: "missingClosingLinebreak",
2003 type
: "ArrayPattern",