Prettier Compatibility Metrics and Goals #2611
Replies: 4 comments 9 replies
-
You raised a really valid point Nicholas. We should really draw a big line and say "We are satisfied with the level of compatibility of the code (how equal they are)". And that's it. Once we draw the line, rome formatter will start being the actual rome formatter and we will take our decisions based on our judgement. The great and big problem is that Prettier, as software, will never reach the "feature complete" status (the languages will continue to evolve, as much as the software itself), which means that we will need to have at least a couple of people to follow the project, understand their code, porting code, etc. which is really time consuming and I don't think it's our goal. I assume that our goal is to make the users comfortable with the transition, by avoiding too many changes. Which means that changes will still occur due to different reasons:
|
Beta Was this translation helpful? Give feedback.
-
I'd like to propose a specific level of compatibility: Pull Request Compatibility. What this means is that if a PR were to be opened that switches a project from Prettier to Rome, the amount of changes would be sufficiently small that people would be willing to merge the PR. Of course, this is a subjective measurement, but we can start with small one-person projects and then scale up to larger projects. |
Beta Was this translation helpful? Give feedback.
-
As an example, I ran Rome on wasup, my library for generating WebAssembly: https://github.com/NicholasLYang/wasup/pull/1/files If I were to see a PR like this, I'd be a little concerned due to the large amount of changes. That said, it does seem like a lot of these changes can be eliminated by fixing trailing commas. |
Beta Was this translation helpful? Give feedback.
-
Another topic worth discussing is our choice of formatting options. I'd like to propose that we explicitly follow Prettier's default options as our default options. That means we avoid trailing commas in situations other than objects and arrays, and we indent with two spaces. As for adopting other formatting options, while I'm aware that the ideology of the formatter is to keep a minimal set of options, we should acknowledge that missing options will limit adoption. People who explicitly configure prettier probably care about these options and won't want to move to a formatter where they can't use them. There might be possible exceptions for people who adopted code, whether from a starter pack or an existing codebase, that had these options and don't care themselves about these minutiae. |
Beta Was this translation helpful? Give feedback.
-
We've set a goal for ourselves of being "Prettier compatible", i.e. our formatter should produce an output very similar to Prettier. This is a good goal for a couple reasons: It punts any larger discussion on formatting issues and it makes adoption easier by preventing large git diffs. Not to mention, Prettier's formatting is overall quite nice.
As nice of a goal as this is, it's hard to define what "Prettier compatibility" actually means. The most optimistic goal would be a precise 1 to 1 match for Prettier output for all JavaScript/TypeScript code. That's not really feasible. It'd take too long and it'd require a lot of porting of Prettier's logic to our codebase. Prettier also has some very very specific edge cases which we may not want to support.
Therefore, what should our goal be? We should create some form of metric for Prettier compatibility. I'm not sure what that metric will be, but I'll note down some potential pitfalls that we should avoid:
Beta Was this translation helpful? Give feedback.
All reactions