Skip to content

Commit 8aba0cd

Browse files
committed
- jslint-bugfix - Fix false-warning about ordering in nested-object-destructuring.
1 parent 1049202 commit 8aba0cd

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

jslint.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5746,6 +5746,7 @@ function jslint_phase3_parse(state) {
57465746
the_function_toplevel
57475747
) {
57485748
const is_brace = token_now.id === "{";
5749+
const sub_list = [];
57495750
const the_destructure = token_now;
57505751
let optional;
57515752
function advance_and_signature_push(id) {
@@ -5761,7 +5762,7 @@ function jslint_phase3_parse(state) {
57615762
}
57625763
}
57635764
function name_list_push(name) {
5764-
name_list.push(name);
5765+
sub_list.push(name);
57655766

57665767
// PR-500 - Fix false-warning "uninitialized_a" in statement ";[aa]=0;".
57675768

@@ -5937,6 +5938,7 @@ function jslint_phase3_parse(state) {
59375938
}
59385939
advance_and_signature_push(",");
59395940
}
5941+
name_list.push(...sub_list);
59405942
if (the_function_toplevel) {
59415943
advance_and_signature_push(")");
59425944
} else if (is_brace) {
@@ -5947,7 +5949,7 @@ function jslint_phase3_parse(state) {
59475949
// ", "check_ordered", "expected_a_b_before_c_d", "aa", 17]
59485950
// ["let{bb,aa}=0", "check_ordered", "expected_a_b_before_c_d", "aa", 8]
59495951

5950-
check_ordered(role, name_list);
5952+
check_ordered(role, sub_list);
59515953
advance_and_signature_push("}");
59525954
} else {
59535955
advance_and_signature_push("]");

test.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -701,10 +701,10 @@ jstestDescribe((
701701
].map(function (source) {
702702
source = source.replace("{expr}", (
703703
`[{\n`
704-
+ ` aa,\n`
705-
+ ` bb = 0,\n`
706-
+ ` bb: cc,\n`
707-
+ ` dd: [{dd}],\n`
704+
+ ` bb,\n`
705+
+ ` cc = 0,\n`
706+
+ ` cc: dd,\n`
707+
+ ` dd: [{aa}],\n`
708708
+ ` ...zz\n`
709709
+ `}]`
710710
));

0 commit comments

Comments
 (0)