rojo-rbx / rojo

Rojo enables Roblox developers to use professional-grade software engineering tools
https://rojo.space
Mozilla Public License 2.0
936 stars 175 forks source link

Suggestions to improve fmt-project #962

Open nezuo opened 3 weeks ago

nezuo commented 3 weeks ago
  1. Add fmt-project --check so formatting can be checked in CI.
  2. Description: what are "the standard JSON formatting rules"? image
  3. Make fmt-project deterministic. Currently, it reorders properties every time you run it.
  4. Make certain data types more concise:
    • For example, Vector3 is formatted as:
      "Position": [
      0.0,
      -10.0,
      0.0
      ]

      but is should be formatted as:

      "Position": [0.0, -10.0, 0.0]
  5. 2 spaces is a bit hard to read for me but I don't necessarily think that should change.
  6. Instance/project settings (anything that starts with $, for example $properties) should come before child instances.
Dekkonot commented 3 weeks ago

With regards to point 3, this is something that's already being done with Syncback. The main issue right now is that project files (as well as all the other JSON formats) use HashMaps for things, which are obviously unordered. Since syncback needs to be deterministic, it had to solve this problem and when it's merged the ordering will be guaranteed.

Point 4 isn't feasible, unfortunately, since it'd involve us using something other than for serializing Variant. I'm not willing to commit to that because of the complexity it'd bring to the table.

Otherwise, I think these are reasonable! fmt-project has gone basically untouched since it was introduced and these suggestions would be great improvements to it.