Skip to content

Commit 5d1a095

Browse files
autofix-ci[bot]sapphi-red
authored andcommitted
[autofix.ci] apply automated fixes
1 parent 8011e21 commit 5d1a095

File tree

6 files changed

+71
-31
lines changed

6 files changed

+71
-31
lines changed

crates/oxc_compat/src/es_features.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ pub enum ESFeature {
5050
ES2022ClassProperties,
5151
ES2022PrivateMethods,
5252
ES2022MatchIndicesRegex,
53-
ES2022TopLevelAwait,
5453
ES2024UnicodeSetsRegex,
5554
ES2025DuplicateNamedCapturingGroupsRegex,
5655
ES2025RegexpModifiers,
5756
ES2020ExportNamespaceFrom,
57+
ES2022TopLevelAwait,
5858
}
5959
pub fn features() -> &'static FxHashMap<ESFeature, EngineTargets> {
6060
use ESFeature::*;
@@ -833,23 +833,6 @@ pub fn features() -> &'static FxHashMap<ESFeature, EngineTargets> {
833833
(Es, Version(2022u16, 0, 0)),
834834
])),
835835
),
836-
(
837-
ES2022TopLevelAwait,
838-
EngineTargets::new(FxHashMap::from_iter([
839-
(Samsung, Version(15u16, 0u16, 0u16)),
840-
(Node, Version(14u16, 8u16, 0u16)),
841-
(Firefox, Version(89u16, 0u16, 0u16)),
842-
(Chrome, Version(89u16, 0u16, 0u16)),
843-
(Safari, Version(15u16, 0u16, 0u16)),
844-
(Ios, Version(15u16, 0u16, 0u16)),
845-
(Edge, Version(89u16, 0u16, 0u16)),
846-
(OperaMobile, Version(63u16, 0u16, 0u16)),
847-
(Deno, Version(1u16, 0u16, 0u16)),
848-
(Electron, Version(12u16, 0u16, 0u16)),
849-
(Opera, Version(75u16, 0u16, 0u16)),
850-
(Es, Version(2022u16, 0, 0)),
851-
])),
852-
),
853836
(
854837
ES2024UnicodeSetsRegex,
855838
EngineTargets::new(FxHashMap::from_iter([
@@ -911,6 +894,23 @@ pub fn features() -> &'static FxHashMap<ESFeature, EngineTargets> {
911894
(Es, Version(2020u16, 0, 0)),
912895
])),
913896
),
897+
(
898+
ES2022TopLevelAwait,
899+
EngineTargets::new(FxHashMap::from_iter([
900+
(Samsung, Version(15u16, 0u16, 0u16)),
901+
(Node, Version(14u16, 8u16, 0u16)),
902+
(Firefox, Version(89u16, 0u16, 0u16)),
903+
(Chrome, Version(89u16, 0u16, 0u16)),
904+
(Safari, Version(15u16, 0u16, 0u16)),
905+
(Ios, Version(15u16, 0u16, 0u16)),
906+
(Edge, Version(89u16, 0u16, 0u16)),
907+
(OperaMobile, Version(63u16, 0u16, 0u16)),
908+
(Deno, Version(1u16, 0u16, 0u16)),
909+
(Electron, Version(12u16, 0u16, 0u16)),
910+
(Opera, Version(75u16, 0u16, 0u16)),
911+
(Es, Version(2022u16, 0, 0)),
912+
])),
913+
),
914914
])
915915
})
916916
}

crates/oxc_transformer/src/es2022/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,12 @@ impl<'a> Traverse<'a, TransformState<'a>> for ES2022<'a, '_> {
132132
}
133133
}
134134

135-
fn enter_await_expression(&mut self, node: &mut AwaitExpression<'a>, ctx: &mut TraverseCtx<'a>) {
136-
if self.options.top_level_await && Self::is_top_level_await(ctx) {
135+
fn enter_await_expression(
136+
&mut self,
137+
node: &mut AwaitExpression<'a>,
138+
ctx: &mut TraverseCtx<'a>,
139+
) {
140+
if self.options.top_level_await && Self::is_top_level(ctx) {
137141
let warning = OxcDiagnostic::warn(
138142
"Top-level await is not available in the configured target environment.",
139143
)
@@ -144,9 +148,7 @@ impl<'a> Traverse<'a, TransformState<'a>> for ES2022<'a, '_> {
144148
}
145149

146150
impl ES2022<'_, '_> {
147-
fn is_top_level_await(ctx: &TraverseCtx) -> bool {
148-
// Check if the hoist scope is the root scope
149-
// Top-level await means await at the module top level
151+
fn is_top_level(ctx: &TraverseCtx) -> bool {
150152
ctx.current_hoist_scope_id() == ctx.scoping().root_scope_id()
151153
}
152154
}

crates/oxc_transformer/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,11 @@ impl<'a> Traverse<'a, TransformState<'a>> for TransformerImpl<'a, '_> {
252252
self.x2_es2020.enter_big_int_literal(node, ctx);
253253
}
254254

255-
fn enter_await_expression(&mut self, node: &mut AwaitExpression<'a>, ctx: &mut TraverseCtx<'a>) {
255+
fn enter_await_expression(
256+
&mut self,
257+
node: &mut AwaitExpression<'a>,
258+
ctx: &mut TraverseCtx<'a>,
259+
) {
256260
self.x2_es2022.enter_await_expression(node, ctx);
257261
}
258262

tasks/compat_data/custom-compat-data.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,25 @@ const customEs2020 = [
2727
},
2828
].map(f('ES2020'));
2929

30-
module.exports = [...customEs2020];
30+
const customEs2022 = [
31+
{
32+
name: 'TopLevelAwait',
33+
babel: null,
34+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#browser_compatibility
35+
targets: {
36+
chrome: '89',
37+
opera: '75',
38+
edge: '89',
39+
firefox: '89',
40+
safari: '15.0',
41+
node: '14.8',
42+
deno: '1.0',
43+
ios: '15.0',
44+
samsung: '15.0',
45+
opera_mobile: '63',
46+
electron: '12.0',
47+
}
48+
},
49+
].map(f('ES2022'));
50+
51+
module.exports = [...customEs2020, ...customEs2022];

tasks/compat_data/data.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,5 +1052,23 @@
10521052
"electron": "5.0"
10531053
},
10541054
"es": "ES2020"
1055+
},
1056+
{
1057+
"name": "TopLevelAwait",
1058+
"babel": null,
1059+
"targets": {
1060+
"chrome": "89",
1061+
"opera": "75",
1062+
"edge": "89",
1063+
"firefox": "89",
1064+
"safari": "15.0",
1065+
"node": "14.8",
1066+
"deno": "1.0",
1067+
"ios": "15.0",
1068+
"samsung": "15.0",
1069+
"opera_mobile": "63",
1070+
"electron": "12.0"
1071+
},
1072+
"es": "ES2022"
10551073
}
1056-
]
1074+
]

tasks/compat_data/es-features.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,6 @@ const es2022 = [
297297
// ignore "shows up in flags"
298298
],
299299
},
300-
{
301-
name: 'TopLevelAwait',
302-
babel: null,
303-
features: [],
304-
},
305300
].map(f('ES2022'));
306301

307302
const es2024 = [

0 commit comments

Comments
 (0)