{"record":{"id":"6dff99eab0997763","repo":"golangci/golangci-lint","slug":"the-word-q-in-the-typo-field-should-only-contai","errorCode":null,"errorMessage":"the word %q in the 'typo' field should only contain letters","messagePattern":"the word %q in the 'typo' field should only contain letters","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/golinters/misspell/misspell.go","lineNumber":140,"sourceCode":"\t}\n\n\treturn nil\n}\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":122,"sourceCodeEnd":153,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/golinters/misspell/misspell.go#L122-L153","documentation":"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.","triggerScenarios":"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.","commonSituations":"Users adding contractions, hyphenated terms, or multi-word phrases as typos; generated config embedding code tokens like \"os.Getenv\"; typos accidentally including punctuation.","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."],"exampleFix":"# before\nextra-words:\n  - typo: \"can't\"\n    correction: \"cannot\"\n# after\nextra-words:\n  - typo: \"cant\"\n    correction: \"cannot\"","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.Typo)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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}+$."],"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"}