n/no-top-level-await
eslint-plugin-n
No autofix
eslint.config.js
import n from "eslint-plugin-n";
export default [
{
plugins: { n },
rules: {
"n/no-top-level-await": "error",
},
},
];const foo = await import('foo');
for await (const e of asyncIterate()) {
// ...
}#!/usr/bin/env node
/*eslint n/no-top-level-await: ["error", { "ignoreBin": true }]*/
const foo = await import('foo');
for await (const e of asyncIterate()) {
// ...
}Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
n/no-top-level-await
eslint-plugin-n
import n from "eslint-plugin-n";
export default [
{
plugins: { n },
rules: {
"n/no-top-level-await": "error",
},
},
];node/no-top-level-await
node plugin · restriction
{
"plugins": [
"node"
],
"rules": {
"node/no-top-level-await": "error"
}
}Biome does not have this rule.
Enforce using the node: protocol when importing Node.js builtin modules.
Enforce using process.getBuiltinModule() to load Node.js built-in modules
Enforce the style of file extensions in import declarations