@@ -27,7 +27,10 @@ const (
2727var (
2828 ErrInvalidName = errors .New ("formatter name must only contain alphanumeric characters, `_` or `-`" )
2929 // ErrCommandNotFound is returned when the Command for a Formatter is not available.
30- ErrCommandNotFound = errors .New ("formatter command not found in PATH" )
30+ ErrCommandNotFound = errors .New ("formatter command not found in PATH" )
31+ ErrNoPositionalArgSupport = errors .New (
32+ "formatter cannot format multiple files at once (it violates rule 1 of the formatter specification)" ,
33+ )
3134
3235 nameRegex = regexp .MustCompile ("^[a-zA-Z0-9_-]+$" )
3336)
@@ -50,12 +53,12 @@ func (f *Formatter) Name() string {
5053 return f .name
5154}
5255
53- func (f * Formatter ) ViolatesRule1 () bool {
54- if f .config .ViolatesRule1 == nil {
56+ func (f * Formatter ) HasNoPositionalArgSupport () bool {
57+ if f .config .NoPositionalArgSupport == nil {
5558 return false
5659 }
5760
58- return * f .config .ViolatesRule1
61+ return * f .config .NoPositionalArgSupport
5962}
6063
6164func (f * Formatter ) Priority () int {
@@ -90,10 +93,8 @@ func (f *Formatter) Hash(h hash.Hash) error {
9093}
9194
9295func (f * Formatter ) Apply (ctx context.Context , files []* walk.File ) error {
93- if len (files ) > 1 && f .ViolatesRule1 () {
94- return fmt .Errorf (
95- "formatter cannot format %d files at once (it violates rule 1 of the formatter specification)" , len (files ),
96- )
96+ if len (files ) > 1 && f .HasNoPositionalArgSupport () {
97+ return ErrNoPositionalArgSupport
9798 }
9899
99100 start := time .Now ()
0 commit comments