]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/rules/sort-keys.js
2 * @fileoverview Tests for sort-keys rule.
3 * @author Toru Nagashima
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
12 const rule
= require("../../../lib/rules/sort-keys"),
13 { RuleTester
} = require("../../../lib/rule-tester");
15 //------------------------------------------------------------------------------
17 //------------------------------------------------------------------------------
19 const ruleTester
= new RuleTester();
21 ruleTester
.run("sort-keys", rule
, {
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 } },
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 } },
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 } },
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 } },
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 } },
62 // ignore destructuring patterns.
63 { code
: "let {a, b} = {}", options
: [], parserOptions
: { ecmaVersion
: 6 } },
66 { code
: "var obj = {a:1, b:{x:1, y:1}, c:1}", options
: [] },
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"] },
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 }] },
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 }] },
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 }] },
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 }] },
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 }] },
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 }] },
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 }] },
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"] },
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 }] },
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 }] },
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 }] },
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 }] },
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 }] },
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 }] },
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 }] },
168 // allowLineSeparatedGroups option
181 options
: ["asc", { allowLineSeparatedGroups
: true }]
193 options
: ["asc", { allowLineSeparatedGroups
: true }]
207 options
: ["asc", { allowLineSeparatedGroups
: true }]
220 options
: ["asc", { allowLineSeparatedGroups
: true }],
221 parserOptions
: { ecmaVersion
: 6 }
236 options
: ["asc", { allowLineSeparatedGroups
: true }],
237 parserOptions
: { ecmaVersion
: 6 }
248 options
: ["asc", { allowLineSeparatedGroups
: true }],
249 parserOptions
: { ecmaVersion
: 6 }
272 options
: ["asc", { allowLineSeparatedGroups
: true }],
273 parserOptions
: { ecmaVersion
: 6 }
283 options
: ["asc", { allowLineSeparatedGroups
: true }]
295 options
: ["asc", { allowLineSeparatedGroups
: true }],
296 parserOptions
: { ecmaVersion
: 6 }
308 options
: ["asc", { allowLineSeparatedGroups
: true }],
309 parserOptions
: { ecmaVersion
: 6 }
319 options
: ["asc", { allowLineSeparatedGroups
: true }],
320 parserOptions
: { ecmaVersion
: 6 }
326 // comment before comma
332 options
: ["asc", { allowLineSeparatedGroups
: true }],
333 parserOptions
: { ecmaVersion
: 6 }
345 options
: ["asc", { allowLineSeparatedGroups
: true }],
346 parserOptions
: { ecmaVersion
: 2018 }
359 options
: ["asc", { allowLineSeparatedGroups
: true }],
360 parserOptions
: { ecmaVersion
: 2018 }
367 code
: "var obj = {a:1, '':2} // default",
370 messageId
: "sortKeys",
382 code
: "var obj = {a:1, [``]:2} // default",
383 parserOptions
: { ecmaVersion
: 6 },
386 messageId
: "sortKeys",
398 code
: "var obj = {a:1, _:2, b:3} // default",
401 messageId
: "sortKeys",
413 code
: "var obj = {a:1, c:2, b:3}",
416 messageId
: "sortKeys",
428 code
: "var obj = {b_:1, a:2, b:3}",
431 messageId
: "sortKeys",
443 code
: "var obj = {b_:1, c:2, C:3}",
446 messageId
: "sortKeys",
458 code
: "var obj = {$:1, _:2, A:3, a:4}",
461 messageId
: "sortKeys",
473 code
: "var obj = {1:1, 2:4, A:3, '11':2}",
476 messageId
: "sortKeys",
488 code
: "var obj = {'#':1, À:3, 'Z':2, è:4}",
491 messageId
: "sortKeys",
503 code
: "var obj = { null: 1, [/(?<zero>0)/]: 2 }",
504 parserOptions
: { ecmaVersion
: 2018 },
507 messageId
: "sortKeys",
512 thisName
: "/(?<zero>0)/",
519 // not ignore properties not separated by spread properties
521 code
: "var obj = {...z, c:1, b:1}",
523 parserOptions
: { ecmaVersion
: 2018 },
526 messageId
: "sortKeys",
538 code
: "var obj = {...z, ...c, d:4, b:1, ...y, ...f, e:2, a:1}",
540 parserOptions
: { ecmaVersion
: 2018 },
543 messageId
: "sortKeys",
553 messageId
: "sortKeys",
565 code
: "var obj = {c:1, b:1, ...a}",
567 parserOptions
: { ecmaVersion
: 2018 },
570 messageId
: "sortKeys",
582 code
: "var obj = {...z, ...a, c:1, b:1}",
584 parserOptions
: { ecmaVersion
: 2018 },
587 messageId
: "sortKeys",
599 code
: "var obj = {...z, b:1, a:1, ...d, ...c}",
601 parserOptions
: { ecmaVersion
: 2018 },
604 messageId
: "sortKeys",
616 code
: "var obj = {...z, a:2, b:0, ...x, ...c}",
618 parserOptions
: { ecmaVersion
: 2018 },
621 messageId
: "sortKeys",
633 code
: "var obj = {...z, a:2, b:0, ...x}",
635 parserOptions
: { ecmaVersion
: 2018 },
638 messageId
: "sortKeys",
650 code
: "var obj = {...z, '':1, a:2}",
652 parserOptions
: { ecmaVersion
: 2018 },
655 messageId
: "sortKeys",
667 // ignore non-simple computed properties, but their position shouldn't affect other comparisons.
669 code
: "var obj = {a:1, [b+c]:2, '':3}",
670 parserOptions
: { ecmaVersion
: 6 },
673 messageId
: "sortKeys",
685 code
: "var obj = {'':1, [b+c]:2, a:3}",
687 parserOptions
: { ecmaVersion
: 6 },
690 messageId
: "sortKeys",
702 code
: "var obj = {b:1, [f()]:2, '':3, a:4}",
704 parserOptions
: { ecmaVersion
: 6 },
707 messageId
: "sortKeys",
719 // not ignore simple computed properties.
721 code
: "var obj = {a:1, b:3, [a]: -1, c:2}",
722 parserOptions
: { ecmaVersion
: 6 },
725 messageId
: "sortKeys",
739 code
: "var obj = {a:1, c:{y:1, x:1}, b:1}",
742 messageId
: "sortKeys",
752 messageId
: "sortKeys",
766 code
: "var obj = {a:1, _:2, b:3} // asc",
770 messageId
: "sortKeys",
782 code
: "var obj = {a:1, c:2, b:3}",
786 messageId
: "sortKeys",
798 code
: "var obj = {b_:1, a:2, b:3}",
802 messageId
: "sortKeys",
814 code
: "var obj = {b_:1, c:2, C:3}",
818 messageId
: "sortKeys",
830 code
: "var obj = {$:1, _:2, A:3, a:4}",
834 messageId
: "sortKeys",
846 code
: "var obj = {1:1, 2:4, A:3, '11':2}",
850 messageId
: "sortKeys",
862 code
: "var obj = {'#':1, À:3, 'Z':2, è:4}",
866 messageId
: "sortKeys",
878 // asc, minKeys should error when number of keys is greater than or equal to minKeys
880 code
: "var obj = {a:1, _:2, b:3}",
881 options
: ["asc", { minKeys
: 3 }],
884 messageId
: "sortKeys",
898 code
: "var obj = {a:1, _:2, b:3} // asc, insensitive",
899 options
: ["asc", { caseSensitive
: false }],
902 messageId
: "sortKeys",
905 insensitive
: "insensitive ",
914 code
: "var obj = {a:1, c:2, b:3}",
915 options
: ["asc", { caseSensitive
: false }],
918 messageId
: "sortKeys",
921 insensitive
: "insensitive ",
930 code
: "var obj = {b_:1, a:2, b:3}",
931 options
: ["asc", { caseSensitive
: false }],
934 messageId
: "sortKeys",
937 insensitive
: "insensitive ",
946 code
: "var obj = {$:1, A:3, _:2, a:4}",
947 options
: ["asc", { caseSensitive
: false }],
950 messageId
: "sortKeys",
953 insensitive
: "insensitive ",
962 code
: "var obj = {1:1, 2:4, A:3, '11':2}",
963 options
: ["asc", { caseSensitive
: false }],
966 messageId
: "sortKeys",
969 insensitive
: "insensitive ",
978 code
: "var obj = {'#':1, À:3, 'Z':2, è:4}",
979 options
: ["asc", { caseSensitive
: false }],
982 messageId
: "sortKeys",
985 insensitive
: "insensitive ",
994 // asc, insensitive, minKeys should error when number of keys is greater than or equal to minKeys
996 code
: "var obj = {a:1, _:2, b:3}",
997 options
: ["asc", { caseSensitive
: false, minKeys
: 3 }],
1000 messageId
: "sortKeys",
1003 insensitive
: "insensitive ",
1014 code
: "var obj = {a:1, _:2, b:3} // asc, natural",
1015 options
: ["asc", { natural
: true }],
1018 messageId
: "sortKeys",
1020 natural
: "natural ",
1030 code
: "var obj = {a:1, c:2, b:3}",
1031 options
: ["asc", { natural
: true }],
1034 messageId
: "sortKeys",
1036 natural
: "natural ",
1046 code
: "var obj = {b_:1, a:2, b:3}",
1047 options
: ["asc", { natural
: true }],
1050 messageId
: "sortKeys",
1052 natural
: "natural ",
1062 code
: "var obj = {b_:1, c:2, C:3}",
1063 options
: ["asc", { natural
: true }],
1066 messageId
: "sortKeys",
1068 natural
: "natural ",
1078 code
: "var obj = {$:1, A:3, _:2, a:4}",
1079 options
: ["asc", { natural
: true }],
1082 messageId
: "sortKeys",
1084 natural
: "natural ",
1094 code
: "var obj = {1:1, 2:4, A:3, '11':2}",
1095 options
: ["asc", { natural
: true }],
1098 messageId
: "sortKeys",
1100 natural
: "natural ",
1110 code
: "var obj = {'#':1, À:3, 'Z':2, è:4}",
1111 options
: ["asc", { natural
: true }],
1114 messageId
: "sortKeys",
1116 natural
: "natural ",
1126 // asc, natural, minKeys should error when number of keys is greater than or equal to minKeys
1128 code
: "var obj = {a:1, _:2, b:3}",
1129 options
: ["asc", { natural
: true, minKeys
: 2 }],
1132 messageId
: "sortKeys",
1134 natural
: "natural ",
1144 // asc, natural, insensitive
1146 code
: "var obj = {a:1, _:2, b:3} // asc, natural, insensitive",
1147 options
: ["asc", { natural
: true, caseSensitive
: false }],
1150 messageId
: "sortKeys",
1152 natural
: "natural ",
1153 insensitive
: "insensitive ",
1162 code
: "var obj = {a:1, c:2, b:3}",
1163 options
: ["asc", { natural
: true, caseSensitive
: false }],
1166 messageId
: "sortKeys",
1168 natural
: "natural ",
1169 insensitive
: "insensitive ",
1178 code
: "var obj = {b_:1, a:2, b:3}",
1179 options
: ["asc", { natural
: true, caseSensitive
: false }],
1182 messageId
: "sortKeys",
1184 natural
: "natural ",
1185 insensitive
: "insensitive ",
1194 code
: "var obj = {$:1, A:3, _:2, a:4}",
1195 options
: ["asc", { natural
: true, caseSensitive
: false }],
1198 messageId
: "sortKeys",
1200 natural
: "natural ",
1201 insensitive
: "insensitive ",
1210 code
: "var obj = {1:1, '11':2, 2:4, A:3}",
1211 options
: ["asc", { natural
: true, caseSensitive
: false }],
1214 messageId
: "sortKeys",
1216 natural
: "natural ",
1217 insensitive
: "insensitive ",
1226 code
: "var obj = {'#':1, À:3, 'Z':2, è:4}",
1227 options
: ["asc", { natural
: true, caseSensitive
: false }],
1230 messageId
: "sortKeys",
1232 natural
: "natural ",
1233 insensitive
: "insensitive ",
1242 // asc, natural, insensitive, minKeys should error when number of keys is greater than or equal to minKeys
1244 code
: "var obj = {a:1, _:2, b:3}",
1245 options
: ["asc", { natural
: true, caseSensitive
: false, minKeys
: 3 }],
1248 messageId
: "sortKeys",
1250 natural
: "natural ",
1251 insensitive
: "insensitive ",
1262 code
: "var obj = {'':1, a:'2'} // desc",
1266 messageId
: "sortKeys",
1278 code
: "var obj = {[``]:1, a:'2'} // desc",
1280 parserOptions
: { ecmaVersion
: 6 },
1283 messageId
: "sortKeys",
1295 code
: "var obj = {a:1, _:2, b:3} // desc",
1299 messageId
: "sortKeys",
1311 code
: "var obj = {a:1, c:2, b:3}",
1315 messageId
: "sortKeys",
1327 code
: "var obj = {b_:1, a:2, b:3}",
1331 messageId
: "sortKeys",
1343 code
: "var obj = {b_:1, c:2, C:3}",
1347 messageId
: "sortKeys",
1359 code
: "var obj = {$:1, _:2, A:3, a:4}",
1363 messageId
: "sortKeys",
1373 messageId
: "sortKeys",
1385 code
: "var obj = {1:1, 2:4, A:3, '11':2}",
1389 messageId
: "sortKeys",
1399 messageId
: "sortKeys",
1411 code
: "var obj = {'#':1, À:3, 'Z':2, è:4}",
1415 messageId
: "sortKeys",
1425 messageId
: "sortKeys",
1437 // desc, minKeys should error when number of keys is greater than or equal to minKeys
1439 code
: "var obj = {a:1, _:2, b:3}",
1440 options
: ["desc", { minKeys
: 3 }],
1443 messageId
: "sortKeys",
1455 // desc, insensitive
1457 code
: "var obj = {a:1, _:2, b:3} // desc, insensitive",
1458 options
: ["desc", { caseSensitive
: false }],
1461 messageId
: "sortKeys",
1464 insensitive
: "insensitive ",
1473 code
: "var obj = {a:1, c:2, b:3}",
1474 options
: ["desc", { caseSensitive
: false }],
1477 messageId
: "sortKeys",
1480 insensitive
: "insensitive ",
1489 code
: "var obj = {b_:1, a:2, b:3}",
1490 options
: ["desc", { caseSensitive
: false }],
1493 messageId
: "sortKeys",
1496 insensitive
: "insensitive ",
1505 code
: "var obj = {b_:1, c:2, C:3}",
1506 options
: ["desc", { caseSensitive
: false }],
1509 messageId
: "sortKeys",
1512 insensitive
: "insensitive ",
1521 code
: "var obj = {$:1, _:2, A:3, a:4}",
1522 options
: ["desc", { caseSensitive
: false }],
1525 messageId
: "sortKeys",
1528 insensitive
: "insensitive ",
1535 messageId
: "sortKeys",
1538 insensitive
: "insensitive ",
1547 code
: "var obj = {1:1, 2:4, A:3, '11':2}",
1548 options
: ["desc", { caseSensitive
: false }],
1551 messageId
: "sortKeys",
1554 insensitive
: "insensitive ",
1561 messageId
: "sortKeys",
1564 insensitive
: "insensitive ",
1573 code
: "var obj = {'#':1, À:3, 'Z':2, è:4}",
1574 options
: ["desc", { caseSensitive
: false }],
1577 messageId
: "sortKeys",
1580 insensitive
: "insensitive ",
1587 messageId
: "sortKeys",
1590 insensitive
: "insensitive ",
1599 // desc, insensitive should error when number of keys is greater than or equal to minKeys
1601 code
: "var obj = {a:1, _:2, b:3}",
1602 options
: ["desc", { caseSensitive
: false, minKeys
: 2 }],
1605 messageId
: "sortKeys",
1608 insensitive
: "insensitive ",
1619 code
: "var obj = {a:1, _:2, b:3} // desc, natural",
1620 options
: ["desc", { natural
: true }],
1623 messageId
: "sortKeys",
1625 natural
: "natural ",
1635 code
: "var obj = {a:1, c:2, b:3}",
1636 options
: ["desc", { natural
: true }],
1639 messageId
: "sortKeys",
1641 natural
: "natural ",
1651 code
: "var obj = {b_:1, a:2, b:3}",
1652 options
: ["desc", { natural
: true }],
1655 messageId
: "sortKeys",
1657 natural
: "natural ",
1667 code
: "var obj = {b_:1, c:2, C:3}",
1668 options
: ["desc", { natural
: true }],
1671 messageId
: "sortKeys",
1673 natural
: "natural ",
1683 code
: "var obj = {$:1, _:2, A:3, a:4}",
1684 options
: ["desc", { natural
: true }],
1687 messageId
: "sortKeys",
1689 natural
: "natural ",
1697 messageId
: "sortKeys",
1699 natural
: "natural ",
1707 messageId
: "sortKeys",
1709 natural
: "natural ",
1719 code
: "var obj = {1:1, 2:4, A:3, '11':2}",
1720 options
: ["desc", { natural
: true }],
1723 messageId
: "sortKeys",
1725 natural
: "natural ",
1733 messageId
: "sortKeys",
1735 natural
: "natural ",
1745 code
: "var obj = {'#':1, À:3, 'Z':2, è:4}",
1746 options
: ["desc", { natural
: true }],
1749 messageId
: "sortKeys",
1751 natural
: "natural ",
1759 messageId
: "sortKeys",
1761 natural
: "natural ",
1771 // desc, natural should error when number of keys is greater than or equal to minKeys
1773 code
: "var obj = {a:1, _:2, b:3}",
1774 options
: ["desc", { natural
: true, minKeys
: 3 }],
1777 messageId
: "sortKeys",
1779 natural
: "natural ",
1789 // desc, natural, insensitive
1791 code
: "var obj = {a:1, _:2, b:3} // desc, natural, insensitive",
1792 options
: ["desc", { natural
: true, caseSensitive
: false }],
1795 messageId
: "sortKeys",
1797 natural
: "natural ",
1798 insensitive
: "insensitive ",
1807 code
: "var obj = {a:1, c:2, b:3}",
1808 options
: ["desc", { natural
: true, caseSensitive
: false }],
1811 messageId
: "sortKeys",
1813 natural
: "natural ",
1814 insensitive
: "insensitive ",
1823 code
: "var obj = {b_:1, a:2, b:3}",
1824 options
: ["desc", { natural
: true, caseSensitive
: false }],
1827 messageId
: "sortKeys",
1829 natural
: "natural ",
1830 insensitive
: "insensitive ",
1839 code
: "var obj = {b_:1, c:2, C:3}",
1840 options
: ["desc", { natural
: true, caseSensitive
: false }],
1843 messageId
: "sortKeys",
1845 natural
: "natural ",
1846 insensitive
: "insensitive ",
1855 code
: "var obj = {$:1, _:2, A:3, a:4}",
1856 options
: ["desc", { natural
: true, caseSensitive
: false }],
1859 messageId
: "sortKeys",
1861 natural
: "natural ",
1862 insensitive
: "insensitive ",
1869 messageId
: "sortKeys",
1871 natural
: "natural ",
1872 insensitive
: "insensitive ",
1881 code
: "var obj = {1:1, 2:4, '11':2, A:3}",
1882 options
: ["desc", { natural
: true, caseSensitive
: false }],
1885 messageId
: "sortKeys",
1887 natural
: "natural ",
1888 insensitive
: "insensitive ",
1895 messageId
: "sortKeys",
1897 natural
: "natural ",
1898 insensitive
: "insensitive ",
1905 messageId
: "sortKeys",
1907 natural
: "natural ",
1908 insensitive
: "insensitive ",
1917 code
: "var obj = {'#':1, À:3, 'Z':2, è:4}",
1918 options
: ["desc", { natural
: true, caseSensitive
: false }],
1921 messageId
: "sortKeys",
1923 natural
: "natural ",
1924 insensitive
: "insensitive ",
1931 messageId
: "sortKeys",
1933 natural
: "natural ",
1934 insensitive
: "insensitive ",
1943 // desc, natural, insensitive should error when number of keys is greater than or equal to minKeys
1945 code
: "var obj = {a:1, _:2, b:3}",
1946 options
: ["desc", { natural
: true, caseSensitive
: false, minKeys
: 2 }],
1949 messageId
: "sortKeys",
1951 natural
: "natural ",
1952 insensitive
: "insensitive ",
1961 // When allowLineSeparatedGroups option is false
1970 options
: ["asc", { allowLineSeparatedGroups
: false }],
1973 messageId
: "sortKeys",
1992 options
: ["asc", { allowLineSeparatedGroups
: false }],
1993 parserOptions
: { ecmaVersion
: 6 },
1996 messageId
: "sortKeys",
2008 // When allowLineSeparatedGroups option is true
2019 options
: ["asc", { allowLineSeparatedGroups
: true }],
2020 parserOptions
: { ecmaVersion
: 6 },
2023 messageId
: "sortKeys",
2046 options
: ["asc", { allowLineSeparatedGroups
: true }],
2047 parserOptions
: { ecmaVersion
: 6 },
2050 messageId
: "sortKeys",
2071 options
: ["asc", { allowLineSeparatedGroups
: true }],
2072 parserOptions
: { ecmaVersion
: 6 },
2075 messageId
: "sortKeys",
2091 a // sort-keys: 'a' should be before 'b'
2094 options
: ["asc", { allowLineSeparatedGroups
: true }],
2095 parserOptions
: { ecmaVersion
: 6 },
2098 messageId
: "sortKeys",
2121 options
: ["asc", { allowLineSeparatedGroups
: true }],
2122 parserOptions
: { ecmaVersion
: 6 },
2125 messageId
: "sortKeys",
2155 options
: ["asc", { allowLineSeparatedGroups
: true }],
2156 parserOptions
: { ecmaVersion
: 6 },
2159 messageId
: "sortKeys",
2169 messageId
: "sortKeys",
2187 options
: ["asc", { allowLineSeparatedGroups
: true }],
2190 messageId
: "sortKeys",
2205 // comment before comma
2209 options
: ["asc", { allowLineSeparatedGroups
: true }],
2210 parserOptions
: { ecmaVersion
: 6 },
2213 messageId
: "sortKeys",
2229 // ↓ this blank is inside a property and therefore should not count
2235 options
: ["asc", { allowLineSeparatedGroups
: true }],
2236 parserOptions
: { ecmaVersion
: 2018 },
2239 messageId
: "sortKeys",