Skip to content

Commit bfcfdcc

Browse files
chore(deps): update babel to v7.24.8 (#16472)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: fisker <[email protected]>
1 parent 977c161 commit bfcfdcc

File tree

10 files changed

+295
-34
lines changed

10 files changed

+295
-34
lines changed

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"dependencies": {
3333
"@angular/compiler": "18.1.0",
3434
"@babel/code-frame": "7.24.7",
35-
"@babel/parser": "7.24.7",
36-
"@babel/types": "7.24.7",
35+
"@babel/parser": "7.24.8",
36+
"@babel/types": "7.24.8",
3737
"@glimmer/syntax": "0.92.0",
3838
"@iarna/toml": "2.2.5",
3939
"@prettier/is-es5-identifier-name": "0.2.0",
@@ -105,7 +105,7 @@
105105
"yaml-unist-parser": "2.0.1"
106106
},
107107
"devDependencies": {
108-
"@babel/generator": "7.24.7",
108+
"@babel/generator": "7.24.8",
109109
"@eslint/compat": "1.0.3",
110110
"@eslint/eslintrc": "3.1.0",
111111
"@eslint/js": "9.5.0",

src/language-js/needs-parens.js

+18
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,24 @@ function needsParens(path, options) {
288288
return true;
289289
}
290290
break;
291+
292+
case "VariableDeclarator":
293+
// Legacy syntax
294+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Invalid_for-in_initializer
295+
// `for (var a = 1 in b);`
296+
if (
297+
key === "init" &&
298+
path.match(
299+
undefined,
300+
undefined,
301+
(node, key) =>
302+
key === "declarations" && node.type === "VariableDeclaration",
303+
(node, key) => key === "left" && node.type === "ForInStatement",
304+
)
305+
) {
306+
return true;
307+
}
308+
break;
291309
}
292310

293311
switch (node.type) {

src/language-js/parse/babel.js

+1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ const allowedReasonCodes = new Set([
174174
"StrictEvalArguments",
175175
"StrictEvalArgumentsBinding",
176176
"StrictFunction",
177+
"ForInOfLoopInitializer",
177178

178179
"EmptyTypeArguments",
179180
"EmptyTypeParameters",

tests/format/js/for/__snapshots__/format.test.js.snap

+188
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,71 @@ for (var i = 0; i < 10; ++i) 0;
799799
================================================================================
800800
`;
801801

802+
exports[`for-in-with-initializer.js [flow] format 1`] = `
803+
"Invalid left-hand side in for-in (3:6)
804+
1 | // https://github.com/babel/babel/blob/HEAD/packages/babel-generator/test/fixtures/parentheses/in-inside-for/input.js
805+
2 |
806+
> 3 | for (var a = (b in c) in {});
807+
| ^^^^^^^^^^^^^^^^
808+
4 | for (var a = 1 || (b in c) in {});
809+
5 | for (var a = 1 + (2 || (b in c)) in {});
810+
6 | for (var a = (() => b in c) in {});"
811+
`;
812+
813+
exports[`for-in-with-initializer.js [typescript] format 1`] = `
814+
"',' expected. (9:17)
815+
7 | for (var a = 1 || (() => b in c) in {});
816+
8 | for (var a = (() => { b in c; }) in {});
817+
> 9 | for (var a = [b in c] in {});
818+
| ^
819+
10 | for (var a = {b: b in c} in {});
820+
11 | // Meriyah can't parse
821+
12 | // for (var a = (x = b in c) => {} in {});
822+
Cause: ',' expected."
823+
`;
824+
825+
exports[`for-in-with-initializer.js format 1`] = `
826+
====================================options=====================================
827+
parsers: ["babel", "flow", "typescript"]
828+
printWidth: 80
829+
| printWidth
830+
=====================================input======================================
831+
// https://github.com/babel/babel/blob/HEAD/packages/babel-generator/test/fixtures/parentheses/in-inside-for/input.js
832+
833+
for (var a = (b in c) in {});
834+
for (var a = 1 || (b in c) in {});
835+
for (var a = 1 + (2 || (b in c)) in {});
836+
for (var a = (() => b in c) in {});
837+
for (var a = 1 || (() => b in c) in {});
838+
for (var a = (() => { b in c; }) in {});
839+
for (var a = [b in c] in {});
840+
for (var a = {b: b in c} in {});
841+
// Meriyah can't parse
842+
// for (var a = (x = b in c) => {} in {});
843+
for (var a = class extends (b in c) {} in {});
844+
for (var a = function (x = b in c) {} in {});
845+
846+
=====================================output=====================================
847+
// https://github.com/babel/babel/blob/HEAD/packages/babel-generator/test/fixtures/parentheses/in-inside-for/input.js
848+
849+
for (var a = (b in c) in {});
850+
for (var a = (1 || b in c) in {});
851+
for (var a = (1 + (2 || b in c)) in {});
852+
for (var a = (() => b in c) in {});
853+
for (var a = (1 || (() => b in c)) in {});
854+
for (var a = (() => {
855+
b in c;
856+
}) in {});
857+
for (var a = ([b in c]) in {});
858+
for (var a = ({ b: b in c }) in {});
859+
// Meriyah can't parse
860+
// for (var a = (x = b in c) => {} in {});
861+
for (var a = (class extends (b in c) {}) in {});
862+
for (var a = (function (x = b in c) {}) in {});
863+
864+
================================================================================
865+
`;
866+
802867
exports[`in.js format 1`] = `
803868
====================================options=====================================
804869
parsers: ["babel", "flow", "typescript"]
@@ -835,6 +900,129 @@ for (a in b) 0;
835900
================================================================================
836901
`;
837902

903+
exports[`parentheses.js [flow] format 1`] = `
904+
"Unexpected token \`=>\`, expected the token \`;\` (11:27)
905+
9 | for (var a = [b in c];;);
906+
10 | for (var a = {b: b in c};;);
907+
> 11 | for (var a = (x = b in c) => {};;);
908+
| ^^
909+
12 | for (var a = class extends (b in c) {};;);
910+
13 | for (var a = function (x = b in c) {};;);
911+
14 |"
912+
`;
913+
914+
exports[`parentheses.js [typescript] format 1`] = `
915+
"',' expected. (9:17)
916+
7 | for (var a = 1 || (() => b in c);;);
917+
8 | for (var a = (() => { b in c; });;);
918+
> 9 | for (var a = [b in c];;);
919+
| ^
920+
10 | for (var a = {b: b in c};;);
921+
11 | for (var a = (x = b in c) => {};;);
922+
12 | for (var a = class extends (b in c) {};;);
923+
Cause: ',' expected."
924+
`;
925+
926+
exports[`parentheses.js format 1`] = `
927+
====================================options=====================================
928+
parsers: ["babel", "flow", "typescript"]
929+
printWidth: 80
930+
| printWidth
931+
=====================================input======================================
932+
// https://github.com/babel/babel/blob/HEAD/packages/babel-generator/test/fixtures/parentheses/in-inside-for/input.js
933+
934+
for (var a = (b in c);;);
935+
for (var a = 1 || (b in c);;);
936+
for (var a = 1 + (2 || (b in c));;);
937+
for (var a = (() => b in c);;);
938+
for (var a = 1 || (() => b in c);;);
939+
for (var a = (() => { b in c; });;);
940+
for (var a = [b in c];;);
941+
for (var a = {b: b in c};;);
942+
for (var a = (x = b in c) => {};;);
943+
for (var a = class extends (b in c) {};;);
944+
for (var a = function (x = b in c) {};;);
945+
946+
for (var a in (b in c));
947+
for (var a in 1 || (b in c));
948+
for (var a in 1 + (2 || (b in c)));
949+
for (var a in (() => b in c));
950+
for (var a in 1 || (() => b in c));
951+
for (var a in (() => { b in c; }));
952+
for (var a in [b in c]);
953+
for (var a in {b: b in c});
954+
for (var a in (x = b in c) => {});
955+
for (var a in class extends (b in c) {});
956+
for (var a in function (x = b in c) {});
957+
958+
for (;a = (b in c););
959+
for (;a = 1 || (b in c););
960+
for (;a = 1 + (2 || (b in c)););
961+
for (;a = (() => b in c););
962+
for (;a = 1 || (() => b in c););
963+
for (;a = (() => { b in c; }););
964+
for (;a = [b in c];);
965+
for (;a = {b: b in c};);
966+
for (;a = (x = b in c) => {};);
967+
for (;a = class extends (b in c) {};);
968+
for (;a = function (x = b in c) {};);
969+
970+
=====================================output=====================================
971+
// https://github.com/babel/babel/blob/HEAD/packages/babel-generator/test/fixtures/parentheses/in-inside-for/input.js
972+
973+
for (var a = (b in c); ; );
974+
for (var a = 1 || (b in c); ; );
975+
for (var a = 1 + (2 || (b in c)); ; );
976+
for (var a = () => (b in c); ; );
977+
for (var a = 1 || (() => (b in c)); ; );
978+
for (
979+
var a = () => {
980+
(b in c);
981+
};
982+
;
983+
984+
);
985+
for (var a = [(b in c)]; ; );
986+
for (var a = { b: (b in c) }; ; );
987+
for (var a = (x = (b in c)) => {}; ; );
988+
for (var a = class extends (b in c) {}; ; );
989+
for (var a = function (x = (b in c)) {}; ; );
990+
991+
for (var a in b in c);
992+
for (var a in 1 || b in c);
993+
for (var a in 1 + (2 || b in c));
994+
for (var a in () => b in c);
995+
for (var a in 1 || (() => b in c));
996+
for (var a in () => {
997+
b in c;
998+
});
999+
for (var a in [b in c]);
1000+
for (var a in { b: b in c });
1001+
for (var a in (x = b in c) => {});
1002+
for (var a in class extends (b in c) {});
1003+
for (var a in function (x = b in c) {});
1004+
1005+
for (; (a = b in c); );
1006+
for (; (a = 1 || b in c); );
1007+
for (; (a = 1 + (2 || b in c)); );
1008+
for (; (a = () => b in c); );
1009+
for (; (a = 1 || (() => b in c)); );
1010+
for (
1011+
;
1012+
(a = () => {
1013+
b in c;
1014+
});
1015+
1016+
);
1017+
for (; (a = [b in c]); );
1018+
for (; (a = { b: b in c }); );
1019+
for (; (a = (x = b in c) => {}); );
1020+
for (; (a = class extends (b in c) {}); );
1021+
for (; (a = function (x = b in c) {}); );
1022+
1023+
================================================================================
1024+
`;
1025+
8381026
exports[`var.js format 1`] = `
8391027
====================================options=====================================
8401028
parsers: ["babel", "flow", "typescript"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// https://github.com/babel/babel/blob/HEAD/packages/babel-generator/test/fixtures/parentheses/in-inside-for/input.js
2+
3+
for (var a = (b in c) in {});
4+
for (var a = 1 || (b in c) in {});
5+
for (var a = 1 + (2 || (b in c)) in {});
6+
for (var a = (() => b in c) in {});
7+
for (var a = 1 || (() => b in c) in {});
8+
for (var a = (() => { b in c; }) in {});
9+
for (var a = [b in c] in {});
10+
for (var a = {b: b in c} in {});
11+
// Meriyah can't parse
12+
// for (var a = (x = b in c) => {} in {});
13+
for (var a = class extends (b in c) {} in {});
14+
for (var a = function (x = b in c) {} in {});

tests/format/js/for/format.test.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
runFormatTest(import.meta, ["babel", "flow", "typescript"]);
1+
runFormatTest(import.meta, ["babel", "flow", "typescript"], {
2+
errors: {
3+
flow: ["parentheses.js", "for-in-with-initializer.js"],
4+
typescript: ["parentheses.js", "for-in-with-initializer.js"],
5+
},
6+
});

tests/format/js/for/parentheses.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// https://github.com/babel/babel/blob/HEAD/packages/babel-generator/test/fixtures/parentheses/in-inside-for/input.js
2+
3+
for (var a = (b in c);;);
4+
for (var a = 1 || (b in c);;);
5+
for (var a = 1 + (2 || (b in c));;);
6+
for (var a = (() => b in c);;);
7+
for (var a = 1 || (() => b in c);;);
8+
for (var a = (() => { b in c; });;);
9+
for (var a = [b in c];;);
10+
for (var a = {b: b in c};;);
11+
for (var a = (x = b in c) => {};;);
12+
for (var a = class extends (b in c) {};;);
13+
for (var a = function (x = b in c) {};;);
14+
15+
for (var a in (b in c));
16+
for (var a in 1 || (b in c));
17+
for (var a in 1 + (2 || (b in c)));
18+
for (var a in (() => b in c));
19+
for (var a in 1 || (() => b in c));
20+
for (var a in (() => { b in c; }));
21+
for (var a in [b in c]);
22+
for (var a in {b: b in c});
23+
for (var a in (x = b in c) => {});
24+
for (var a in class extends (b in c) {});
25+
for (var a in function (x = b in c) {});
26+
27+
for (;a = (b in c););
28+
for (;a = 1 || (b in c););
29+
for (;a = 1 + (2 || (b in c)););
30+
for (;a = (() => b in c););
31+
for (;a = 1 || (() => b in c););
32+
for (;a = (() => { b in c; }););
33+
for (;a = [b in c];);
34+
for (;a = {b: b in c};);
35+
for (;a = (x = b in c) => {};);
36+
for (;a = class extends (b in c) {};);
37+
for (;a = function (x = b in c) {};);

tests/format/misc/errors/js/explicit-resource-management/__snapshots__/format.test.js.snap

+7-6
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,15 @@ exports[`invalid-using-binding-let.js [flow] format 1`] = `
8080
`;
8181

8282
exports[`invalid-using-binding-pattern.js [babel] format 1`] = `
83-
"Unexpected token (2:17)
84-
1 | {
85-
> 2 | using { foo } = f();
86-
| ^
83+
"Unexpected token, expected ")" (4:25)
84+
2 | using { foo } = f();
8785
3 | using [ bar ] = g();
88-
4 | for (using { qux } of h());
86+
> 4 | for (using { qux } of h());
87+
| ^
8988
5 | for (using [ quux ] of i());
90-
Cause: Unexpected token (2:16)"
89+
6 | }
90+
7 |
91+
Cause: Unexpected token, expected ")" (4:24)"
9192
`;
9293

9394
exports[`invalid-using-binding-pattern.js [flow] format 1`] = `

tests/unit/__snapshots__/visitor-keys.js.snap

-3
Original file line numberDiff line numberDiff line change
@@ -628,9 +628,6 @@ exports[`visitor keys estree 1`] = `
628628
"ObjectTypeInternalSlot": [
629629
"id",
630630
"value",
631-
"optional",
632-
"static",
633-
"method",
634631
],
635632
"ObjectTypeMappedTypeProperty": [
636633
"keyTparam",

0 commit comments

Comments
 (0)