Skip to content

Deprecate "dartfmt" in favor of "dart format" #986

Closed
@munificent

Description

@munificent

The Dart SDK now exposes a single dart command line executable with subcommands for all of the main tasks you might like to perform: run code, run tests, etc. To format your code, you can now run dart format. Eventually, we plan to remove the dartfmt executable from the Dart SDK. Two things make this a little more complicated:

New CLI options

The command line options supported by dartfmt are not very usable, and the output is verbose. When we added the new dart format command, I took the opportunity to completely revamp the options. The dart format command does away with the annoying required -w option and the hundreds of "Unchanged..." lines. The new CLI is more usable, flexible, and consistent with other dart commands. It is also incompatible with the old option set.

Package CLI

In addition to running the formatter through the Dart SDK, the dart_style package also exposes a command line executable that can be invoked like:

$ pub run dart_style:format

Or:

$ pub global install dart_style
$ dartfmt

That executable still uses the old options. It would be nice to eventually completely remove the old option code, which means the dart_style:format command should either go away or also move over to the new options.

As far as I can tell, the package executable is not widely used. We could deprecate it and remove it in a future breaking release of dart_style. But I do think exposing an executable is useful because it gives users a way to write scripts that run a specific version of the formatter. This may become important if we want to make larger formatting changes and users want to control when they migrate to them.

To that end, I propose we keep the format executable in dart_style but move it over to the new CLI options in a future breaking release.

Migration plan

After Dart 2.14 ships:

  • Remove dartfmt shell scripts from the SDK.

In a future breaking change release of dart_style:

  • Move bin/format.dart to use the new CLI options and remove the old option code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions