Repository: editorconfig-checker/editorconfig-checker (go)

Issue:
Empty `Format` field in config file breaks ECC 
I've upgraded to 3.12 just now and I got following error which I can't figure out:

```
$ ec
"" is not a valid output format
$ ec --version
"" is not a valid output format
```

Using MacOS Sequoia. Running ec on virtual environment for my work.

Any help?

Pull request:
fix: empty format in the config file should be treated as Default
Some of our users have an empty Format in their config file - this should be treated as having requested the "default" output format, as it would be when the option is missing entirely.

Closes #430

Patch:
diff --git a/pkg/outputformat/outputformat.go b/pkg/outputformat/outputformat.go
index 37070bf..aa88216 100644
--- a/pkg/outputformat/outputformat.go
+++ b/pkg/outputformat/outputformat.go
@@ -2,6 +2,7 @@
 package outputformat
 
 import (
+	"cmp"
 	"fmt"
 	"slices"
 	"strings"
@@ -39,7 +40,7 @@ func (format OutputFormat) MarshalText() ([]byte, error) {
 }
 
 func (format *OutputFormat) UnmarshalText(data []byte) error {
-	*format = OutputFormat(string(data))
+	*format = OutputFormat(cmp.Or(string(data), "default"))
 	if !format.IsValid() {
 		return fmt.Errorf("%q is not a valid output format", data)
 	}


Test patch:
diff --git a/pkg/outputformat/outputformat_test.go b/pkg/outputformat/outputformat_test.go
index e6853fe..f9aeb4c 100644
--- a/pkg/outputformat/outputformat_test.go
+++ b/pkg/outputformat/outputformat_test.go
@@ -56,3 +56,14 @@ func TestUnmarshallingBrokenInputFails(t *testing.T) {
 		t.Error("unmarshalling did not recognize an invalid value and unmarshalled it anyway")
 	}
 }
+
+func TestUnmarshallingEmptyFormat(t *testing.T) {
+	var working OutputFormat
+	err := working.UnmarshalText([]byte(""))
+	if err != nil {
+		t.Errorf("unmarshalling an empty string as the default output format failed: %v", err)
+	}
+	if working != Default {
+		t.Error("unmarshalling an empty string did not return the default output format")
+	}
+}