Skip to content

Commit bb013de

Browse files
committed
MINOR: add language dictionaries for Go, Python, and WebJS
This commit introduces dedicated text-based dictionaries for Golang, Python, and Web/JS ecosystems to prevent common programming keywords, built-ins, and framework-specific terms from being flagged as spelling errors in commit messages. Additionally, it refactors the match package by moving the previously hardcoded Go keywords into a separate golang_dict.go file, improving code readability. A new test was also added to ensure that words from these embedded language dictionaries are successfully loaded into the global acceptable words list.
1 parent b140aba commit bb013de

7 files changed

Lines changed: 270 additions & 18 deletions

File tree

aspell/dictionaries/golang.txt

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
break
2+
default
3+
func
4+
interface
5+
select
6+
case
7+
defer
8+
go
9+
map
10+
struct
11+
chan
12+
else
13+
goto
14+
package
15+
switch
16+
const
17+
fallthrough
18+
if
19+
range
20+
type
21+
continue
22+
for
23+
import
24+
return
25+
var
26+
bool
27+
byte
28+
complex64
29+
complex128
30+
error
31+
float32
32+
float64
33+
int
34+
int8
35+
int16
36+
int32
37+
int64
38+
rune
39+
string
40+
uint
41+
uint8
42+
uint16
43+
uint32
44+
uint64
45+
uintptr
46+
len
47+
cap
48+
str
49+
filepath
50+
url
51+
Fatalf
52+
ctx
53+
Println
54+
Stdin
55+
stdout
56+
stderr
57+
Stdout
58+
Stderr
59+
errorf
60+
println
61+
Sprintf
62+
Printf
63+
Unmarshal
64+
Getenv
65+
Errorf
66+
Atoi
67+
EOF
68+
exec
69+
iter
70+
gomemlimit
71+
gomaxprocs
72+
gogc
73+
godebug
74+
goflags
75+
goos
76+
goarch
77+
gopath
78+
goroot
79+
goproxy
80+
gocache
81+
gomodcache
82+
goprivate
83+
gotoolchain
84+
cgo
85+
tt
86+
yml
87+
ok
88+
cmd
89+
utf
90+
oauth
91+
args

aspell/dictionaries/python.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
def
2+
elif
3+
lambda
4+
nonlocal
5+
async
6+
await
7+
del
8+
yield
9+
assert
10+
raise
11+
except
12+
finally
13+
str
14+
int
15+
bool
16+
dict
17+
len
18+
repr
19+
isinstance
20+
enumerate
21+
kwargs
22+
args
23+
init
24+
dunder
25+
classmethod
26+
staticmethod
27+
iterable
28+
iterator
29+
namedtuple
30+
dataclass
31+
async
32+
asyncio
33+
numpy
34+
pandas
35+
pytest
36+
pyproject
37+
venv
38+
virtualenv
39+
pip
40+
setuptools
41+
sys
42+
os
43+
stdin
44+
stdout
45+
stderr
46+
utf
47+
json
48+
yaml
49+
toml
50+
regex
51+
stdlib
52+
traceback

aspell/dictionaries/webjs.txt

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
const
2+
let
3+
async
4+
await
5+
typeof
6+
instanceof
7+
undefined
8+
null
9+
func
10+
enum
11+
interface
12+
readonly
13+
namespace
14+
keyof
15+
infer
16+
tsconfig
17+
eslint
18+
prettier
19+
webpack
20+
vite
21+
rollup
22+
babel
23+
npm
24+
npx
25+
pnpm
26+
yarn
27+
nodejs
28+
stdout
29+
stderr
30+
stdin
31+
buffer
32+
middleware
33+
async
34+
fetch
35+
json
36+
jsx
37+
tsx
38+
dom
39+
api
40+
url
41+
uri
42+
href
43+
runtime
44+
config
45+
env
46+
util
47+
utils
48+
plugin
49+
plugins
50+
vue
51+
vuex
52+
pinia
53+
nuxt
54+
ref
55+
reactive
56+
computed
57+
watch
58+
watcher
59+
props
60+
emit
61+
emits
62+
slot
63+
slots
64+
setup
65+
composable
66+
composables
67+
directive
68+
mixin
69+
mixins
70+
lifecycle
71+
mounted
72+
unmounted
73+
component
74+
components

aspell/dictionaries_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package aspell
2+
3+
import "testing"
4+
5+
func TestEmbeddedLanguageDictionariesLoaded(t *testing.T) {
6+
// One representative word per added language wordlist.
7+
for _, word := range []string{"gomemlimit", "gotoolchain", "kwargs", "asyncio", "pinia", "composable"} {
8+
if _, ok := acceptableWordsGlobal[word]; !ok {
9+
t.Errorf("expected %q loaded from embedded dictionaries", word)
10+
}
11+
}
12+
}

match/golang.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,7 @@ func GetImportWordsFromGoFile(filename string) []string {
2727
}
2828
fileContent := string(data)
2929

30-
var importWords []string
31-
importWords = append(
32-
importWords,
33-
"break", "default", "func", "interface", "select",
34-
"case", "defer", "go", "map", "struct",
35-
"chan", "else", "goto", "package", "switch",
36-
"const", "fallthrough", "if", "range", "type",
37-
"continue", "for", "import", "return", "var",
38-
"bool", "byte", "complex64", "complex128",
39-
"error", "float32", "float64", "int",
40-
"int8", "int16", "int32", "int64", "rune", "string",
41-
"uint", "uint8", "uint16", "uint32", "uint64", "uintptr",
42-
"str", "len", "cap", "filepath", "url", "Fatalf", "ctx",
43-
"Println", "Stdin", "stdout", "stderr", "Stdout", "Stderr",
44-
"errorf", "println", "Sprintf", "Printf", "Unmarshal", "args",
45-
"Getenv", "Errorf", "tt", "yml", "ok", "cmd", "utf", "Atoi",
46-
"oauth", "EOF", "exec", "iter",
47-
)
30+
importWords := append([]string(nil), goDictionary...)
4831
findImports(fileContent, "import (", ")", func(data string) {
4932
words := strings.FieldsFunc(data, func(r rune) bool {
5033
return r == '\n' || r == '\t' || r == '/' || r == '.'

match/golang_dict.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package match
2+
3+
// goDictionary lists Go-specific words that aspell would otherwise flag in
4+
// commit message bodies and diffs. Prepended to the imports extracted per file.
5+
// Lowercased at use; case here is only for readability.
6+
var goDictionary = []string{
7+
// keywords
8+
"break", "default", "func", "interface", "select",
9+
"case", "defer", "go", "map", "struct",
10+
"chan", "else", "goto", "package", "switch",
11+
"const", "fallthrough", "if", "range", "type",
12+
"continue", "for", "import", "return", "var",
13+
14+
// predeclared types and builtins
15+
"bool", "byte", "complex64", "complex128",
16+
"error", "float32", "float64", "int",
17+
"int8", "int16", "int32", "int64", "rune", "string",
18+
"uint", "uint8", "uint16", "uint32", "uint64", "uintptr",
19+
"len", "cap",
20+
21+
// common stdlib identifiers
22+
"str", "filepath", "url", "Fatalf", "ctx",
23+
"Println", "Stdin", "stdout", "stderr", "Stdout", "Stderr",
24+
"errorf", "println", "Sprintf", "Printf", "Unmarshal",
25+
"Getenv", "Errorf", "Atoi", "EOF", "exec", "iter",
26+
27+
// go tooling and environment variables
28+
"gomemlimit", "gomaxprocs", "gogc", "godebug", "goflags",
29+
"goos", "goarch", "gopath", "goroot", "goproxy",
30+
"gocache", "gomodcache", "goprivate", "gotoolchain", "cgo",
31+
32+
// project-specific identifiers
33+
"tt", "yml", "ok", "cmd", "utf", "oauth", "args",
34+
}

match/golang_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ func TestGetImportWordsFromFile(t *testing.T) {
2727
"errorf", "println", "Sprintf", "Printf", "Unmarshal", "args",
2828
"Getenv", "Errorf", "tt", "yml", "ok", "cmd", "utf", "Atoi",
2929
"oauth", "EOF", "exec", "iter",
30+
"gomemlimit", "gomaxprocs", "gogc", "godebug", "goflags",
31+
"goos", "goarch", "gopath", "goroot", "goproxy",
32+
"gocache", "gomodcache", "goprivate", "gotoolchain", "cgo",
3033
"strings", "slices", "testing",
3134
}},
3235
{"test 2", "match.go", []string{
@@ -44,6 +47,9 @@ func TestGetImportWordsFromFile(t *testing.T) {
4447
"errorf", "println", "Sprintf", "Printf", "Unmarshal", "args",
4548
"Getenv", "Errorf", "tt", "yml", "ok", "cmd", "utf", "Atoi",
4649
"oauth", "EOF", "exec", "iter",
50+
"gomemlimit", "gomaxprocs", "gogc", "godebug", "goflags",
51+
"goos", "goarch", "gopath", "goroot", "goproxy",
52+
"gocache", "gomodcache", "goprivate", "gotoolchain", "cgo",
4753
"filepath", "path", "strings", "regexp",
4854
}},
4955
}

0 commit comments

Comments
 (0)