Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forbid top-level-await #5454

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config-v-next/eslint.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ function createConfig(configFilePath) {
message:
"assert.ok should provide an error message as the second argument",
},
{
selector: "AwaitExpression:not(:function AwaitExpression)",
message:
"Top-level await is only allowed in a few cases. Please discuss this change with the team.",
},
],
"@typescript-eslint/restrict-plus-operands": "error",
"@typescript-eslint/restrict-template-expressions": [
Expand Down
1 change: 1 addition & 0 deletions v-next/hardhat/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// small file is loaded with sourcemaps enabled.
process.setSourceMapsEnabled(true);

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

main(process.argv.slice(2)).catch((error: unknown) => {
Expand Down
2 changes: 2 additions & 0 deletions v-next/hardhat/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { resolveHardhatConfigPath } from "./config.js";
import { importUserConfig } from "./internal/helpers/config-loading.js";
import { getHardhatRuntimeEnvironmentSingleton } from "./internal/hre-singleton.js";

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

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

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

Expand Down
Loading