golangci/golangci-lint · error
the word %q in the 'correction' field should only contain le
Error message
the word %q in the 'correction' field should only contain letters
What it means
appendExtraWords applies the same letters-only rule to the correction field: any non-letter rune in a custom correction is rejected because corrections are inserted as word rules in the misspell dictionary. The word appears in the error message to identify the offending entry.
Source
Thrown at pkg/golinters/misspell/misspell.go:143
}
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 correction value to a single alphabetic word.
- If the intended fix is multi-word, choose the nearest single-word correction or fix such cases manually/with a different tool.
- Strip punctuation/digits from the correction.
- Test entries against ^\p{L}+$ before adding them to the config.
Example fix
# before
extra-words:
- typo: "teh"
correction: "the best"
# after
extra-words:
- typo: "teh"
correction: "the" 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.Correction) Prevention
- Use single alphabetic words for correction values.
- Map typos to the nearest single-word fix rather than multi-word phrases.
- Pre-validate entries with regex ^\p{L}+$.
When it happens
Trigger: An extra-words entry whose correction contains a non-letter rune — e.g. correction: "can not" (space), "no-way" (hyphen), "ok1" (digit) — during misspell replacer construction.
Common situations: Users mapping a typo to a multi-word fix or a symbol; corrections pasted with trailing punctuation; automation generating corrections from strings like "don't".
Related errors
- typo (%q) and correction (%q) fields should not be empty
- the word %q in the 'typo' field should only contain letters
- 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/a38bf72835ff284f.
Report an issue: GitHub.