Skip to content
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

[Meta] Ship the new formatting style and migrate to it #56688

Open
18 of 24 tasks
munificent opened this issue Sep 10, 2024 · 0 comments
Open
18 of 24 tasks

[Meta] Ship the new formatting style and migrate to it #56688

munificent opened this issue Sep 10, 2024 · 0 comments
Labels
area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...).

Comments

@munificent
Copy link
Member

munificent commented Sep 10, 2024

Since last year, we have been rewriting the Dart formatter (the dart format command and dart_style package where its implementation lives) to apply a style that works better for the kinds of declarative code Dart users are writing today and fix a list of long-standing style bugs. The rewrite is mostly done and it's time now to prepare to ship it.

This meta-issue tracks work to ship the new style and migrate code owned by the Dart and Flutter teams to that style.

Migrate code to pass in a language version to the formatter API

The new formatter will use language version to determine whether you get the old or new style. The DartFormatter constructor now takes an optional parameter where you can pass in the language version. In a future version of dart_style, that parameter will become mandatory.

Before we can do that, the Dart SDK (and the various packages it pulls in) need to be migrated to start passing that in:

For the packages developed outside of the Dart SDK repo, these changes then need to be rolled in:

  • Roll dartdoc into Dart SDK
  • Roll http into Dart SDK
  • Roll mockito into Dart SDK
  • Roll web into Dart SDK

Make the language version mandatory

While users are migrating to dart_style 2.3.7 and passing in the language version, we can start working on the new major version of dart_style. Since we're bumping the major version, this enables us to make some other planned breaking changes:

Note that the new style is still behind an experiment flag, so this is a "major" version only because of the API changes.

Ship the new style

In addition to the above changes, we will probably still be fixing style issues and tweaking the output. Once those changes have mostly settled down, it's time to actually ship the new style and flip the experiment flag.

Roll into the Dart SDK and migrate the SDK

Rolling the new dart_style into the SDK is challenging because some Dart code in the SDK will already be at the language version where the new style applies. Probably the core libraries, and maybe some other packages, runtime code, etc. As soon as the new dart_style lands, that code will be incorrectly using the old style. (Code in packages that are still using an older language version is fine because that will still use the old style.)

We can't reformat that code in the same commit that rolls in the new dart_style, because the presubmit uses a pre-built version of the SDK. So, I think the easiest approach is:

  • (https://dart-review.googlesource.com/c/sdk/+/391320) Temporarily disable the format check in the presubmit script.
  • (https://dart-review.googlesource.com/c/sdk/+/391263) Roll the new dart_style into the Dart SDK.
  • Regenerate and land a pre-built SDK with the new dart_style.
  • Reformat code in the Dart SDK. Run the formatter on the whole Dart repo (minus third_party and multitests). Send out some number of giant code reviews to land it all. Let the team know what they may need to update any in-progress changes they have to the new style.
  • (Handle the new formatting style in the static error test updater #57042) Update the static error test updater to handle indented comments.
  • Re-enable the format check in the presubmit. At this point, everything in the SDK repo should have the right style and we should have a pre-built SDK with a new enough formatter to validate that.
  • (https://dart-review.googlesource.com/c/sdk/+/394571) Update the SDK CHANGELOG. Describe the new style and language version selection for it. Also describe the new support for opting regions of code out of formatting.
  • Publish a new version of dart_style.

Migrate Flutter

It's to be determined how this will happen.

Announce

Once we're certain the new style will ship in a version of the Dart and Flutter SDKs, we can announce it:

  • Announce that a new style is coming in the new Dart SDK. Explain how language versioning will work.
@munificent munificent added the area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). label Sep 10, 2024
@munificent munificent changed the title [Meta] Migrate uses of dart_style package to pass in language version [Meta] Ship the new formatting style and migrate to it Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...).
Projects
None yet
Development

No branches or pull requests

1 participant