You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would have expected that running dart format . in the myproject directory formats foo.dart in the old style without removing/adding any trailing commas because the lower SDK bound in the pubspec.yaml is below 3.7. However, it actually uses the new format style and removes the trailing comma:
enum foo { entry1, entry2 }
Observation: After running dart pub update the formatter actually respects the given sdk constraints and uses the old style:
Expectation: The formatter uses the correct style based on the sdk constrains in the pubspec.yaml even if dart pub update hasn't been run to avoid breaking CI this way.
I observed this behavior with the formatter from Dart SDK version 3.7.0-219.0.dev.
If it doesn't reproduce: delete the .dart_tools directory and pubpsec.lock file.
The text was updated successfully, but these errors were encountered:
Oof, yeah, this is a nasty UX pitfall. I'm going to close this as a duplicate of #1597 which has a lot more context.
Sorry for the breakage. I'm still trying to figure out the best way for the formatter to help users avoid this problem without adding unbounded complexity to how it interacts with the file system.
Given the following setup:
myproject/pubspec.yaml
:myproject/lib/foo.dart
:enum foo { entry1, entry2, }
I would have expected that running
dart format .
in themyproject
directory formatsfoo.dart
in the old style without removing/adding any trailing commas because the lower SDK bound in thepubspec.yaml
is below 3.7. However, it actually uses the new format style and removes the trailing comma:enum foo { entry1, entry2 }
Observation: After running
dart pub update
the formatter actually respects the given sdk constraints and uses the old style:enum foo { entry1, entry2, }
This caused an actual breakage in flutter's assets-for-api-docs repository where the CI was all of the sudden (without bumping the lower SDK constraints) expecting everything to be formatted in the new style: https://github.com/flutter/assets-for-api-docs/actions/runs/11847189657/job/33016375039
Expectation: The formatter uses the correct style based on the sdk constrains in the pubspec.yaml even if
dart pub update
hasn't been run to avoid breaking CI this way.I observed this behavior with the formatter from Dart SDK version 3.7.0-219.0.dev.
If it doesn't reproduce: delete the
.dart_tools
directory andpubpsec.lock
file.The text was updated successfully, but these errors were encountered: