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

Pass a language version to DartFormatter(). #901

Merged
merged 2 commits into from
Oct 28, 2024

Conversation

munificent
Copy link
Member

We're in the process of moving dart_style to a new formatting style. That involves making the formatter aware of the language version of what it's formatting.

That in turn means that the library API now lets you pass in a language version. In dart_style 2.3.7 you can pass in a language version but the parameter is optional. In the forthcoming 3.0.0 release, that parameter will become mandatory.

This updates the two calls to DartFormatter() in intl_translation/bin to pass in a language version. It attempts to look for a surrounding package_config.json file and uses the language version from that (which is what other Dart tools do). If that files, it just defaults to using the latest language version that the formatter supports.

We're in [the process of](dart-lang/dart_style#1403) moving dart_style to [a new formatting style](dart-lang/dart_style#1253). That involves making the formatter [aware of the language version of what it's formatting](dart-lang/dart_style#1402).

That in turn means that the library API now lets you pass in a language version. In dart_style 2.3.7 [you can pass in a language version but the parameter is optional](https://pub.dev/documentation/dart_style/latest/dart_style/DartFormatter/DartFormatter.html). In the forthcoming 3.0.0 release, that parameter will become mandatory.

This updates the two calls to `DartFormatter()` in intl_translation/bin to pass in a language version. It attempts to look for a surrounding package_config.json file and uses the language version from that (which is what other Dart tools do). If that files, it just defaults to using the latest language version that the formatter supports.
@munificent
Copy link
Member Author

cc @kevmoo

I ended up harvesting just the tiny amount of code from dart_style needed to replicate the package config lookup here.

Copy link

github-actions bot commented Oct 25, 2024

PR Health

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
intl_translation None 0.20.1-wip 0.20.1-wip 0.20.1-wip ✔️
Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

Coverage ⚠️
File Coverage
pkgs/intl_translation/bin/make_examples_const.dart 💔 Not covered
pkgs/intl_translation/bin/rewrite_intl_messages.dart 💔 Not covered
pkgs/intl_translation/lib/src/language_version.dart 💔 Not covered

This check for test coverage is informational (issues shown here will not fail the PR).

This check can be disabled by tagging the PR with skip-coverage-check.

API leaks ⚠️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbols
intl_translation Message
MainMessage

This check can be disabled by tagging the PR with skip-leaking-check.

License Headers ✔️
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
no missing headers

All source files should start with a license header.

@copybara-service copybara-service bot merged commit c878218 into main Oct 28, 2024
14 checks passed
@copybara-service copybara-service bot deleted the language-version-formatter branch October 28, 2024 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants