-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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 auto-formatting of the entire code-base using Prettier (issue 11444) #11446
Conversation
afbea58
to
281fd40
Compare
6c3274a
to
c3448cb
Compare
… data structures There's a fair number of (primarily) `Array`s/`TypedArray`s whose formatting we don't want disturb, since in many cases that would lead to the code becoming much more difficult to read and/or break existing inline comments. *Please note:* It may be a good idea to look through these cases individually, and possibly re-write some of the them (especially the `String` ones) to reduce the need for all of these ignore commands.
701603e
to
2bc6f08
Compare
…11444) Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes). Prettier is being used for a couple of reasons: - To be consistent with `mozilla-central`, where Prettier is already in use across the tree. - To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters. Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some). Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long. *Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit. (On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
…t `--fix` couldn't handle This patch makes the follow changes: - Remove no longer necessary inline `// eslint-disable-...` comments. - Fix `// eslint-disable-...` comments that Prettier moved down, thus causing new linting errors. - Concatenate strings which now fit on just one line. - Fix comments that are now too long. - Finally, and most importantly, adjust comments that Prettier moved down, since the new positions often is confusing or outright wrong.
2bc6f08
to
a63f7ad
Compare
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/e96b4de3a2a9b66/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/e96b4de3a2a9b66/output.txt Total script time: 1.74 mins Published |
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/3dacbc2adfd57a9/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.215.176.217:8877/5759f99a92b50c3/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/3dacbc2adfd57a9/output.txt Total script time: 18.89 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.215.176.217:8877/5759f99a92b50c3/output.txt Total script time: 25.80 mins
|
While the first and last commits should be possible to review manually, the main commit is unfortunately not feasible to review (and enabling Prettier everywhere at once seemed like a good idea). |
/botio lint |
From: Bot.io (Linux m4)ReceivedCommand cmd_lint from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/1fc5ea99334c055/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_lint from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.215.176.217:8877/7f45de869546954/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/1fc5ea99334c055/output.txt Total script time: 1.17 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.215.176.217:8877/7f45de869546954/output.txt Total script time: 2.58 mins
|
Once Prettier auto-formatting has landed: I think that we should avoid doing things like e.g. the recent |
Thank you for improving this! I think it's a huge step forward in terms of consistency with I checked everything except for the main commit, but I did look over it to see if all changes look correct. I'm indeed going to trust that ESLint did the work correctly, and the passing tests and linting prove this. I have reviewed this pull request first because I figured rebasing this would be horrible, so now we can rebase the other patches easily. |
Thanks a lot for taking the time to review this; and also for prioritizing getting this landed quickly to avoid painful rebasing :-) |
Holy crap, that's how to enter 2020 in style! 😎 Congratulations! |
Note that Prettier, purposely, has only limited configuration options. The configuration file is based on the one in
mozilla central
with just a few additions (to avoid future breakage if the defaults ever changes).Prettier is being used for a couple of reasons:
To be consistent with
mozilla-central
, where Prettier is already in use across the tree.To ensure a consistent coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the
printWidth
option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that comments won't become too long.Please note: This patch is generated automatically, by appending the
--fix
argument to the ESLint call used in thegulp lint
task. It will thus require some additional clean-up, which will be done in a separate commit.(On a more personal note, I'll readily admit that some of the changes Prettier makes are extremely ugly. However, in the name of consistency we'll probably have to live with that.)
Fixes #11444.