{"record":{"id":"a38bf72835ff284f","repo":"golangci/golangci-lint","slug":"the-word-q-in-the-correction-field-should-only","errorCode":null,"errorMessage":"the word %q in the 'correction' field should only contain letters","messagePattern":"the word %q in the 'correction' field should only contain letters","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/golinters/misspell/misspell.go","lineNumber":143,"sourceCode":"}\n\nfunc appendExtraWords(replacer *misspell.Replacer, extraWords []config.MisspellExtraWords) error {\n\tif len(extraWords) == 0 {\n\t\treturn nil\n\t}\n\n\textra := make([]string, 0, len(extraWords)*2)\n\n\tfor _, word := range extraWords {\n\t\tif word.Typo == \"\" || word.Correction == \"\" {\n\t\t\treturn fmt.Errorf(\"typo (%q) and correction (%q) fields should not be empty\", word.Typo, word.Correction)\n\t\t}\n\n\t\tif strings.ContainsFunc(word.Typo, func(r rune) bool { return !unicode.IsLetter(r) }) {\n\t\t\treturn fmt.Errorf(\"the word %q in the 'typo' field should only contain letters\", word.Typo)\n\t\t}\n\t\tif strings.ContainsFunc(word.Correction, func(r rune) bool { return !unicode.IsLetter(r) }) {\n\t\t\treturn fmt.Errorf(\"the word %q in the 'correction' field should only contain letters\", word.Correction)\n\t\t}\n\n\t\textra = append(extra, strings.ToLower(word.Typo), strings.ToLower(word.Correction))\n\t}\n\n\treplacer.AddRuleList(extra)\n\n\treturn nil\n}\n","sourceCodeStart":125,"sourceCodeEnd":153,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/golinters/misspell/misspell.go#L125-L153","documentation":"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.","triggerScenarios":"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.","commonSituations":"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\".","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."],"exampleFix":"# before\nextra-words:\n  - typo: \"teh\"\n    correction: \"the best\"\n# after\nextra-words:\n  - typo: \"teh\"\n    correction: \"the\"","handlingStrategy":"validation","validationCode":"func lettersOnly(s string) bool {\n    for _, r := range s {\n        if !unicode.IsLetter(r) { return false }\n    }\n    return len(s) > 0\n}\n// reject entry if !lettersOnly(w.Correction)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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}+$."],"tags":["golang","linter","misspell","validation"],"backgroundTag":"invalid-linter-config","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}