Do a formatting pass on comm-central using Prettier (the actual change)
Categories
(Thunderbird :: General, task, P3)
Tracking
(Not tracked)
People
(Reporter: pmorris, Assigned: pmorris)
References
Details
Attachments
(23 files, 23 obsolete files)
Following on doing a Prettier formatting pass on Calendar code in bug 1577606, do the same for the rest of comm-central. Here are some notes copied from the meta bug 1572047:
"Preparation work is at least adding "curly: all" to eslint and do an intermediary step to fix that up (through mach lint --fix), or otherwise we get the ugly online if-elses where braces are missing."
Assignee | ||
Comment 1•5 years ago
|
||
1 of 23: Adjust eslint settings for reformatting TB code with Prettier. Includes removing the rules that were added when m-c started using Prettier, as darktrojan mentioned on the meta bug:
Some of those rules were removed from mozilla-central when they turned on Prettier. They were added to our config because we had Prettier disabled and wanted to keep the checks.
https://hg.mozilla.org/comm-central/rev/1ba917da139c6e707d6d964c5d1de142cab1e666
These 23 patches should be applied on top of:
- part 1 patch from bug 1573670
- parts 1-7 from bug 1577606
- parts 2-3 from bug 1573670
Assignee | ||
Comment 2•5 years ago
|
||
2 of 23: Automated reformatting of chat/ code.
These changes were achieved by:
- Using eslint to add curly brackets to control
statements that did not have them (if, else, etc.),
thanks to the eslint rule: "curly": ["error", "all"]
Done by running |mach eslint chat/ --fix|
- Reformatting the code using Prettier.
Done by deleting the chat/ line from
the .prettierignore file and running:
|mach eslint chat/ --fix|
This was also the procedure for the other patches that do auto-formatting on other directories besides chat/.
Assignee | ||
Comment 3•5 years ago
|
||
3 of 23: Manually fix linting errors produced by (left over from) auto-formatting chat/ code.
Assignee | ||
Comment 4•5 years ago
|
||
4 of 23: Fix placement of comments in if/else blocks that were not handled well by auto-formatting (due to insertion of curly brackets).
The insertion of curly blocks worked well overall, but fixing these comments was a chore. Basically if the original code had things like the following, the comment placement was off after the auto-formatting. The comments ended up outside the curly braces.
if (foo) // blah 1 (comments here were handled correctly)
bar();
else // blah 2
baz();
if (foo)
bar() // blah 1
else
baz() // blah 2
Assignee | ||
Comment 5•5 years ago
|
||
5 of 23: Remove the .eslintrc.js file for chat/ code. These eslint rules for the chat/ code are no longer needed. Removing them did not produce any eslint errors.
Assignee | ||
Comment 6•5 years ago
|
||
6 of 23: Auto-format code in the common/ and ldap/ directories.
Assignee | ||
Comment 7•5 years ago
|
||
7 of 23: Reformat editor/ code.
Assignee | ||
Comment 8•5 years ago
|
||
8 of 23: Fix linting errors left over after auto-formatting editor/ code.
Assignee | ||
Comment 9•5 years ago
|
||
9 of 23: Fix comment placement in if/else blocks in editor/ code.
Assignee | ||
Comment 10•5 years ago
|
||
10 of 23: Auto-format mail/ code.
Assignee | ||
Comment 11•5 years ago
|
||
11 of 23: Fix "curly" eslint errors in XUL files in mail/ directory. These errors came from enabling the "curly" rule, rather than the auto-formatting changes.
Assignee | ||
Comment 12•5 years ago
|
||
12 of 23: Fix some atypical for loops in mail/ code that are objectionable to Prettier.
Assignee | ||
Comment 13•5 years ago
|
||
13 of 23: Fix placement of "eslint-disable-" comments in mail/ code so they still work.
Assignee | ||
Comment 14•5 years ago
|
||
14 of 23: Fix "no-useless-concat" eslint errors left over after auto-formatting, in mail/ code.
Assignee | ||
Comment 15•5 years ago
|
||
15 of 23: Fix placement of comments connected to else blocks in mail/ code.
Assignee | ||
Comment 16•5 years ago
|
||
16 of 23: Fix placement of comments connected to if blocks in mail/ code.
Assignee | ||
Comment 17•5 years ago
|
||
17 of 23: Auto-format mailnews/ code.
Assignee | ||
Comment 18•5 years ago
|
||
18 of 23: Fix atypical for loops in mailnews/ code that Prettier finds objectionable.
Assignee | ||
Comment 19•5 years ago
|
||
19 of 23: Fix "no-useless-concat" eslint errors left over after auto-formatting in mailnews/ code.
Assignee | ||
Comment 20•5 years ago
|
||
20 of 23: Fix placement of comments connected to else blocks in mailnews/ code.
Assignee | ||
Comment 21•5 years ago
|
||
Assignee | ||
Comment 22•5 years ago
|
||
The patch in comment 21 is:
21 of 23: Fix placement of comments connected to if blocks in mailnews/ code.
Assignee | ||
Comment 23•5 years ago
|
||
22 of 23: Fix some comments connected with function declarations in mailnews/ code. The auto-formatting mangles cases like this:
/* globals openHelp */// Suite only.
function doHelpButton() {
So put comments on separate lines instead.
/* globals openHelp */
// Suite only.
function doHelpButton() {
Assignee | ||
Comment 24•5 years ago
|
||
23 of 23: Auto-format eslintrc.js files with Prettier (using mach eslint --fix). Seems like we'd want to be consistent and format these files with Prettier as well.
Assignee | ||
Comment 25•5 years ago
|
||
I just tried to do a try server run, but the tree is closed (see bug 1578014).
An earlier try run[0] was successful, except it had an earlier version of the last patch (#23) that did not reformat all of the eslintrc.js files. That problem is fixed in the patches I just uploaded. Aside from patch 23, the only change in the uploaded patches and those in that try server run were rebasing them on the current tip of trunk. The good news is that tests are passing with these changes.
Updated•5 years ago
|
Comment 26•5 years ago
|
||
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Comment 27•5 years ago
|
||
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Comment 28•5 years ago
|
||
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Assignee | ||
Comment 29•5 years ago
|
||
Thanks for the review. I've addressed all the comments and rebased on current tip. Uploading new patches next. Try run is underway here: https://treeherder.mozilla.org/#/jobs?repo=try-comm-central&revision=5f2092a05610a9fe5e0226120dfdebd5727ff083
Comment 30•5 years ago
|
||
Can you do some folding to reduce the number of patches?
Comment 31•5 years ago
|
||
Like one patch per directory.
Assignee | ||
Comment 32•5 years ago
|
||
Assignee | ||
Comment 33•5 years ago
|
||
Assignee | ||
Comment 34•5 years ago
|
||
Assignee | ||
Comment 35•5 years ago
|
||
Assignee | ||
Comment 36•5 years ago
|
||
Assignee | ||
Comment 37•5 years ago
|
||
Assignee | ||
Comment 38•5 years ago
|
||
Assignee | ||
Comment 39•5 years ago
|
||
Assignee | ||
Comment 40•5 years ago
|
||
Assignee | ||
Comment 41•5 years ago
|
||
Assignee | ||
Comment 42•5 years ago
|
||
Assignee | ||
Comment 43•5 years ago
|
||
Assignee | ||
Comment 44•5 years ago
|
||
Assignee | ||
Comment 45•5 years ago
|
||
Assignee | ||
Comment 46•5 years ago
|
||
Assignee | ||
Comment 47•5 years ago
|
||
Assignee | ||
Comment 48•5 years ago
|
||
Assignee | ||
Comment 49•5 years ago
|
||
Assignee | ||
Comment 50•5 years ago
|
||
Assignee | ||
Comment 51•5 years ago
|
||
Assignee | ||
Comment 52•5 years ago
|
||
Assignee | ||
Comment 53•5 years ago
|
||
Assignee | ||
Comment 54•5 years ago
|
||
Assignee | ||
Comment 55•5 years ago
|
||
jorgk: just saw your comment 30 & 31. (Wish I'd seen them before uploading all those patches...)
I'd prefer to keep the automatic formatting patches and manual fix patches separate. What about two patches for each directory, one automatic and one manual follow ups?
Assignee | ||
Updated•5 years ago
|
Comment 56•5 years ago
|
||
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/d62d63b2f73c
Adjust eslint config for reformatting. r=mkmelin
https://hg.mozilla.org/comm-central/rev/e57378725085
Reformat chat/ code with eslint and Prettier. r=mkmelin
https://hg.mozilla.org/comm-central/rev/8e3167f4cea7
Fix remaining linting errors in chat/. r=mkmelin
https://hg.mozilla.org/comm-central/rev/73f7aa520703
Fix 'if, else, comments', other formatting in chat/. r=mkmelin
https://hg.mozilla.org/comm-central/rev/23725f0afc96
Remove now unneeded chat/.eslintrc.js file. r=mkmelin
https://hg.mozilla.org/comm-central/rev/ab9b63f9d226
Reformat common/ and ldap/ code. r=mkmelin
https://hg.mozilla.org/comm-central/rev/8d3544b63528
Reformat editor/ code with eslint and Prettier. r=mkmelin
https://hg.mozilla.org/comm-central/rev/b1283c57f051
Fix remaining linting errors in editor/. r=mkmelin
https://hg.mozilla.org/comm-central/rev/81f2db384ad9
Fix 'if, else, and comments' formatting in editor/. r=mkmelin
https://hg.mozilla.org/comm-central/rev/883449e17f9d
Reformat mail/ code with eslint and Prettier. r=mkmelin
https://hg.mozilla.org/comm-central/rev/c9b6c0d8e2d2
Fix "curly" eslint errors in xul files in mail/. r=mkmelin
https://hg.mozilla.org/comm-central/rev/90e206d351f7
Rewrite atypical for loops in mail/ for Prettier. r=mkmelin
https://hg.mozilla.org/comm-central/rev/50a23b185cdd
Fix location of 'eslint-disable-' comments in mail/. r=mkmelin
https://hg.mozilla.org/comm-central/rev/f19f1829633f
Fix eslint "no-useless-concat" errors in mail/. r=mkmelin
https://hg.mozilla.org/comm-central/rev/e8bbfa11d96e
Fix 'else and comments' formatting in mail/. r=mkmelin
https://hg.mozilla.org/comm-central/rev/3aceadebffb5
Fix 'if and comments' formatting in mail/. r=mkmelin
https://hg.mozilla.org/comm-central/rev/5b47088d84e7
Reformat mailnews/ code with eslint and Prettier. r=mkmelin
https://hg.mozilla.org/comm-central/rev/b53bee47da4e
Rewrite atypical for loops in mailnews/ for Prettier. r=mkmelin
https://hg.mozilla.org/comm-central/rev/77773ecb02ca
Fix eslint "no-useless-concat" errors in mailnews/. r=mkmelin
https://hg.mozilla.org/comm-central/rev/90b92315e8a5
Fix 'else and comments' formatting in mailnews/. r=mkmelin
https://hg.mozilla.org/comm-central/rev/d61a07ada51d
Fix 'if and comments' formatting in mailnews/. r=mkmelin
https://hg.mozilla.org/comm-central/rev/dfc10500bb00
Fix 'function and comments' formatting in mailnews/. r=mkmelin
https://hg.mozilla.org/comm-central/rev/8177b85d18db
Reformat the .eslintrc.js files with Prettier. r=mkmelin
Comment 57•5 years ago
|
||
Nice job. However: Two patches had the wrong bug number (check it on your try run), one patch said "But" instead of "Bug". That was the 9th patch which made the entire push fail. So I had to strip and reapply 15 patches which "hg qfinish -a" had already removed :-(
Assignee | ||
Comment 58•5 years ago
|
||
Oof, oh man, sorry about those slip ups, and thank you for handling them.
Comment 59•5 years ago
|
||
Did this all land without ignore-this-changeset or adding to .hg-annotate-ignore-revs and thus destroying useful blame history?
Comment 60•5 years ago
|
||
No, all the reformat patches had ignore-this-changeset, for example here:
https://hg.mozilla.org/comm-central/rev/5b47088d84e7
Somehow "ignore-this-changeset" doesn't work out of the box, some measures need to be taken for those changesets to be really ignored.
Comment 61•5 years ago
|
||
Well, when looking here in searchfox, blame shows this commit:
https://searchfox.org/comm-central/source/mail/base/content/browserRequest.js#19
Should it?
Comment 62•5 years ago
|
||
Yes, last line of comment #60. I don't know how to ignore them, someone needs to talk to Searchfox.
Comment 63•5 years ago
|
||
Perhaps talking to (copying) firefox would be better, and using the second technique in last line of comment 59?
There is a post from Jan on m.dev.platform, subject: Skipping changesets when viewing blame
Comment 64•5 years ago
|
||
I think we need a .hg-annotate-ignore-revs (and .git-blame-ignore-revs) file
Assignee | ||
Comment 65•5 years ago
|
||
Adding .hg-annotate-ignore-revs and .git-blame-ignore-revs files in bug 1579183 and bug 1579191.
Description
•