CesiumJS source code is now formatted with Prettier

Hi everyone!

A quick note to let everyone know that we’ve just reformatted all of the CesiumJS source code in the master branch using Prettier. :scream:

If you’re just using CesiumJS by downloading release ZIPs or by installing it from npm, this won’t affect you at all. You can stop reading.

But if you have a fork of CesiumJS, you will find that the next time you pull from the upstream repo, nearly every line of code will have changed and you’ll have heaps of merge conflicts. The good news is, it’s very easy to avoid the conflicts if you follow the process below. Consider bookmarking this post now so that you can return to it when you’re ready to merge.

To merge from CesiumGS/cesium starting with master today or with the 1.69 release early May, do the following:

  1. Fetch changes from the upstream git fetch upstream. Replace upstream with the name of your git remote that points to the official CesiumGS/cesium repo.
  2. Create a new branch for your merge: git checkout -b whatever-merge. This is not strictly necessary, but it makes it easier to start over if something goes wrong in this process.
  3. Merge the last commit before Prettier into your branch: git merge pre-prettier . Resolve any conflicts as you usually do.
  4. Commit the merge above.
  5. Merge the Prettier formatting changes, accepting your own changes in all cases: git merge post-prettier --strategy=ours --no-commit Accepting yours is safe because this commit only changes formatting. Do NOT commit yet.
  6. Run prettier on the result of the merge before committing it: npm run prettier
  7. Commit these changes (which is technically a merge commit).
  8. Merge master into your branch in order to pick up any changes in master that happened after Prettier was introduced: git merge upstream/master . You can also merge a release tag here instead of master, if desired. Resolve any conflicts as normal and commit; there shouldn’t be any Prettier-related conflicts.
  9. Once you’re satisfied with the result, merge it back into your original branch, if you created a new one in step 2: git checkout my-original-branch && git merge whatever-merge

That seems like a lot of steps, but with any luck it should be pretty painless. Let us know if you run into any difficulties.