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
The FormatCommand should offer a --code argument, as in FixCommand to apply fixes to specific lint rules instead of using --fix-<non-standard-code> (currently documented as used for non-whitespace changes only).
Additional context
The FormatCommand is being consumed by dartdev, a command-line utility for Dart development (part of the Dart SDK).
The package:dartdevexposes a FixCommand that accepts a code argument. This is very useful, since it allows to explicitly resolve fixes for a specific linter rule.
dart fix --apply --code=directives_ordering # Solves for "directives_ordering"
Note: The directives_ordering code is already well documented in Dart Linter Rules.
However, the FormatCommand presents another solution which brings inconsistency to the overall Developer Experience offered by the command-line utility for Dart development.
dart format . --code=avoid_single_cascade_in_expression_statements # Could not find an option named "code"
dart format . --fix-single-cascade-statements
The --fix support in dart format is pretty old, which mostly explains why its names don't agree with the linter. Instead of updating the names in --fix, I think the better solution that we're working toward (thanks @keertip!) is to make dart fix fast enough for users to use it for all of the things where dart format --fix is currently supported and faster. That will enable us to remove dart format --fix entirely and have one canonical way to apply code fixes: dart fix.
Given that, I think it's unlikely that we'll bother changing the API of FormatCommand, but if it's urgent or important, I'm up for discussing it.
Thanks @munificent for the quick reply. I'm happy with the suggested better solution. Is there a way I can track the work towards making dart fix fast enough?
Description
The
FormatCommand
should offer a--code
argument, as inFixCommand
to apply fixes to specific lint rules instead of using--fix-<non-standard-code>
(currently documented as used for non-whitespace changes only).Additional context
The
FormatCommand
is being consumed bydartdev
, a command-line utility for Dart development (part of the Dart SDK).The
package:dartdev
exposes aFixCommand
that accepts acode
argument. This is very useful, since it allows to explicitly resolve fixes for a specific linter rule.With
FixCommand
you can explicitly solve fordirectives_ordering
, by doing:dart fix --apply --code=directives_ordering # Solves for "directives_ordering"
However, the
FormatCommand
presents another solution which brings inconsistency to the overall Developer Experience offered by the command-line utility for Dart development.The text was updated successfully, but these errors were encountered: