golangci/golangci-lint · error
the word %q in the 'typo' field should only contain letters
Error message
the word %q in the 'typo' field should only contain letters
What it means
appendExtraWords requires each extra-words typo field to contain only letters (unicode.IsLetter). Values with spaces, digits, punctuation or symbols are rejected, since the misspell replacer works on whole words and cannot match arbitrary tokens.
Source
Thrown at pkg/golinters/misspell/misspell.go:140
}
return nil
}
func appendExtraWords(replacer *misspell.Replacer, extraWords []config.MisspellExtraWords) error {
if len(extraWords) == 0 {
return nil
}
extra := make([]string, 0, len(extraWords)*2)
for _, word := range extraWords {
if word.Typo == "" || word.Correction == "" {
return fmt.Errorf("typo (%q) and correction (%q) fields should not be empty", word.Typo, word.Correction)
}
if strings.ContainsFunc(word.Typo, func(r rune) bool { return !unicode.IsLetter(r) }) {
return fmt.Errorf("the word %q in the 'typo' field should only contain letters", word.Typo)
}
if strings.ContainsFunc(word.Correction, func(r rune) bool { return !unicode.IsLetter(r) }) {
return fmt.Errorf("the word %q in the 'correction' field should only contain letters", word.Correction)
}
extra = append(extra, strings.ToLower(word.Typo), strings.ToLower(word.Correction))
}
replacer.AddRuleList(extra)
return nil
}
View on GitHub (pinned to ed7a235d2d)
Solutions
- Change the typo value to a single alphabetic word (letters only).
- Split multi-word phrases and register each word separately.
- Remove punctuation/digits or pick the closest single-word misspelling.
- Validate entries locally with a quick regex ^\p{L}+$ before adding to config.
Example fix
# before
extra-words:
- typo: "can't"
correction: "cannot"
# after
extra-words:
- typo: "cant"
correction: "cannot" Defensive patterns
Strategy: validation
Validate before calling
func lettersOnly(s string) bool {
for _, r := range s {
if !unicode.IsLetter(r) { return false }
}
return len(s) > 0
}
// reject entry if !lettersOnly(w.Typo) Prevention
- Use single alphabetic words for typo values; no spaces, digits, or punctuation.
- Reject contractions/hyphenated phrases when generating config entries.
- Pre-validate entries with regex ^\p{L}+$.
When it happens
Trigger: An extra-words entry whose typo contains a non-letter rune — e.g. "can't" (apostrophe), "id-number" (hyphen), "foo2" (digit), or "bad word" (space) — during misspell replacer construction.
Common situations: Users adding contractions, hyphenated terms, or multi-word phrases as typos; generated config embedding code tokens like "os.Getenv"; typos accidentally including punctuation.
Related errors
- typo (%q) and correction (%q) fields should not be empty
- the word %q in the 'correction' field should only contain le
- unknown locale: %q
- process extra words: %w
- can't get file %s contents: %w
AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02).
Data as JSON: /api/errors/6dff99eab0997763.
Report an issue: GitHub.