Skip to content

Commit ba1c8fd

Browse files
committed
Forbid top-level-await
1 parent 623ed23 commit ba1c8fd

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

config-v-next/eslint.cjs

+5
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ function createConfig(configFilePath) {
236236
message:
237237
"assert.ok should provide an error message as the second argument",
238238
},
239+
{
240+
selector: "AwaitExpression:not(:function AwaitExpression)",
241+
message:
242+
"Top-level await is only allowed in a few cases. Please discuss this change with the team.",
243+
},
239244
],
240245
"@typescript-eslint/restrict-plus-operands": "error",
241246
"@typescript-eslint/restrict-template-expressions": [

v-next/hardhat/src/cli.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// small file is loaded with sourcemaps enabled.
33
process.setSourceMapsEnabled(true);
44

5+
// eslint-disable-next-line no-restricted-syntax -- Allow top-level await here
56
const { main } = await import("./internal/cli/main.js");
67

78
main(process.argv.slice(2)).catch((error: unknown) => {

v-next/hardhat/src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import { resolveHardhatConfigPath } from "./config.js";
22
import { importUserConfig } from "./internal/helpers/config-loading.js";
33
import { getHardhatRuntimeEnvironmentSingleton } from "./internal/hre-singleton.js";
44

5+
/* eslint-disable no-restricted-syntax -- Allow top-level await here */
56
const configPath = await resolveHardhatConfigPath();
67
const userConfig = await importUserConfig(configPath);
78

89
const hre = await getHardhatRuntimeEnvironmentSingleton(userConfig);
10+
/* eslint-enable no-restricted-syntax */
911

1012
export const { config, tasks, globalOptions, hooks, interruptions } = hre;
1113

0 commit comments

Comments
 (0)