From c21765d21c8cc3611d0f44a89ce2dd83e32ff7d4 Mon Sep 17 00:00:00 2001 From: secustor Date: Fri, 6 Feb 2026 12:15:56 +0100 Subject: [PATCH 1/2] feat(lint): apply defaultIgnoreDirectories to nested directories --- internal/core/util.go | 4 ++- internal/core/util_test.go | 71 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/internal/core/util.go b/internal/core/util.go index d7fad73e6..70fbdb894 100755 --- a/internal/core/util.go +++ b/internal/core/util.go @@ -3,6 +3,7 @@ package core import ( "bytes" "fmt" + "path/filepath" "regexp" "strings" "unicode" @@ -44,7 +45,8 @@ func WhitespaceToSpace(msg string) string { } // ShouldIgnoreDirectory will check if directory should be ignored -func ShouldIgnoreDirectory(directoryName string) bool { +func ShouldIgnoreDirectory(directoryPath string) bool { + directoryName := filepath.Base(directoryPath) for _, directory := range defaultIgnoreDirectories { if directory == directoryName { return true diff --git a/internal/core/util_test.go b/internal/core/util_test.go index 3997154b5..f9e853321 100755 --- a/internal/core/util_test.go +++ b/internal/core/util_test.go @@ -88,3 +88,74 @@ func TestNormalizePath(t *testing.T) { t.Errorf("expected = %v, got = %v", expectedOutput, result) } } + +func TestShouldIgnoreDirectory(t *testing.T) { + tests := []struct { + name string + path string + expected bool + }{ + // Direct directory names + { + name: "direct node_modules", + path: "node_modules", + expected: true, + }, + { + name: "direct .git", + path: ".git", + expected: true, + }, + // Nested paths with ignored directories + { + name: "nested node_modules", + path: "plugins/foo/node_modules", + expected: true, + }, + { + name: "nested .git in worktree", + path: "worktree-a/.git", + expected: true, + }, + { + name: "deeply nested node_modules", + path: "project/src/components/node_modules", + expected: true, + }, + { + name: "node_modules in path with backslashes", + path: filepath.Join("project", "src", "node_modules"), + expected: true, + }, + // Non-ignored directories + { + name: "regular directory", + path: "src", + expected: false, + }, + { + name: "nested regular directory", + path: "plugins/foo", + expected: false, + }, + { + name: "directory containing node_modules in name", + path: "my_node_modules_backup", + expected: false, + }, + { + name: "directory containing .git in name", + path: "my.github", + expected: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + result := ShouldIgnoreDirectory(tt.path) + if result != tt.expected { + t.Errorf("ShouldIgnoreDirectory(%q) = %v, expected %v", tt.path, result, tt.expected) + } + }) + } +} From b86ca498937a40310e95a22a1949910913d474ac Mon Sep 17 00:00:00 2001 From: secustor Date: Mon, 9 Feb 2026 11:34:40 +0100 Subject: [PATCH 2/2] do not ignore empty directory name --- internal/core/util.go | 4 ++++ internal/core/util_test.go | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/internal/core/util.go b/internal/core/util.go index 70fbdb894..a8d48fc47 100755 --- a/internal/core/util.go +++ b/internal/core/util.go @@ -47,6 +47,10 @@ func WhitespaceToSpace(msg string) string { // ShouldIgnoreDirectory will check if directory should be ignored func ShouldIgnoreDirectory(directoryPath string) bool { directoryName := filepath.Base(directoryPath) + // if a current dir is detected e.g with directoryPath being an empty string always process + if directoryName == "." { + return false + } for _, directory := range defaultIgnoreDirectories { if directory == directoryName { return true diff --git a/internal/core/util_test.go b/internal/core/util_test.go index f9e853321..2262a77f9 100755 --- a/internal/core/util_test.go +++ b/internal/core/util_test.go @@ -95,6 +95,11 @@ func TestShouldIgnoreDirectory(t *testing.T) { path string expected bool }{ + { + name: "empty directory name", + path: "", + expected: false, + }, // Direct directory names { name: "direct node_modules",