Skip to content

Enable no-process-exit#11025

Merged
nicolo-ribaudo merged 1 commit intobabel:masterfrom
JLHwung:enable-no-process-exit
Jan 19, 2020
Merged

Enable no-process-exit#11025
nicolo-ribaudo merged 1 commit intobabel:masterfrom
JLHwung:enable-no-process-exit

Conversation

@JLHwung
Copy link
Copy Markdown
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 force-pushed the enable-no-process-exit branch from 72e8bf4 to 64cb26a Compare January 17, 2020 21:22
@JLHwung JLHwung marked this pull request as ready for review January 17, 2020 22:02
process.kill(process.pid, signal);
} else {
process.exit(code);
process.exitCode = code;
Copy link
Copy Markdown
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.

var filename = process.argv[2];
if (!filename) {
console.error("no filename specified");
process.exit(0);
Copy link
Copy Markdown
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.

break;
}

process.exit(0);
Copy link
Copy Markdown
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.

3 participants