Skip to content

Commit

Permalink
fix: handle regex-based replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkato committed Dec 25, 2024
1 parent df4a934 commit 0c4f880
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 1 addition & 3 deletions internal/check/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,7 @@ func (mgr *Manager) loadVocabRules() {
if len(mgr.Config.AcceptedTokens) > 0 {
vocab := defaultRules["Terms"]
for _, term := range mgr.Config.AcceptedTokens {
if core.IsPhrase(term) {
vocab["swap"].(map[string]string)[strings.ToLower(term)] = term
}
vocab["swap"].(map[string]string)[strings.ToLower(term)] = term
}
if level, ok := mgr.Config.RuleToLevel["Vale.Terms"]; ok {
vocab["level"] = level
Expand Down
1 change: 1 addition & 0 deletions testdata/features/misc.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Feature: Misc
test.md:19:1:Vale.Terms:Use 'ABCDEF' instead of 'ABCDEf'.
test.md:21:1:Vale.Terms:Use 'ABC-DEF' instead of 'ABC-DEf'.
test.md:23:1:Vale.Terms:Use 'PLuG' instead of 'plug'.
test.md:27:17:Vale.Terms:Use '[Oo]bservability' instead of 'oBservability'.
"""

Scenario: Multiple Vocabs
Expand Down
6 changes: 5 additions & 1 deletion testdata/fixtures/vocab/Basic/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ ABC-DEf

plug

Github
Github

This is no good oBservability.

This Observability and observability are okay.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
(?i)GitHub
[Oo]bservability
[pP]y.*\b
definately
# This is a comment
ABC-DEF
ABCDEF
definately
Documentarians
Log4j
ABCDEF
ABC-DEF
PLuG
(?i)GitHub

0 comments on commit 0c4f880

Please sign in to comment.