Skip to content

Enable prettier formatter in monaco #12640

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

Open
wants to merge 3 commits into
base: sandcastle-react-structure
Choose a base branch
from

Conversation

jjspace
Copy link
Contributor

@jjspace jjspace commented May 29, 2025

Description

  • Add prettier to Sandcastle to format code in monaco
    • This aligns with the rest of Cesium's code so gallery examples should format the same as the source
  • Update monaco default settings
    • I did a pass on all the editor options and toggled a handful to increase the user experience.
    • I really struggled not to turn on all the extra stuff that fits my personal preference 😅

Issue number and link

Part of #12566

Testing plan

  • Write any code in Sandcastle
  • Click Format and make sure it works for JS and HTML with no errors
  • Make sure the formatted code matches what you'd expect from prettier

Author checklist

  • I have submitted a Contributor License Agreement
  • I have added my name to CONTRIBUTORS.md
  • I have updated CHANGES.md with a short summary of my change
  • I have added or updated unit tests to ensure consistent code coverage
  • I have updated the inline documentation, and included code examples where relevant
  • I have performed a self-review of my code

@jjspace jjspace requested a review from ggetz May 29, 2025 15:47
Copy link

Thank you for the pull request, @jjspace!

✅ We can confirm we have a CLA on file for you.

@jjspace jjspace force-pushed the monaco-prettier branch from c055b8b to 4bef0ac Compare June 6, 2025 22:06
@ggetz
Copy link
Contributor

ggetz commented Jun 13, 2025

I really struggled not to turn on all the extra stuff that fits my personal preference 😅

We all have editor preferences, and some user expressed interest in disabling as much as possible. How tricky would it be to add a settings menu to turn features on and off?

@jjspace
Copy link
Contributor Author

jjspace commented Jun 13, 2025

@ggetz functionally it shouldn't be that hard. However it would probably be a lot of effort to pick and choose which of the 150+ options we want to expose and allow changing

I would rather we stick mostly to defaults with the few opinionated changes I've already made. Monaco shouldn't really get in the way of people just "typing in code".

If we get feedback that it's too much after trying it we can potentially add a single toggle for a "plain text" mode that turns off nearly everything.

Copy link
Contributor

@ggetz ggetz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

guides: {
bracketPairs: "active",
},
minimap: { size: "fill" },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly hate this. 😆 But I'm not going to hold up the PR over it.

Copy link
Contributor Author

@jjspace jjspace Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha I was really on the fence about this one. I personally really hate it the "default" way and this is much better to me. 😆 This is probably the most opinionated setting I changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly thought about just removing the minimap entirely 🤔

Copy link
Contributor

@ggetz ggetz Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, personally I hate the minimap entirely.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well you're in luck 😆 Due to how monaco calculates resizing the minimap seems "expensive" and slow. When I added the panel resizing (#12672) it started flickering pretty bad and lagging behind visually. Easier to just turn it off (in that PR) Oh well 🤷

@ggetz
Copy link
Contributor

ggetz commented Jun 13, 2025

However it would probably be a lot of effort to pick and choose which of the 150+ options and allow changing...If we get feedback that it's too much after trying it we can potentially add a single toggle for a "plain text" mode that turns off nearly everything.

Yes, I agree that approach it with that kind of fine-toothed comb would be a loosing battle.

At the very least, we are already allowing user to toggle dark and light modes, so I don't think it would hurt to have a settings area for that plus maybe one or two "controversial" options. From there, we could make small changes based on user feedback, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants