📝 Disallow exports in scripts.
💼 This rule is enabled in the following configs: ✅ recommended, ☑️ unopinionated.
Scripts are meant to be executed directly, not imported as modules.
Exports in a script mix module and script boundaries and can mislead readers about how the file is intended to run.
This script fails:
#!/usr/bin/env node
export const foo = 1;This script passes:
#!/usr/bin/env node
const foo = 1;
console.log(foo);Modules pass:
export const foo = 1;