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
Enable no-process-exit
#11025
Enable no-process-exit
#11025
Conversation
72e8bf4
to
64cb26a
Compare
@@ -92,7 +92,7 @@ getV8Flags(function(err, v8Flags) { | |||
if (signal) { | |||
process.kill(process.pid, signal); | |||
} else { | |||
process.exit(code); | |||
process.exitCode = code; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node.js will terminate when all exit
listeners are executed, so we don't need to call process.exit
again in the listener.
@@ -7,10 +7,9 @@ var fs = require("fs"); | |||
var filename = process.argv[2]; | |||
if (!filename) { | |||
console.error("no filename specified"); | |||
process.exit(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
process.exit(0)
is unnecessary after refactor.
} | ||
|
||
process.exit(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is rather a bug because when --check
is provided, it will still exit after checking only "plugin"
data. Removed after refactor. So it can continue checking corejs2-builtin-in
after the first check succeeds.
This PR includes commits from #11026.
Enabled
no-process-exit
rule and fixed linting errors. Rationale: https://nodejs.org/api/process.html#process_process_exit_codeIn most case the synchronous
process.exit()
is unnecessary, and it causes asynchronous IO operations terminated even when they are not fulfilled, e.g. writes tostdout
orstderr
.In our codebase,
process.exit()
is often used as top level return: It is straightforward to fix: wrap the statements into anelse
branch so we are not scheduling new tasks for the event loop.