Skip to content

Commit

Permalink
feat: capitalise var naming to IDs (#964)
Browse files Browse the repository at this point in the history
* feat: capitalise var naming to IDs

* feat: added test case for IDs case
  • Loading branch information
VincentBaron committed Jan 17, 2024
1 parent 9abe06a commit 64dda06
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lint/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ func Name(name string, allowlist, blocklist []string) (should string) {
if w == 0 && unicode.IsLower(runes[w]) {
u = strings.ToLower(u)
}
// Keep lowercase s for IDs
if u == "IDS" {
u = "IDs"
}
// All the common initialisms are ASCII,
// so we can replace the bytes exactly.
copy(runes[w:], []rune(u))
Expand Down Expand Up @@ -99,6 +103,7 @@ var commonInitialisms = map[string]bool{
"HTTP": true,
"HTTPS": true,
"ID": true,
"IDS": true,
"IP": true,
"JSON": true,
"LHS": true,
Expand Down
3 changes: 2 additions & 1 deletion testdata/var-naming.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package fixtures

func foo() string {
customId := "result"
customVm := "result" // MATCH /var customVm should be customVM/
customVm := "result" // MATCH /var customVm should be customVM/
customIds := "result" // MATCH /var customIds should be customIDs/
return customId
}

0 comments on commit 64dda06

Please sign in to comment.