dart-sdk/pkg/dartfix
Samuel Rawlins 5a32ff0d7f Revert "Bump cli_util to 0.2.0; implement new methods"
This reverts commit ebcc6dc2a2.

Reason for revert: Broke golem. I think there are more implementations of Logger than I realized.

Original change's description:
> Bump cli_util to 0.2.0; implement new methods
> 
> This fixes the issue of progress indicators being shown during tests.
> 
> Change-Id: I39fd68cfeca70a63d088aceb4325b42c53766afd
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150669
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Paul Berry <paulberry@google.com>

TBR=paulberry@google.com,jcollins@google.com,mfairhurst@google.com,srawlins@google.com

Change-Id: I52ac0f5d96a161534c28cc160c2a2b3b364ad511
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150693
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-10 23:59:05 +00:00
..
bin [dartfix] Bump pedantic dep to v1.8.0 and cleanup lint violations 2019-07-09 16:25:19 +00:00
example dartfix: Fix for new lints in pedantic 0.9: 2019-12-16 04:11:26 +00:00
fixed dartfix: Fix for new lints in pedantic 0.9: 2019-12-16 04:11:26 +00:00
lib Migration: connect dartdev to new command-line API. 2020-05-14 18:03:21 +00:00
test Revert "Bump cli_util to 0.2.0; implement new methods" 2020-06-10 23:59:05 +00:00
.gitignore Move dartfix to its own package 2018-10-22 17:50:25 +00:00
analysis_options.yaml [dartdev] address a few analysis issues 2020-03-10 20:07:51 +00:00
CHANGELOG.md Prepare for dartfix 0.1.7. 2020-05-15 16:39:52 +00:00
LICENSE Update dartfix package for publication 2018-10-31 17:36:51 +00:00
pubspec.yaml Bypass pub constraint validation for dartfix 0.1.7. 2020-05-07 18:11:28 +00:00
README.md Fix pub.dev URLs throughout SDK repo 2019-11-20 11:30:48 +00:00

dartfix is a command-line tool for migrating your Dart code to use newer syntax styles.

Usage

Important: Save a copy of your source code before making changes with dartfix. Unlike dartfmt, which makes only safe changes (usually to whitespace), dartfix can make changes that you might need to undo or modify.

Before you can use the dartfix tool, you need to install it, as described below. Then invoke it with the name of the directory that you want to update. When you're ready to make the suggested changes, add the --overwrite option.

$ dartfix examples/misc
... summary of recommended changes ...
$ dartfix examples/misc --overwrite

Features

dartfix applies different types of "fixes" to migrate your Dart code. By default, all fixes are applied, but you can select only the specific fixes you want. See dartfix --help for more about the available command line options.

Some of the fixes that you can apply are "required" in that the Dart language is changing and at some point the old syntax will no longer be supported. To only apply these changes, pass the --required option on the command line. The required fixes include:

  • Find classes used as mixins, and convert them to use the mixin keyword instead of class. Mixin support is one of the features added to Dart in 2.1. At some point in the future, the Dart team plans to disallow using classes as mixins.

  • Move named constructor type arguments from the name to the type.
    For example, given class A<T> { A.from(Object obj) { } }, dartfix changes constructor invocations in the following way:

    Original code:
    A.from<String>(anObject) // Invokes the `A.from` named constructor.
    
    Code produced by dartfix:
    A<String>.from(anObject) // Same, but the type is directly after `A`.
    

Other changes are recommended but not required. These include:

  • Find double literals that end in .0, and remove the .0. Language support for this was added in Dart in 2.1.

Installing and updating dartfix

The easiest way to use dartfix is to globally install it, so that it can be in your path:

$ pub global activate dartfix

Use the same command to update dartfix. We recommend updating dartfix whenever you update your Dart SDK or when a new feature is released.

Filing issues

If you want a new fix, first look at dartfix issues and star the fixes you want. If no issue exists for the fix, create a GitHub issue.