Closed Bug 1577835 Opened 5 years ago Closed 5 years ago

Do a formatting pass on comm-central using Prettier (the actual change)

Categories

(Thunderbird :: General, task, P3)

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 70.0

People

(Reporter: pmorris, Assigned: pmorris)

References

Details

Attachments

(23 files, 23 obsolete files)

4.82 KB, patch
Details | Diff | Splinter Review
1.29 MB, patch
Details | Diff | Splinter Review
6.01 KB, patch
Details | Diff | Splinter Review
16.45 KB, patch
Details | Diff | Splinter Review
607 bytes, patch
Details | Diff | Splinter Review
167.48 KB, patch
Details | Diff | Splinter Review
585.73 KB, patch
Details | Diff | Splinter Review
5.35 KB, patch
Details | Diff | Splinter Review
12.11 KB, patch
Details | Diff | Splinter Review
6.15 MB, patch
Details | Diff | Splinter Review
13.72 KB, patch
Details | Diff | Splinter Review
8.65 KB, patch
Details | Diff | Splinter Review
3.72 KB, patch
Details | Diff | Splinter Review
17.68 KB, patch
Details | Diff | Splinter Review
27.74 KB, patch
Details | Diff | Splinter Review
25.59 KB, patch
Details | Diff | Splinter Review
4.98 MB, patch
Details | Diff | Splinter Review
3.16 KB, patch
Details | Diff | Splinter Review
9.09 KB, patch
Details | Diff | Splinter Review
33.99 KB, patch
Details | Diff | Splinter Review
19.15 KB, patch
Details | Diff | Splinter Review
17.71 KB, patch
Details | Diff | Splinter Review
16.32 KB, patch
Details | Diff | Splinter Review

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."

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:

Attachment #9089638 - Flags: review?(mkmelin+mozilla)
Attached patch part2-reformat-chat-code-0.patch (obsolete) — Splinter Review

2 of 23: Automated reformatting of chat/ code.

These changes were achieved by:

  1. 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|

  1. 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/.

Attachment #9089639 - Flags: review?(mkmelin+mozilla)

3 of 23: Manually fix linting errors produced by (left over from) auto-formatting chat/ code.

Attachment #9089640 - Flags: review?(mkmelin+mozilla)

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

Attachment #9089641 - Flags: review?(mkmelin+mozilla)

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.

Attachment #9089642 - Flags: review?(mkmelin+mozilla)

6 of 23: Auto-format code in the common/ and ldap/ directories.

Attachment #9089643 - Flags: review?(mkmelin+mozilla)

7 of 23: Reformat editor/ code.

Attachment #9089644 - Flags: review?(mkmelin+mozilla)

8 of 23: Fix linting errors left over after auto-formatting editor/ code.

Attachment #9089645 - Flags: review?(mkmelin+mozilla)

9 of 23: Fix comment placement in if/else blocks in editor/ code.

Attachment #9089646 - Flags: review?(mkmelin+mozilla)

10 of 23: Auto-format mail/ code.

Attachment #9089648 - Flags: review?(mkmelin+mozilla)

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.

Attachment #9089650 - Flags: review?(mkmelin+mozilla)
Attached patch part12-for-loops-in-mail-0.patch (obsolete) — Splinter Review

12 of 23: Fix some atypical for loops in mail/ code that are objectionable to Prettier.

Attachment #9089651 - Flags: review?(mkmelin+mozilla)

13 of 23: Fix placement of "eslint-disable-" comments in mail/ code so they still work.

Attachment #9089652 - Flags: review?(mkmelin+mozilla)

14 of 23: Fix "no-useless-concat" eslint errors left over after auto-formatting, in mail/ code.

Attachment #9089653 - Flags: review?(mkmelin+mozilla)

15 of 23: Fix placement of comments connected to else blocks in mail/ code.

Attachment #9089654 - Flags: review?(mkmelin+mozilla)
Attached patch part16-if-comments-mail-0.patch (obsolete) — Splinter Review

16 of 23: Fix placement of comments connected to if blocks in mail/ code.

Attachment #9089655 - Flags: review?(mkmelin+mozilla)

17 of 23: Auto-format mailnews/ code.

Attachment #9089656 - Flags: review?(mkmelin+mozilla)

18 of 23: Fix atypical for loops in mailnews/ code that Prettier finds objectionable.

Attachment #9089657 - Flags: review?(mkmelin+mozilla)

19 of 23: Fix "no-useless-concat" eslint errors left over after auto-formatting in mailnews/ code.

Attachment #9089658 - Flags: review?(mkmelin+mozilla)

20 of 23: Fix placement of comments connected to else blocks in mailnews/ code.

Attachment #9089659 - Flags: review?(mkmelin+mozilla)
Attachment #9089660 - Flags: review?(mkmelin+mozilla)

The patch in comment 21 is:
21 of 23: Fix placement of comments connected to if blocks in mailnews/ code.

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() {

Attachment #9089661 - Flags: review?(mkmelin+mozilla)

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.

Attachment #9089662 - Flags: review?(mkmelin+mozilla)

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.

[0] https://treeherder.mozilla.org/#/jobs?repo=try-comm-central&revision=365deb5d9f12b48d6068050b62c86c7f0db39a74

Attachment #9089638 - Flags: review?(mkmelin+mozilla) → review+
Comment on attachment 9089639 [details] [diff] [review] part2-reformat-chat-code-0.patch Review of attachment 9089639 [details] [diff] [review]: ----------------------------------------------------------------- ::: chat/modules/imContentSink.jsm @@ +12,5 @@ > + // default one > + // useful if you want to allow or forbid > + // an additional thing in a specific > + // conversation but take into account all > + // the other global settings. these could use some fixing...
Attachment #9089639 - Flags: review?(mkmelin+mozilla) → review+
Attachment #9089640 - Flags: review?(mkmelin+mozilla) → review+
Attachment #9089641 - Flags: review?(mkmelin+mozilla) → review+
Attachment #9089642 - Flags: review?(mkmelin+mozilla) → review+
Attachment #9089643 - Flags: review?(mkmelin+mozilla) → review+
Status: NEW → ASSIGNED
Attachment #9089644 - Flags: review?(mkmelin+mozilla) → review+
Attachment #9089645 - Flags: review?(mkmelin+mozilla) → review+
Attachment #9089646 - Flags: review?(mkmelin+mozilla) → review+
Attachment #9089650 - Flags: review?(mkmelin+mozilla) → review+
Attachment #9089651 - Flags: review?(mkmelin+mozilla) → review+
Attachment #9089652 - Flags: review?(mkmelin+mozilla) → review+
Attachment #9089648 - Flags: review?(mkmelin+mozilla) → review+
Attachment #9089653 - Flags: review?(mkmelin+mozilla) → review+
Attachment #9089654 - Flags: review?(mkmelin+mozilla) → review+
Comment on attachment 9089655 [details] [diff] [review] part16-if-comments-mail-0.patch Review of attachment 9089655 [details] [diff] [review]: ----------------------------------------------------------------- ::: mail/base/content/editContactPanel.js @@ +193,5 @@ > }, > > deleteContact() { > if (this._cardDetails.book.readOnly) { > + /* Double check we can delete this. */ I'd make these // style while we're at it.
Attachment #9089655 - Flags: review?(mkmelin+mozilla) → review+
Attachment #9089656 - Flags: review?(mkmelin+mozilla) → review+
Attachment #9089657 - Flags: review?(mkmelin+mozilla) → review+
Attachment #9089658 - Flags: review?(mkmelin+mozilla) → review+
Comment on attachment 9089659 [details] [diff] [review] part20-else-comments-mailnews-0.patch Review of attachment 9089659 [details] [diff] [review]: ----------------------------------------------------------------- ::: mailnews/base/prefs/content/am-prefs.js @@ +44,5 @@ > newprefstr += prefPartsArray[i] + "."; > } > } > + } else { > + /* token is falsy. */ // style please ::: mailnews/base/util/JXON.js @@ +147,5 @@ > oParentObj instanceof String || > oParentObj instanceof Number || > oParentObj instanceof Boolean > ) { > + /* verbosity level is 0 */ here too @@ +156,5 @@ > > for (var sName in oParentObj) { > vValue = oParentObj[sName]; > if (isFinite(sName) || vValue instanceof Function) { > + /* verbosity level is 0 */ here and the others in this patch too ::: mailnews/db/gloda/modules/datastore.js @@ +1795,2 @@ > return null; > + } else if ( please make it just if. (no else after return)
Attachment #9089659 - Flags: review?(mkmelin+mozilla) → review+
Attachment #9089660 - Flags: review?(mkmelin+mozilla) → review+
Attachment #9089661 - Flags: review?(mkmelin+mozilla) → review+
Attachment #9089662 - Flags: review?(mkmelin+mozilla) → review+

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

Can you do some folding to reduce the number of patches?

Like one patch per directory.

Attachment #9089638 - Attachment is obsolete: true
Attachment #9089639 - Attachment is obsolete: true
Attachment #9089640 - Attachment is obsolete: true
Attachment #9089641 - Attachment is obsolete: true
Attachment #9089642 - Attachment is obsolete: true
Attachment #9089643 - Attachment is obsolete: true
Attachment #9089644 - Attachment is obsolete: true
Attachment #9089645 - Attachment is obsolete: true
Attachment #9089646 - Attachment is obsolete: true
Attachment #9089648 - Attachment is obsolete: true
Attachment #9089650 - Attachment is obsolete: true
Attachment #9089651 - Attachment is obsolete: true
Attachment #9089652 - Attachment is obsolete: true
Attachment #9089653 - Attachment is obsolete: true
Attachment #9089654 - Attachment is obsolete: true
Attachment #9089655 - Attachment is obsolete: true
Attachment #9089656 - Attachment is obsolete: true
Attachment #9089657 - Attachment is obsolete: true
Attachment #9089658 - Attachment is obsolete: true
Attachment #9089659 - Attachment is obsolete: true
Attachment #9089660 - Attachment is obsolete: true
Attachment #9089661 - Attachment is obsolete: true
Attachment #9089662 - Attachment is obsolete: true

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?

Keywords: checkin-needed

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

Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Keywords: checkin-needed
Resolution: --- → FIXED

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 :-(

Target Milestone: --- → Thunderbird 70.0

Oof, oh man, sorry about those slip ups, and thank you for handling them.

Did this all land without ignore-this-changeset or adding to .hg-annotate-ignore-revs and thus destroying useful blame history?

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.

Well, when looking here in searchfox, blame shows this commit:
https://searchfox.org/comm-central/source/mail/base/content/browserRequest.js#19
Should it?

Yes, last line of comment #60. I don't know how to ignore them, someone needs to talk to Searchfox.

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

Blocks: 1578477

I think we need a .hg-annotate-ignore-revs (and .git-blame-ignore-revs) file

Adding .hg-annotate-ignore-revs and .git-blame-ignore-revs files in bug 1579183 and bug 1579191.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: