Skip to content

dart format --language-version=3.7 vs sdk: '>=3.7.0 <4.0.0' #1648

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

Closed
dcharkes opened this issue Feb 14, 2025 · 2 comments
Closed

dart format --language-version=3.7 vs sdk: '>=3.7.0 <4.0.0' #1648

dcharkes opened this issue Feb 14, 2025 · 2 comments

Comments

@dcharkes
Copy link

dcharkes commented Feb 14, 2025

I'm somewhat confused around how the formatter versions work. The command line --language-version seems to not agree 100% with the language version in the pubspec.

I'm seeing a difference between

$ dart format --language-version=3.7 .

and

$ dart format .

My pubspec contains:

environment:
  sdk: '>=3.7.0 <4.0.0'

The diff

diff --git a/pkgs/native_assets_cli/example/build/native_add_library/hook/build.dart b/pkgs/native_assets_cli/example/build/native_add_library/hook/build.dart
index b8ddfd95..aa0b20e7 100644
--- a/pkgs/native_assets_cli/example/build/native_add_library/hook/build.dart
+++ b/pkgs/native_assets_cli/example/build/native_add_library/hook/build.dart
@@ -17,9 +17,10 @@ void main(List<String> args) async {
     await cbuilder.run(
       input: input,
       output: output,
-      logger: Logger('')
-        ..level = Level.ALL
-        ..onRecord.listen((record) => print(record.message)),
+      logger:
+          Logger('')
+            ..level = Level.ALL
+            ..onRecord.listen((record) => print(record.message)),
     );
   });
 }

My understanding was that the formatter is per language version. So, any future changes in the formatter will not change the formatting until the language version is bumped in the pubspec. However, on the GitHub CI dart format . seems to want to have the files formatted as dart format --language-version=3.7 . locally, which means the CI becomes red.

Local Dart version:

$ dart --version
Dart SDK version: 3.8.0-24.0.dev (dev)

@munificent How are breaking changes to the formatter handled?

@dcharkes
Copy link
Author

Ah, there was an old package_config.json:

    {
      "name": "native_add_library",
      "rootUri": "../",
      "packageUri": "lib/",
      "languageVersion": "3.3"
    }

@munificent
Copy link
Member

Ah, there was an old package_config.json:

Yeah, this is a really really annoying failure mode. We aren't sure the best way to deal with it yet. See #1597.

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

No branches or pull requests

2 participants