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

Enable no-process-exit #11025

Merged
merged 1 commit into from Jan 19, 2020
Merged

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Jan 16, 2020

Q                       A
License MIT

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_code

In most case the synchronous process.exit() is unnecessary, and it causes asynchronous IO operations terminated even when they are not fulfilled, e.g. writes to stdout or stderr.

In our codebase, process.exit() is often used as top level return: It is straightforward to fix: wrap the statements into an else branch so we are not scheduling new tasks for the event loop.

@JLHwung JLHwung added PR: Internal 🏠 A type of pull request used for our changelog categories area: eslint labels Jan 16, 2020
@JLHwung JLHwung marked this pull request as ready for review January 17, 2020 22:02
@@ -92,7 +92,7 @@ getV8Flags(function(err, v8Flags) {
if (signal) {
process.kill(process.pid, signal);
} else {
process.exit(code);
process.exitCode = code;
Copy link
Contributor Author

@JLHwung JLHwung Jan 17, 2020

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);
Copy link
Contributor Author

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);
Copy link
Contributor Author

@JLHwung JLHwung Jan 17, 2020

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.

@nicolo-ribaudo nicolo-ribaudo merged commit facfd4d into babel:master Jan 19, 2020
@nicolo-ribaudo nicolo-ribaudo deleted the enable-no-process-exit branch January 19, 2020 23:48
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Apr 20, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: eslint outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Internal 🏠 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants