]> git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/rules/sort-keys.js
ff6482747ad9a50c82b216d1db9a8694da5d2206
[pve-eslint.git] / eslint / tests / lib / rules / sort-keys.js
1 /**
2 * @fileoverview Tests for sort-keys rule.
3 * @author Toru Nagashima
4 */
5
6 "use strict";
7
8 //------------------------------------------------------------------------------
9 // Requirements
10 //------------------------------------------------------------------------------
11
12 const rule = require("../../../lib/rules/sort-keys"),
13 { RuleTester } = require("../../../lib/rule-tester");
14
15 //------------------------------------------------------------------------------
16 // Tests
17 //------------------------------------------------------------------------------
18
19 const ruleTester = new RuleTester();
20
21 ruleTester.run("sort-keys", rule, {
22 valid: [
23
24 // default (asc)
25 { code: "var obj = {'':1, [``]:2}", options: [], parserOptions: { ecmaVersion: 6 } },
26 { code: "var obj = {[``]:1, '':2}", options: [], parserOptions: { ecmaVersion: 6 } },
27 { code: "var obj = {'':1, a:2}", options: [] },
28 { code: "var obj = {[``]:1, a:2}", options: [], parserOptions: { ecmaVersion: 6 } },
29 { code: "var obj = {_:2, a:1, b:3} // default", options: [] },
30 { code: "var obj = {a:1, b:3, c:2}", options: [] },
31 { code: "var obj = {a:2, b:3, b_:1}", options: [] },
32 { code: "var obj = {C:3, b_:1, c:2}", options: [] },
33 { code: "var obj = {$:1, A:3, _:2, a:4}", options: [] },
34 { code: "var obj = {1:1, '11':2, 2:4, A:3}", options: [] },
35 { code: "var obj = {'#':1, 'Z':2, À:3, è:4}", options: [] },
36 { code: "var obj = { [/(?<zero>0)/]: 1, '/(?<zero>0)/': 2 }", options: [], parserOptions: { ecmaVersion: 2018 } },
37
38 // ignore non-simple computed properties.
39 { code: "var obj = {a:1, b:3, [a + b]: -1, c:2}", options: [], parserOptions: { ecmaVersion: 6 } },
40 { code: "var obj = {'':1, [f()]:2, a:3}", options: [], parserOptions: { ecmaVersion: 6 } },
41 { code: "var obj = {a:1, [b++]:2, '':3}", options: ["desc"], parserOptions: { ecmaVersion: 6 } },
42
43 // ignore properties separated by spread properties
44 { code: "var obj = {a:1, ...z, b:1}", options: [], parserOptions: { ecmaVersion: 2018 } },
45 { code: "var obj = {b:1, ...z, a:1}", options: [], parserOptions: { ecmaVersion: 2018 } },
46 { code: "var obj = {...a, b:1, ...c, d:1}", options: [], parserOptions: { ecmaVersion: 2018 } },
47 { code: "var obj = {...a, b:1, ...d, ...c, e:2, z:5}", options: [], parserOptions: { ecmaVersion: 2018 } },
48 { code: "var obj = {b:1, ...c, ...d, e:2}", options: [], parserOptions: { ecmaVersion: 2018 } },
49 { code: "var obj = {a:1, ...z, '':2}", options: [], parserOptions: { ecmaVersion: 2018 } },
50 { code: "var obj = {'':1, ...z, 'a':2}", options: ["desc"], parserOptions: { ecmaVersion: 2018 } },
51
52 // not ignore properties not separated by spread properties
53 { code: "var obj = {...z, a:1, b:1}", options: [], parserOptions: { ecmaVersion: 2018 } },
54 { code: "var obj = {...z, ...c, a:1, b:1}", options: [], parserOptions: { ecmaVersion: 2018 } },
55 { code: "var obj = {a:1, b:1, ...z}", options: [], parserOptions: { ecmaVersion: 2018 } },
56 { code: "var obj = {...z, ...x, a:1, ...c, ...d, f:5, e:4}", options: ["desc"], parserOptions: { ecmaVersion: 2018 } },
57
58 // works when spread occurs somewhere other than an object literal
59 { code: "function fn(...args) { return [...args].length; }", options: [], parserOptions: { ecmaVersion: 2018 } },
60 { code: "function g() {}; function f(...args) { return g(...args); }", options: [], parserOptions: { ecmaVersion: 2018 } },
61
62 // ignore destructuring patterns.
63 { code: "let {a, b} = {}", options: [], parserOptions: { ecmaVersion: 6 } },
64
65 // nested
66 { code: "var obj = {a:1, b:{x:1, y:1}, c:1}", options: [] },
67
68 // asc
69 { code: "var obj = {_:2, a:1, b:3} // asc", options: ["asc"] },
70 { code: "var obj = {a:1, b:3, c:2}", options: ["asc"] },
71 { code: "var obj = {a:2, b:3, b_:1}", options: ["asc"] },
72 { code: "var obj = {C:3, b_:1, c:2}", options: ["asc"] },
73 { code: "var obj = {$:1, A:3, _:2, a:4}", options: ["asc"] },
74 { code: "var obj = {1:1, '11':2, 2:4, A:3}", options: ["asc"] },
75 { code: "var obj = {'#':1, 'Z':2, À:3, è:4}", options: ["asc"] },
76
77 // asc, minKeys should ignore unsorted keys when number of keys is less than minKeys
78 { code: "var obj = {a:1, c:2, b:3}", options: ["asc", { minKeys: 4 }] },
79
80 // asc, insensitive
81 { code: "var obj = {_:2, a:1, b:3} // asc, insensitive", options: ["asc", { caseSensitive: false }] },
82 { code: "var obj = {a:1, b:3, c:2}", options: ["asc", { caseSensitive: false }] },
83 { code: "var obj = {a:2, b:3, b_:1}", options: ["asc", { caseSensitive: false }] },
84 { code: "var obj = {b_:1, C:3, c:2}", options: ["asc", { caseSensitive: false }] },
85 { code: "var obj = {b_:1, c:3, C:2}", options: ["asc", { caseSensitive: false }] },
86 { code: "var obj = {$:1, _:2, A:3, a:4}", options: ["asc", { caseSensitive: false }] },
87 { code: "var obj = {1:1, '11':2, 2:4, A:3}", options: ["asc", { caseSensitive: false }] },
88 { code: "var obj = {'#':1, 'Z':2, À:3, è:4}", options: ["asc", { caseSensitive: false }] },
89
90 // asc, insensitive, minKeys should ignore unsorted keys when number of keys is less than minKeys
91 { code: "var obj = {$:1, A:3, _:2, a:4}", options: ["asc", { caseSensitive: false, minKeys: 5 }] },
92
93 // asc, natural
94 { code: "var obj = {_:2, a:1, b:3} // asc, natural", options: ["asc", { natural: true }] },
95 { code: "var obj = {a:1, b:3, c:2}", options: ["asc", { natural: true }] },
96 { code: "var obj = {a:2, b:3, b_:1}", options: ["asc", { natural: true }] },
97 { code: "var obj = {C:3, b_:1, c:2}", options: ["asc", { natural: true }] },
98 { code: "var obj = {$:1, _:2, A:3, a:4}", options: ["asc", { natural: true }] },
99 { code: "var obj = {1:1, 2:4, '11':2, A:3}", options: ["asc", { natural: true }] },
100 { code: "var obj = {'#':1, 'Z':2, À:3, è:4}", options: ["asc", { natural: true }] },
101
102 // asc, natural, minKeys should ignore unsorted keys when number of keys is less than minKeys
103 { code: "var obj = {b_:1, a:2, b:3}", options: ["asc", { natural: true, minKeys: 4 }] },
104
105 // asc, natural, insensitive
106 { code: "var obj = {_:2, a:1, b:3} // asc, natural, insensitive", options: ["asc", { natural: true, caseSensitive: false }] },
107 { code: "var obj = {a:1, b:3, c:2}", options: ["asc", { natural: true, caseSensitive: false }] },
108 { code: "var obj = {a:2, b:3, b_:1}", options: ["asc", { natural: true, caseSensitive: false }] },
109 { code: "var obj = {b_:1, C:3, c:2}", options: ["asc", { natural: true, caseSensitive: false }] },
110 { code: "var obj = {b_:1, c:3, C:2}", options: ["asc", { natural: true, caseSensitive: false }] },
111 { code: "var obj = {$:1, _:2, A:3, a:4}", options: ["asc", { natural: true, caseSensitive: false }] },
112 { code: "var obj = {1:1, 2:4, '11':2, A:3}", options: ["asc", { natural: true, caseSensitive: false }] },
113 { code: "var obj = {'#':1, 'Z':2, À:3, è:4}", options: ["asc", { natural: true, caseSensitive: false }] },
114
115 // asc, natural, insensitive, minKeys should ignore unsorted keys when number of keys is less than minKeys
116 { code: "var obj = {a:1, _:2, b:3}", options: ["asc", { natural: true, caseSensitive: false, minKeys: 4 }] },
117
118 // desc
119 { code: "var obj = {b:3, a:1, _:2} // desc", options: ["desc"] },
120 { code: "var obj = {c:2, b:3, a:1}", options: ["desc"] },
121 { code: "var obj = {b_:1, b:3, a:2}", options: ["desc"] },
122 { code: "var obj = {c:2, b_:1, C:3}", options: ["desc"] },
123 { code: "var obj = {a:4, _:2, A:3, $:1}", options: ["desc"] },
124 { code: "var obj = {A:3, 2:4, '11':2, 1:1}", options: ["desc"] },
125 { code: "var obj = {è:4, À:3, 'Z':2, '#':1}", options: ["desc"] },
126
127 // desc, minKeys should ignore unsorted keys when number of keys is less than minKeys
128 { code: "var obj = {a:1, c:2, b:3}", options: ["desc", { minKeys: 4 }] },
129
130 // desc, insensitive
131 { code: "var obj = {b:3, a:1, _:2} // desc, insensitive", options: ["desc", { caseSensitive: false }] },
132 { code: "var obj = {c:2, b:3, a:1}", options: ["desc", { caseSensitive: false }] },
133 { code: "var obj = {b_:1, b:3, a:2}", options: ["desc", { caseSensitive: false }] },
134 { code: "var obj = {c:2, C:3, b_:1}", options: ["desc", { caseSensitive: false }] },
135 { code: "var obj = {C:2, c:3, b_:1}", options: ["desc", { caseSensitive: false }] },
136 { code: "var obj = {a:4, A:3, _:2, $:1}", options: ["desc", { caseSensitive: false }] },
137 { code: "var obj = {A:3, 2:4, '11':2, 1:1}", options: ["desc", { caseSensitive: false }] },
138 { code: "var obj = {è:4, À:3, 'Z':2, '#':1}", options: ["desc", { caseSensitive: false }] },
139
140 // desc, insensitive, minKeys should ignore unsorted keys when number of keys is less than minKeys
141 { code: "var obj = {$:1, _:2, A:3, a:4}", options: ["desc", { caseSensitive: false, minKeys: 5 }] },
142
143 // desc, natural
144 { code: "var obj = {b:3, a:1, _:2} // desc, natural", options: ["desc", { natural: true }] },
145 { code: "var obj = {c:2, b:3, a:1}", options: ["desc", { natural: true }] },
146 { code: "var obj = {b_:1, b:3, a:2}", options: ["desc", { natural: true }] },
147 { code: "var obj = {c:2, b_:1, C:3}", options: ["desc", { natural: true }] },
148 { code: "var obj = {a:4, A:3, _:2, $:1}", options: ["desc", { natural: true }] },
149 { code: "var obj = {A:3, '11':2, 2:4, 1:1}", options: ["desc", { natural: true }] },
150 { code: "var obj = {è:4, À:3, 'Z':2, '#':1}", options: ["desc", { natural: true }] },
151
152 // desc, natural, minKeys should ignore unsorted keys when number of keys is less than minKeys
153 { code: "var obj = {b_:1, a:2, b:3}", options: ["desc", { natural: true, minKeys: 4 }] },
154
155 // desc, natural, insensitive
156 { code: "var obj = {b:3, a:1, _:2} // desc, natural, insensitive", options: ["desc", { natural: true, caseSensitive: false }] },
157 { code: "var obj = {c:2, b:3, a:1}", options: ["desc", { natural: true, caseSensitive: false }] },
158 { code: "var obj = {b_:1, b:3, a:2}", options: ["desc", { natural: true, caseSensitive: false }] },
159 { code: "var obj = {c:2, C:3, b_:1}", options: ["desc", { natural: true, caseSensitive: false }] },
160 { code: "var obj = {C:2, c:3, b_:1}", options: ["desc", { natural: true, caseSensitive: false }] },
161 { code: "var obj = {a:4, A:3, _:2, $:1}", options: ["desc", { natural: true, caseSensitive: false }] },
162 { code: "var obj = {A:3, '11':2, 2:4, 1:1}", options: ["desc", { natural: true, caseSensitive: false }] },
163 { code: "var obj = {è:4, À:3, 'Z':2, '#':1}", options: ["desc", { natural: true, caseSensitive: false }] },
164
165 // desc, natural, insensitive, minKeys should ignore unsorted keys when number of keys is less than minKeys
166 { code: "var obj = {a:1, _:2, b:3}", options: ["desc", { natural: true, caseSensitive: false, minKeys: 4 }] }
167 ],
168 invalid: [
169
170 // default (asc)
171 {
172 code: "var obj = {a:1, '':2} // default",
173 errors: [
174 {
175 messageId: "sortKeys",
176 data: {
177 natural: "",
178 insensitive: "",
179 order: "asc",
180 thisName: "",
181 prevName: "a"
182 }
183 }
184 ]
185 },
186 {
187 code: "var obj = {a:1, [``]:2} // default",
188 parserOptions: { ecmaVersion: 6 },
189 errors: [
190 {
191 messageId: "sortKeys",
192 data: {
193 natural: "",
194 insensitive: "",
195 order: "asc",
196 thisName: "",
197 prevName: "a"
198 }
199 }
200 ]
201 },
202 {
203 code: "var obj = {a:1, _:2, b:3} // default",
204 errors: [
205 {
206 messageId: "sortKeys",
207 data: {
208 natural: "",
209 insensitive: "",
210 order: "asc",
211 thisName: "_",
212 prevName: "a"
213 }
214 }
215 ]
216 },
217 {
218 code: "var obj = {a:1, c:2, b:3}",
219 errors: [
220 {
221 messageId: "sortKeys",
222 data: {
223 natural: "",
224 insensitive: "",
225 order: "asc",
226 thisName: "b",
227 prevName: "c"
228 }
229 }
230 ]
231 },
232 {
233 code: "var obj = {b_:1, a:2, b:3}",
234 errors: [
235 {
236 messageId: "sortKeys",
237 data: {
238 natural: "",
239 insensitive: "",
240 order: "asc",
241 thisName: "a",
242 prevName: "b_"
243 }
244 }
245 ]
246 },
247 {
248 code: "var obj = {b_:1, c:2, C:3}",
249 errors: [
250 {
251 messageId: "sortKeys",
252 data: {
253 natural: "",
254 insensitive: "",
255 order: "asc",
256 thisName: "C",
257 prevName: "c"
258 }
259 }
260 ]
261 },
262 {
263 code: "var obj = {$:1, _:2, A:3, a:4}",
264 errors: [
265 {
266 messageId: "sortKeys",
267 data: {
268 natural: "",
269 insensitive: "",
270 order: "asc",
271 thisName: "A",
272 prevName: "_"
273 }
274 }
275 ]
276 },
277 {
278 code: "var obj = {1:1, 2:4, A:3, '11':2}",
279 errors: [
280 {
281 messageId: "sortKeys",
282 data: {
283 natural: "",
284 insensitive: "",
285 order: "asc",
286 thisName: "11",
287 prevName: "A"
288 }
289 }
290 ]
291 },
292 {
293 code: "var obj = {'#':1, À:3, 'Z':2, è:4}",
294 errors: [
295 {
296 messageId: "sortKeys",
297 data: {
298 natural: "",
299 insensitive: "",
300 order: "asc",
301 thisName: "Z",
302 prevName: "À"
303 }
304 }
305 ]
306 },
307 {
308 code: "var obj = { null: 1, [/(?<zero>0)/]: 2 }",
309 parserOptions: { ecmaVersion: 2018 },
310 errors: [
311 {
312 messageId: "sortKeys",
313 data: {
314 natural: "",
315 insensitive: "",
316 order: "asc",
317 thisName: "/(?<zero>0)/",
318 prevName: "null"
319 }
320 }
321 ]
322 },
323
324 // not ignore properties not separated by spread properties
325 {
326 code: "var obj = {...z, c:1, b:1}",
327 options: [],
328 parserOptions: { ecmaVersion: 2018 },
329 errors: [
330 {
331 messageId: "sortKeys",
332 data: {
333 natural: "",
334 insensitive: "",
335 order: "asc",
336 thisName: "b",
337 prevName: "c"
338 }
339 }
340 ]
341 },
342 {
343 code: "var obj = {...z, ...c, d:4, b:1, ...y, ...f, e:2, a:1}",
344 options: [],
345 parserOptions: { ecmaVersion: 2018 },
346 errors: [
347 {
348 messageId: "sortKeys",
349 data: {
350 natural: "",
351 insensitive: "",
352 order: "asc",
353 thisName: "b",
354 prevName: "d"
355 }
356 },
357 {
358 messageId: "sortKeys",
359 data: {
360 natural: "",
361 insensitive: "",
362 order: "asc",
363 thisName: "a",
364 prevName: "e"
365 }
366 }
367 ]
368 },
369 {
370 code: "var obj = {c:1, b:1, ...a}",
371 options: [],
372 parserOptions: { ecmaVersion: 2018 },
373 errors: [
374 {
375 messageId: "sortKeys",
376 data: {
377 natural: "",
378 insensitive: "",
379 order: "asc",
380 thisName: "b",
381 prevName: "c"
382 }
383 }
384 ]
385 },
386 {
387 code: "var obj = {...z, ...a, c:1, b:1}",
388 options: [],
389 parserOptions: { ecmaVersion: 2018 },
390 errors: [
391 {
392 messageId: "sortKeys",
393 data: {
394 natural: "",
395 insensitive: "",
396 order: "asc",
397 thisName: "b",
398 prevName: "c"
399 }
400 }
401 ]
402 },
403 {
404 code: "var obj = {...z, b:1, a:1, ...d, ...c}",
405 options: [],
406 parserOptions: { ecmaVersion: 2018 },
407 errors: [
408 {
409 messageId: "sortKeys",
410 data: {
411 natural: "",
412 insensitive: "",
413 order: "asc",
414 thisName: "a",
415 prevName: "b"
416 }
417 }
418 ]
419 },
420 {
421 code: "var obj = {...z, a:2, b:0, ...x, ...c}",
422 options: ["desc"],
423 parserOptions: { ecmaVersion: 2018 },
424 errors: [
425 {
426 messageId: "sortKeys",
427 data: {
428 natural: "",
429 insensitive: "",
430 order: "desc",
431 thisName: "b",
432 prevName: "a"
433 }
434 }
435 ]
436 },
437 {
438 code: "var obj = {...z, a:2, b:0, ...x}",
439 options: ["desc"],
440 parserOptions: { ecmaVersion: 2018 },
441 errors: [
442 {
443 messageId: "sortKeys",
444 data: {
445 natural: "",
446 insensitive: "",
447 order: "desc",
448 thisName: "b",
449 prevName: "a"
450 }
451 }
452 ]
453 },
454 {
455 code: "var obj = {...z, '':1, a:2}",
456 options: ["desc"],
457 parserOptions: { ecmaVersion: 2018 },
458 errors: [
459 {
460 messageId: "sortKeys",
461 data: {
462 natural: "",
463 insensitive: "",
464 order: "desc",
465 thisName: "a",
466 prevName: ""
467 }
468 }
469 ]
470 },
471
472 // ignore non-simple computed properties, but their position shouldn't affect other comparisons.
473 {
474 code: "var obj = {a:1, [b+c]:2, '':3}",
475 parserOptions: { ecmaVersion: 6 },
476 errors: [
477 {
478 messageId: "sortKeys",
479 data: {
480 natural: "",
481 insensitive: "",
482 order: "asc",
483 thisName: "",
484 prevName: "a"
485 }
486 }
487 ]
488 },
489 {
490 code: "var obj = {'':1, [b+c]:2, a:3}",
491 options: ["desc"],
492 parserOptions: { ecmaVersion: 6 },
493 errors: [
494 {
495 messageId: "sortKeys",
496 data: {
497 natural: "",
498 insensitive: "",
499 order: "desc",
500 thisName: "a",
501 prevName: ""
502 }
503 }
504 ]
505 },
506 {
507 code: "var obj = {b:1, [f()]:2, '':3, a:4}",
508 options: ["desc"],
509 parserOptions: { ecmaVersion: 6 },
510 errors: [
511 {
512 messageId: "sortKeys",
513 data: {
514 natural: "",
515 insensitive: "",
516 order: "desc",
517 thisName: "a",
518 prevName: ""
519 }
520 }
521 ]
522 },
523
524 // not ignore simple computed properties.
525 {
526 code: "var obj = {a:1, b:3, [a]: -1, c:2}",
527 parserOptions: { ecmaVersion: 6 },
528 errors: [
529 {
530 messageId: "sortKeys",
531 data: {
532 natural: "",
533 insensitive: "",
534 order: "asc",
535 thisName: "a",
536 prevName: "b"
537 }
538 }
539 ]
540 },
541
542 // nested
543 {
544 code: "var obj = {a:1, c:{y:1, x:1}, b:1}",
545 errors: [
546 {
547 messageId: "sortKeys",
548 data: {
549 natural: "",
550 insensitive: "",
551 order: "asc",
552 thisName: "x",
553 prevName: "y"
554 }
555 },
556 {
557 messageId: "sortKeys",
558 data: {
559 natural: "",
560 insensitive: "",
561 order: "asc",
562 thisName: "b",
563 prevName: "c"
564 }
565 }
566 ]
567 },
568
569 // asc
570 {
571 code: "var obj = {a:1, _:2, b:3} // asc",
572 options: ["asc"],
573 errors: [
574 {
575 messageId: "sortKeys",
576 data: {
577 natural: "",
578 insensitive: "",
579 order: "asc",
580 thisName: "_",
581 prevName: "a"
582 }
583 }
584 ]
585 },
586 {
587 code: "var obj = {a:1, c:2, b:3}",
588 options: ["asc"],
589 errors: [
590 {
591 messageId: "sortKeys",
592 data: {
593 natural: "",
594 insensitive: "",
595 order: "asc",
596 thisName: "b",
597 prevName: "c"
598 }
599 }
600 ]
601 },
602 {
603 code: "var obj = {b_:1, a:2, b:3}",
604 options: ["asc"],
605 errors: [
606 {
607 messageId: "sortKeys",
608 data: {
609 natural: "",
610 insensitive: "",
611 order: "asc",
612 thisName: "a",
613 prevName: "b_"
614 }
615 }
616 ]
617 },
618 {
619 code: "var obj = {b_:1, c:2, C:3}",
620 options: ["asc"],
621 errors: [
622 {
623 messageId: "sortKeys",
624 data: {
625 natural: "",
626 insensitive: "",
627 order: "asc",
628 thisName: "C",
629 prevName: "c"
630 }
631 }
632 ]
633 },
634 {
635 code: "var obj = {$:1, _:2, A:3, a:4}",
636 options: ["asc"],
637 errors: [
638 {
639 messageId: "sortKeys",
640 data: {
641 natural: "",
642 insensitive: "",
643 order: "asc",
644 thisName: "A",
645 prevName: "_"
646 }
647 }
648 ]
649 },
650 {
651 code: "var obj = {1:1, 2:4, A:3, '11':2}",
652 options: ["asc"],
653 errors: [
654 {
655 messageId: "sortKeys",
656 data: {
657 natural: "",
658 insensitive: "",
659 order: "asc",
660 thisName: "11",
661 prevName: "A"
662 }
663 }
664 ]
665 },
666 {
667 code: "var obj = {'#':1, À:3, 'Z':2, è:4}",
668 options: ["asc"],
669 errors: [
670 {
671 messageId: "sortKeys",
672 data: {
673 natural: "",
674 insensitive: "",
675 order: "asc",
676 thisName: "Z",
677 prevName: "À"
678 }
679 }
680 ]
681 },
682
683 // asc, minKeys should error when number of keys is greater than or equal to minKeys
684 {
685 code: "var obj = {a:1, _:2, b:3}",
686 options: ["asc", { minKeys: 3 }],
687 errors: [
688 {
689 messageId: "sortKeys",
690 data: {
691 natural: "",
692 insensitive: "",
693 order: "asc",
694 thisName: "_",
695 prevName: "a"
696 }
697 }
698 ]
699 },
700
701 // asc, insensitive
702 {
703 code: "var obj = {a:1, _:2, b:3} // asc, insensitive",
704 options: ["asc", { caseSensitive: false }],
705 errors: [
706 {
707 messageId: "sortKeys",
708 data: {
709 natural: "",
710 insensitive: "insensitive ",
711 order: "asc",
712 thisName: "_",
713 prevName: "a"
714 }
715 }
716 ]
717 },
718 {
719 code: "var obj = {a:1, c:2, b:3}",
720 options: ["asc", { caseSensitive: false }],
721 errors: [
722 {
723 messageId: "sortKeys",
724 data: {
725 natural: "",
726 insensitive: "insensitive ",
727 order: "asc",
728 thisName: "b",
729 prevName: "c"
730 }
731 }
732 ]
733 },
734 {
735 code: "var obj = {b_:1, a:2, b:3}",
736 options: ["asc", { caseSensitive: false }],
737 errors: [
738 {
739 messageId: "sortKeys",
740 data: {
741 natural: "",
742 insensitive: "insensitive ",
743 order: "asc",
744 thisName: "a",
745 prevName: "b_"
746 }
747 }
748 ]
749 },
750 {
751 code: "var obj = {$:1, A:3, _:2, a:4}",
752 options: ["asc", { caseSensitive: false }],
753 errors: [
754 {
755 messageId: "sortKeys",
756 data: {
757 natural: "",
758 insensitive: "insensitive ",
759 order: "asc",
760 thisName: "_",
761 prevName: "A"
762 }
763 }
764 ]
765 },
766 {
767 code: "var obj = {1:1, 2:4, A:3, '11':2}",
768 options: ["asc", { caseSensitive: false }],
769 errors: [
770 {
771 messageId: "sortKeys",
772 data: {
773 natural: "",
774 insensitive: "insensitive ",
775 order: "asc",
776 thisName: "11",
777 prevName: "A"
778 }
779 }
780 ]
781 },
782 {
783 code: "var obj = {'#':1, À:3, 'Z':2, è:4}",
784 options: ["asc", { caseSensitive: false }],
785 errors: [
786 {
787 messageId: "sortKeys",
788 data: {
789 natural: "",
790 insensitive: "insensitive ",
791 order: "asc",
792 thisName: "Z",
793 prevName: "À"
794 }
795 }
796 ]
797 },
798
799 // asc, insensitive, minKeys should error when number of keys is greater than or equal to minKeys
800 {
801 code: "var obj = {a:1, _:2, b:3}",
802 options: ["asc", { caseSensitive: false, minKeys: 3 }],
803 errors: [
804 {
805 messageId: "sortKeys",
806 data: {
807 natural: "",
808 insensitive: "insensitive ",
809 order: "asc",
810 thisName: "_",
811 prevName: "a"
812 }
813 }
814 ]
815 },
816
817 // asc, natural
818 {
819 code: "var obj = {a:1, _:2, b:3} // asc, natural",
820 options: ["asc", { natural: true }],
821 errors: [
822 {
823 messageId: "sortKeys",
824 data: {
825 natural: "natural ",
826 insensitive: "",
827 order: "asc",
828 thisName: "_",
829 prevName: "a"
830 }
831 }
832 ]
833 },
834 {
835 code: "var obj = {a:1, c:2, b:3}",
836 options: ["asc", { natural: true }],
837 errors: [
838 {
839 messageId: "sortKeys",
840 data: {
841 natural: "natural ",
842 insensitive: "",
843 order: "asc",
844 thisName: "b",
845 prevName: "c"
846 }
847 }
848 ]
849 },
850 {
851 code: "var obj = {b_:1, a:2, b:3}",
852 options: ["asc", { natural: true }],
853 errors: [
854 {
855 messageId: "sortKeys",
856 data: {
857 natural: "natural ",
858 insensitive: "",
859 order: "asc",
860 thisName: "a",
861 prevName: "b_"
862 }
863 }
864 ]
865 },
866 {
867 code: "var obj = {b_:1, c:2, C:3}",
868 options: ["asc", { natural: true }],
869 errors: [
870 {
871 messageId: "sortKeys",
872 data: {
873 natural: "natural ",
874 insensitive: "",
875 order: "asc",
876 thisName: "C",
877 prevName: "c"
878 }
879 }
880 ]
881 },
882 {
883 code: "var obj = {$:1, A:3, _:2, a:4}",
884 options: ["asc", { natural: true }],
885 errors: [
886 {
887 messageId: "sortKeys",
888 data: {
889 natural: "natural ",
890 insensitive: "",
891 order: "asc",
892 thisName: "_",
893 prevName: "A"
894 }
895 }
896 ]
897 },
898 {
899 code: "var obj = {1:1, 2:4, A:3, '11':2}",
900 options: ["asc", { natural: true }],
901 errors: [
902 {
903 messageId: "sortKeys",
904 data: {
905 natural: "natural ",
906 insensitive: "",
907 order: "asc",
908 thisName: "11",
909 prevName: "A"
910 }
911 }
912 ]
913 },
914 {
915 code: "var obj = {'#':1, À:3, 'Z':2, è:4}",
916 options: ["asc", { natural: true }],
917 errors: [
918 {
919 messageId: "sortKeys",
920 data: {
921 natural: "natural ",
922 insensitive: "",
923 order: "asc",
924 thisName: "Z",
925 prevName: "À"
926 }
927 }
928 ]
929 },
930
931 // asc, natural, minKeys should error when number of keys is greater than or equal to minKeys
932 {
933 code: "var obj = {a:1, _:2, b:3}",
934 options: ["asc", { natural: true, minKeys: 2 }],
935 errors: [
936 {
937 messageId: "sortKeys",
938 data: {
939 natural: "natural ",
940 insensitive: "",
941 order: "asc",
942 thisName: "_",
943 prevName: "a"
944 }
945 }
946 ]
947 },
948
949 // asc, natural, insensitive
950 {
951 code: "var obj = {a:1, _:2, b:3} // asc, natural, insensitive",
952 options: ["asc", { natural: true, caseSensitive: false }],
953 errors: [
954 {
955 messageId: "sortKeys",
956 data: {
957 natural: "natural ",
958 insensitive: "insensitive ",
959 order: "asc",
960 thisName: "_",
961 prevName: "a"
962 }
963 }
964 ]
965 },
966 {
967 code: "var obj = {a:1, c:2, b:3}",
968 options: ["asc", { natural: true, caseSensitive: false }],
969 errors: [
970 {
971 messageId: "sortKeys",
972 data: {
973 natural: "natural ",
974 insensitive: "insensitive ",
975 order: "asc",
976 thisName: "b",
977 prevName: "c"
978 }
979 }
980 ]
981 },
982 {
983 code: "var obj = {b_:1, a:2, b:3}",
984 options: ["asc", { natural: true, caseSensitive: false }],
985 errors: [
986 {
987 messageId: "sortKeys",
988 data: {
989 natural: "natural ",
990 insensitive: "insensitive ",
991 order: "asc",
992 thisName: "a",
993 prevName: "b_"
994 }
995 }
996 ]
997 },
998 {
999 code: "var obj = {$:1, A:3, _:2, a:4}",
1000 options: ["asc", { natural: true, caseSensitive: false }],
1001 errors: [
1002 {
1003 messageId: "sortKeys",
1004 data: {
1005 natural: "natural ",
1006 insensitive: "insensitive ",
1007 order: "asc",
1008 thisName: "_",
1009 prevName: "A"
1010 }
1011 }
1012 ]
1013 },
1014 {
1015 code: "var obj = {1:1, '11':2, 2:4, A:3}",
1016 options: ["asc", { natural: true, caseSensitive: false }],
1017 errors: [
1018 {
1019 messageId: "sortKeys",
1020 data: {
1021 natural: "natural ",
1022 insensitive: "insensitive ",
1023 order: "asc",
1024 thisName: "2",
1025 prevName: "11"
1026 }
1027 }
1028 ]
1029 },
1030 {
1031 code: "var obj = {'#':1, À:3, 'Z':2, è:4}",
1032 options: ["asc", { natural: true, caseSensitive: false }],
1033 errors: [
1034 {
1035 messageId: "sortKeys",
1036 data: {
1037 natural: "natural ",
1038 insensitive: "insensitive ",
1039 order: "asc",
1040 thisName: "Z",
1041 prevName: "À"
1042 }
1043 }
1044 ]
1045 },
1046
1047 // asc, natural, insensitive, minKeys should error when number of keys is greater than or equal to minKeys
1048 {
1049 code: "var obj = {a:1, _:2, b:3}",
1050 options: ["asc", { natural: true, caseSensitive: false, minKeys: 3 }],
1051 errors: [
1052 {
1053 messageId: "sortKeys",
1054 data: {
1055 natural: "natural ",
1056 insensitive: "insensitive ",
1057 order: "asc",
1058 thisName: "_",
1059 prevName: "a"
1060 }
1061 }
1062 ]
1063 },
1064
1065 // desc
1066 {
1067 code: "var obj = {'':1, a:'2'} // desc",
1068 options: ["desc"],
1069 errors: [
1070 {
1071 messageId: "sortKeys",
1072 data: {
1073 natural: "",
1074 insensitive: "",
1075 order: "desc",
1076 thisName: "a",
1077 prevName: ""
1078 }
1079 }
1080 ]
1081 },
1082 {
1083 code: "var obj = {[``]:1, a:'2'} // desc",
1084 options: ["desc"],
1085 parserOptions: { ecmaVersion: 6 },
1086 errors: [
1087 {
1088 messageId: "sortKeys",
1089 data: {
1090 natural: "",
1091 insensitive: "",
1092 order: "desc",
1093 thisName: "a",
1094 prevName: ""
1095 }
1096 }
1097 ]
1098 },
1099 {
1100 code: "var obj = {a:1, _:2, b:3} // desc",
1101 options: ["desc"],
1102 errors: [
1103 {
1104 messageId: "sortKeys",
1105 data: {
1106 natural: "",
1107 insensitive: "",
1108 order: "desc",
1109 thisName: "b",
1110 prevName: "_"
1111 }
1112 }
1113 ]
1114 },
1115 {
1116 code: "var obj = {a:1, c:2, b:3}",
1117 options: ["desc"],
1118 errors: [
1119 {
1120 messageId: "sortKeys",
1121 data: {
1122 natural: "",
1123 insensitive: "",
1124 order: "desc",
1125 thisName: "c",
1126 prevName: "a"
1127 }
1128 }
1129 ]
1130 },
1131 {
1132 code: "var obj = {b_:1, a:2, b:3}",
1133 options: ["desc"],
1134 errors: [
1135 {
1136 messageId: "sortKeys",
1137 data: {
1138 natural: "",
1139 insensitive: "",
1140 order: "desc",
1141 thisName: "b",
1142 prevName: "a"
1143 }
1144 }
1145 ]
1146 },
1147 {
1148 code: "var obj = {b_:1, c:2, C:3}",
1149 options: ["desc"],
1150 errors: [
1151 {
1152 messageId: "sortKeys",
1153 data: {
1154 natural: "",
1155 insensitive: "",
1156 order: "desc",
1157 thisName: "c",
1158 prevName: "b_"
1159 }
1160 }
1161 ]
1162 },
1163 {
1164 code: "var obj = {$:1, _:2, A:3, a:4}",
1165 options: ["desc"],
1166 errors: [
1167 {
1168 messageId: "sortKeys",
1169 data: {
1170 natural: "",
1171 insensitive: "",
1172 order: "desc",
1173 thisName: "_",
1174 prevName: "$"
1175 }
1176 },
1177 {
1178 messageId: "sortKeys",
1179 data: {
1180 natural: "",
1181 insensitive: "",
1182 order: "desc",
1183 thisName: "a",
1184 prevName: "A"
1185 }
1186 }
1187 ]
1188 },
1189 {
1190 code: "var obj = {1:1, 2:4, A:3, '11':2}",
1191 options: ["desc"],
1192 errors: [
1193 {
1194 messageId: "sortKeys",
1195 data: {
1196 natural: "",
1197 insensitive: "",
1198 order: "desc",
1199 thisName: "2",
1200 prevName: "1"
1201 }
1202 },
1203 {
1204 messageId: "sortKeys",
1205 data: {
1206 natural: "",
1207 insensitive: "",
1208 order: "desc",
1209 thisName: "A",
1210 prevName: "2"
1211 }
1212 }
1213 ]
1214 },
1215 {
1216 code: "var obj = {'#':1, À:3, 'Z':2, è:4}",
1217 options: ["desc"],
1218 errors: [
1219 {
1220 messageId: "sortKeys",
1221 data: {
1222 natural: "",
1223 insensitive: "",
1224 order: "desc",
1225 thisName: "À",
1226 prevName: "#"
1227 }
1228 },
1229 {
1230 messageId: "sortKeys",
1231 data: {
1232 natural: "",
1233 insensitive: "",
1234 order: "desc",
1235 thisName: "è",
1236 prevName: "Z"
1237 }
1238 }
1239 ]
1240 },
1241
1242 // desc, minKeys should error when number of keys is greater than or equal to minKeys
1243 {
1244 code: "var obj = {a:1, _:2, b:3}",
1245 options: ["desc", { minKeys: 3 }],
1246 errors: [
1247 {
1248 messageId: "sortKeys",
1249 data: {
1250 natural: "",
1251 insensitive: "",
1252 order: "desc",
1253 thisName: "b",
1254 prevName: "_"
1255 }
1256 }
1257 ]
1258 },
1259
1260 // desc, insensitive
1261 {
1262 code: "var obj = {a:1, _:2, b:3} // desc, insensitive",
1263 options: ["desc", { caseSensitive: false }],
1264 errors: [
1265 {
1266 messageId: "sortKeys",
1267 data: {
1268 natural: "",
1269 insensitive: "insensitive ",
1270 order: "desc",
1271 thisName: "b",
1272 prevName: "_"
1273 }
1274 }
1275 ]
1276 },
1277 {
1278 code: "var obj = {a:1, c:2, b:3}",
1279 options: ["desc", { caseSensitive: false }],
1280 errors: [
1281 {
1282 messageId: "sortKeys",
1283 data: {
1284 natural: "",
1285 insensitive: "insensitive ",
1286 order: "desc",
1287 thisName: "c",
1288 prevName: "a"
1289 }
1290 }
1291 ]
1292 },
1293 {
1294 code: "var obj = {b_:1, a:2, b:3}",
1295 options: ["desc", { caseSensitive: false }],
1296 errors: [
1297 {
1298 messageId: "sortKeys",
1299 data: {
1300 natural: "",
1301 insensitive: "insensitive ",
1302 order: "desc",
1303 thisName: "b",
1304 prevName: "a"
1305 }
1306 }
1307 ]
1308 },
1309 {
1310 code: "var obj = {b_:1, c:2, C:3}",
1311 options: ["desc", { caseSensitive: false }],
1312 errors: [
1313 {
1314 messageId: "sortKeys",
1315 data: {
1316 natural: "",
1317 insensitive: "insensitive ",
1318 order: "desc",
1319 thisName: "c",
1320 prevName: "b_"
1321 }
1322 }
1323 ]
1324 },
1325 {
1326 code: "var obj = {$:1, _:2, A:3, a:4}",
1327 options: ["desc", { caseSensitive: false }],
1328 errors: [
1329 {
1330 messageId: "sortKeys",
1331 data: {
1332 natural: "",
1333 insensitive: "insensitive ",
1334 order: "desc",
1335 thisName: "_",
1336 prevName: "$"
1337 }
1338 },
1339 {
1340 messageId: "sortKeys",
1341 data: {
1342 natural: "",
1343 insensitive: "insensitive ",
1344 order: "desc",
1345 thisName: "A",
1346 prevName: "_"
1347 }
1348 }
1349 ]
1350 },
1351 {
1352 code: "var obj = {1:1, 2:4, A:3, '11':2}",
1353 options: ["desc", { caseSensitive: false }],
1354 errors: [
1355 {
1356 messageId: "sortKeys",
1357 data: {
1358 natural: "",
1359 insensitive: "insensitive ",
1360 order: "desc",
1361 thisName: "2",
1362 prevName: "1"
1363 }
1364 },
1365 {
1366 messageId: "sortKeys",
1367 data: {
1368 natural: "",
1369 insensitive: "insensitive ",
1370 order: "desc",
1371 thisName: "A",
1372 prevName: "2"
1373 }
1374 }
1375 ]
1376 },
1377 {
1378 code: "var obj = {'#':1, À:3, 'Z':2, è:4}",
1379 options: ["desc", { caseSensitive: false }],
1380 errors: [
1381 {
1382 messageId: "sortKeys",
1383 data: {
1384 natural: "",
1385 insensitive: "insensitive ",
1386 order: "desc",
1387 thisName: "À",
1388 prevName: "#"
1389 }
1390 },
1391 {
1392 messageId: "sortKeys",
1393 data: {
1394 natural: "",
1395 insensitive: "insensitive ",
1396 order: "desc",
1397 thisName: "è",
1398 prevName: "Z"
1399 }
1400 }
1401 ]
1402 },
1403
1404 // desc, insensitive should error when number of keys is greater than or equal to minKeys
1405 {
1406 code: "var obj = {a:1, _:2, b:3}",
1407 options: ["desc", { caseSensitive: false, minKeys: 2 }],
1408 errors: [
1409 {
1410 messageId: "sortKeys",
1411 data: {
1412 natural: "",
1413 insensitive: "insensitive ",
1414 order: "desc",
1415 thisName: "b",
1416 prevName: "_"
1417 }
1418 }
1419 ]
1420 },
1421
1422 // desc, natural
1423 {
1424 code: "var obj = {a:1, _:2, b:3} // desc, natural",
1425 options: ["desc", { natural: true }],
1426 errors: [
1427 {
1428 messageId: "sortKeys",
1429 data: {
1430 natural: "natural ",
1431 insensitive: "",
1432 order: "desc",
1433 thisName: "b",
1434 prevName: "_"
1435 }
1436 }
1437 ]
1438 },
1439 {
1440 code: "var obj = {a:1, c:2, b:3}",
1441 options: ["desc", { natural: true }],
1442 errors: [
1443 {
1444 messageId: "sortKeys",
1445 data: {
1446 natural: "natural ",
1447 insensitive: "",
1448 order: "desc",
1449 thisName: "c",
1450 prevName: "a"
1451 }
1452 }
1453 ]
1454 },
1455 {
1456 code: "var obj = {b_:1, a:2, b:3}",
1457 options: ["desc", { natural: true }],
1458 errors: [
1459 {
1460 messageId: "sortKeys",
1461 data: {
1462 natural: "natural ",
1463 insensitive: "",
1464 order: "desc",
1465 thisName: "b",
1466 prevName: "a"
1467 }
1468 }
1469 ]
1470 },
1471 {
1472 code: "var obj = {b_:1, c:2, C:3}",
1473 options: ["desc", { natural: true }],
1474 errors: [
1475 {
1476 messageId: "sortKeys",
1477 data: {
1478 natural: "natural ",
1479 insensitive: "",
1480 order: "desc",
1481 thisName: "c",
1482 prevName: "b_"
1483 }
1484 }
1485 ]
1486 },
1487 {
1488 code: "var obj = {$:1, _:2, A:3, a:4}",
1489 options: ["desc", { natural: true }],
1490 errors: [
1491 {
1492 messageId: "sortKeys",
1493 data: {
1494 natural: "natural ",
1495 insensitive: "",
1496 order: "desc",
1497 thisName: "_",
1498 prevName: "$"
1499 }
1500 },
1501 {
1502 messageId: "sortKeys",
1503 data: {
1504 natural: "natural ",
1505 insensitive: "",
1506 order: "desc",
1507 thisName: "A",
1508 prevName: "_"
1509 }
1510 },
1511 {
1512 messageId: "sortKeys",
1513 data: {
1514 natural: "natural ",
1515 insensitive: "",
1516 order: "desc",
1517 thisName: "a",
1518 prevName: "A"
1519 }
1520 }
1521 ]
1522 },
1523 {
1524 code: "var obj = {1:1, 2:4, A:3, '11':2}",
1525 options: ["desc", { natural: true }],
1526 errors: [
1527 {
1528 messageId: "sortKeys",
1529 data: {
1530 natural: "natural ",
1531 insensitive: "",
1532 order: "desc",
1533 thisName: "2",
1534 prevName: "1"
1535 }
1536 },
1537 {
1538 messageId: "sortKeys",
1539 data: {
1540 natural: "natural ",
1541 insensitive: "",
1542 order: "desc",
1543 thisName: "A",
1544 prevName: "2"
1545 }
1546 }
1547 ]
1548 },
1549 {
1550 code: "var obj = {'#':1, À:3, 'Z':2, è:4}",
1551 options: ["desc", { natural: true }],
1552 errors: [
1553 {
1554 messageId: "sortKeys",
1555 data: {
1556 natural: "natural ",
1557 insensitive: "",
1558 order: "desc",
1559 thisName: "À",
1560 prevName: "#"
1561 }
1562 },
1563 {
1564 messageId: "sortKeys",
1565 data: {
1566 natural: "natural ",
1567 insensitive: "",
1568 order: "desc",
1569 thisName: "è",
1570 prevName: "Z"
1571 }
1572 }
1573 ]
1574 },
1575
1576 // desc, natural should error when number of keys is greater than or equal to minKeys
1577 {
1578 code: "var obj = {a:1, _:2, b:3}",
1579 options: ["desc", { natural: true, minKeys: 3 }],
1580 errors: [
1581 {
1582 messageId: "sortKeys",
1583 data: {
1584 natural: "natural ",
1585 insensitive: "",
1586 order: "desc",
1587 thisName: "b",
1588 prevName: "_"
1589 }
1590 }
1591 ]
1592 },
1593
1594 // desc, natural, insensitive
1595 {
1596 code: "var obj = {a:1, _:2, b:3} // desc, natural, insensitive",
1597 options: ["desc", { natural: true, caseSensitive: false }],
1598 errors: [
1599 {
1600 messageId: "sortKeys",
1601 data: {
1602 natural: "natural ",
1603 insensitive: "insensitive ",
1604 order: "desc",
1605 thisName: "b",
1606 prevName: "_"
1607 }
1608 }
1609 ]
1610 },
1611 {
1612 code: "var obj = {a:1, c:2, b:3}",
1613 options: ["desc", { natural: true, caseSensitive: false }],
1614 errors: [
1615 {
1616 messageId: "sortKeys",
1617 data: {
1618 natural: "natural ",
1619 insensitive: "insensitive ",
1620 order: "desc",
1621 thisName: "c",
1622 prevName: "a"
1623 }
1624 }
1625 ]
1626 },
1627 {
1628 code: "var obj = {b_:1, a:2, b:3}",
1629 options: ["desc", { natural: true, caseSensitive: false }],
1630 errors: [
1631 {
1632 messageId: "sortKeys",
1633 data: {
1634 natural: "natural ",
1635 insensitive: "insensitive ",
1636 order: "desc",
1637 thisName: "b",
1638 prevName: "a"
1639 }
1640 }
1641 ]
1642 },
1643 {
1644 code: "var obj = {b_:1, c:2, C:3}",
1645 options: ["desc", { natural: true, caseSensitive: false }],
1646 errors: [
1647 {
1648 messageId: "sortKeys",
1649 data: {
1650 natural: "natural ",
1651 insensitive: "insensitive ",
1652 order: "desc",
1653 thisName: "c",
1654 prevName: "b_"
1655 }
1656 }
1657 ]
1658 },
1659 {
1660 code: "var obj = {$:1, _:2, A:3, a:4}",
1661 options: ["desc", { natural: true, caseSensitive: false }],
1662 errors: [
1663 {
1664 messageId: "sortKeys",
1665 data: {
1666 natural: "natural ",
1667 insensitive: "insensitive ",
1668 order: "desc",
1669 thisName: "_",
1670 prevName: "$"
1671 }
1672 },
1673 {
1674 messageId: "sortKeys",
1675 data: {
1676 natural: "natural ",
1677 insensitive: "insensitive ",
1678 order: "desc",
1679 thisName: "A",
1680 prevName: "_"
1681 }
1682 }
1683 ]
1684 },
1685 {
1686 code: "var obj = {1:1, 2:4, '11':2, A:3}",
1687 options: ["desc", { natural: true, caseSensitive: false }],
1688 errors: [
1689 {
1690 messageId: "sortKeys",
1691 data: {
1692 natural: "natural ",
1693 insensitive: "insensitive ",
1694 order: "desc",
1695 thisName: "2",
1696 prevName: "1"
1697 }
1698 },
1699 {
1700 messageId: "sortKeys",
1701 data: {
1702 natural: "natural ",
1703 insensitive: "insensitive ",
1704 order: "desc",
1705 thisName: "11",
1706 prevName: "2"
1707 }
1708 },
1709 {
1710 messageId: "sortKeys",
1711 data: {
1712 natural: "natural ",
1713 insensitive: "insensitive ",
1714 order: "desc",
1715 thisName: "A",
1716 prevName: "11"
1717 }
1718 }
1719 ]
1720 },
1721 {
1722 code: "var obj = {'#':1, À:3, 'Z':2, è:4}",
1723 options: ["desc", { natural: true, caseSensitive: false }],
1724 errors: [
1725 {
1726 messageId: "sortKeys",
1727 data: {
1728 natural: "natural ",
1729 insensitive: "insensitive ",
1730 order: "desc",
1731 thisName: "À",
1732 prevName: "#"
1733 }
1734 },
1735 {
1736 messageId: "sortKeys",
1737 data: {
1738 natural: "natural ",
1739 insensitive: "insensitive ",
1740 order: "desc",
1741 thisName: "è",
1742 prevName: "Z"
1743 }
1744 }
1745 ]
1746 },
1747
1748 // desc, natural, insensitive should error when number of keys is greater than or equal to minKeys
1749 {
1750 code: "var obj = {a:1, _:2, b:3}",
1751 options: ["desc", { natural: true, caseSensitive: false, minKeys: 2 }],
1752 errors: [
1753 {
1754 messageId: "sortKeys",
1755 data: {
1756 natural: "natural ",
1757 insensitive: "insensitive ",
1758 order: "desc",
1759 thisName: "b",
1760 prevName: "_"
1761 }
1762 }
1763 ]
1764 }
1765 ]
1766 });