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

  1. Change the correction value to a single alphabetic word.
  2. If the intended fix is multi-word, choose the nearest single-word correction or fix such cases manually/with a different tool.
  3. Strip punctuation/digits from the correction.
  4. 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

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


AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02). Data as JSON: /api/errors/a38bf72835ff284f. Report an issue: GitHub.