diff --git a/docs/to-do.md b/docs/to-do.md index 5e26d49..a2fe200 100644 --- a/docs/to-do.md +++ b/docs/to-do.md @@ -2,8 +2,6 @@ * Add a fixer for the 'indent_style' rule. -* Add a non-standard rule to ignore directories. - * Optimize speed and memory usage. * Document how to install. diff --git a/editorconfig/apply.go b/editorconfig/apply.go index 463482e..f7af454 100644 --- a/editorconfig/apply.go +++ b/editorconfig/apply.go @@ -26,6 +26,10 @@ func GetRulesToApplyToSourcePath(sourcePath string, cfs []ConfigFile) map[string } } + if isIgnored, _ := rules["ignore"]; isIgnored == "true" { + return make(map[string]string) + } + delete(rules, "root") if indentStyleValue, _ := rules["indent_style"]; indentStyleValue == "tab" { diff --git a/editorconfig/apply_test.go b/editorconfig/apply_test.go index 593e7cd..bf2edff 100644 --- a/editorconfig/apply_test.go +++ b/editorconfig/apply_test.go @@ -32,3 +32,16 @@ func TestGetRulesToApplyToSourcePathWhenNoRulesShouldApply(t *testing.T) { t.Error("No rules should be applied for the file") } } + +func TestGetRulesToApplyToSourcePathWhenPathShouldBeIgnored(t *testing.T) { + result := GetRulesToApplyToSourcePath( + "some-file-to-ignore.ignored", + []ConfigFile{ + CreateConfigFileStruct("tests/.editorconfig"), + }, + ) + + if len(result) != 0 { + t.Error("No rules should be applied for the file") + } +} diff --git a/editorconfig/tests/.editorconfig b/editorconfig/tests/.editorconfig index 7c753d2..a8f4f94 100644 --- a/editorconfig/tests/.editorconfig +++ b/editorconfig/tests/.editorconfig @@ -13,3 +13,6 @@ trim_trailing_whitespace = false [**.go] indent_style = tabs + +[**.ignored] +ignore = true