Skip to content

Commit 64dda06

Browse files
authored
feat: capitalise var naming to IDs (#964)
* feat: capitalise var naming to IDs * feat: added test case for IDs case
1 parent 9abe06a commit 64dda06

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lint/utils.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ func Name(name string, allowlist, blocklist []string) (should string) {
7171
if w == 0 && unicode.IsLower(runes[w]) {
7272
u = strings.ToLower(u)
7373
}
74+
// Keep lowercase s for IDs
75+
if u == "IDS" {
76+
u = "IDs"
77+
}
7478
// All the common initialisms are ASCII,
7579
// so we can replace the bytes exactly.
7680
copy(runes[w:], []rune(u))
@@ -99,6 +103,7 @@ var commonInitialisms = map[string]bool{
99103
"HTTP": true,
100104
"HTTPS": true,
101105
"ID": true,
106+
"IDS": true,
102107
"IP": true,
103108
"JSON": true,
104109
"LHS": true,

testdata/var-naming.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package fixtures
22

33
func foo() string {
44
customId := "result"
5-
customVm := "result" // MATCH /var customVm should be customVM/
5+
customVm := "result" // MATCH /var customVm should be customVM/
6+
customIds := "result" // MATCH /var customIds should be customIDs/
67
return customId
78
}

0 commit comments

Comments
 (0)