From 0c4f8806d75ef7490d4c92e9d8f8a3239356b2bc Mon Sep 17 00:00:00 2001 From: Joseph Kato Date: Wed, 25 Dec 2024 09:20:57 -0700 Subject: [PATCH] fix: handle regex-based replacements --- internal/check/manager.go | 4 +--- testdata/features/misc.feature | 1 + testdata/fixtures/vocab/Basic/test.md | 6 +++++- .../vocab/styles/config/vocabularies/Basic/accept.txt | 9 +++++---- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/internal/check/manager.go b/internal/check/manager.go index adbe55e8..f94b3533 100755 --- a/internal/check/manager.go +++ b/internal/check/manager.go @@ -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 diff --git a/testdata/features/misc.feature b/testdata/features/misc.feature index 62a2b696..ddbe33b7 100755 --- a/testdata/features/misc.feature +++ b/testdata/features/misc.feature @@ -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 diff --git a/testdata/fixtures/vocab/Basic/test.md b/testdata/fixtures/vocab/Basic/test.md index 97ad5f5c..ab9e21fb 100755 --- a/testdata/fixtures/vocab/Basic/test.md +++ b/testdata/fixtures/vocab/Basic/test.md @@ -22,4 +22,8 @@ ABC-DEf plug -Github \ No newline at end of file +Github + +This is no good oBservability. + +This Observability and observability are okay. diff --git a/testdata/fixtures/vocab/styles/config/vocabularies/Basic/accept.txt b/testdata/fixtures/vocab/styles/config/vocabularies/Basic/accept.txt index f2672456..b5f0fc7b 100755 --- a/testdata/fixtures/vocab/styles/config/vocabularies/Basic/accept.txt +++ b/testdata/fixtures/vocab/styles/config/vocabularies/Basic/accept.txt @@ -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 \ No newline at end of file