cspell
cspell copied to clipboard
ESLint Plugin: Configuration option to add words to the dictionary
When using words that aren't recognized by cspell (in my case "textbox") there is no way to add these words to the dictionary (Unless I have missed something). The only way to disable the warning/error is by disabling the ESLint rule for that line.
It should be possible to modify the dictionary used by cspell in the ESLint options. This could be as simple as providing an array of strings. I think the vscode plugin already supports that.
I tried to use the "eslint-plugin-spellcheck" but unfortunately, it doesn't support "ignoreImports" or "ignoreImportProperties" and also doesn't provide suggestions.
@tim-fabian,
Let me see if I understand you:
You would like the plugin to offer the option to add a word to your dictionary in addition to the suggestions.
I think that is a viable new feature.
Possible Workaround
In the meantime, if you are using the VSCode Code Spell Checker extension, it is possible to bind keys to have the extension add it to your CSpell configuration.
Related to #2782
It is going to be a while before the library used to update CSpell Configuration files is ported to CSpell.
It might be possible to make a simpler option for use with the ESLint Plugin:
-
addWordsToFile: <path>
This option would allow adding words to either acspell.json
file or a text file.
@Jason3S
Let me see if I understand you
You understood that correctly.
It might be possible to make a simpler option for use with the ESLint Plugin:
- addWordsToFile:
This option would allow adding words to either a cspell.json file or a text file.
That sounds great and should probably be enough configuration for most users.
Needs a solution to Change Request: Notify plugins when a fix has been applied · Issue #16143 · eslint/eslint to work.
@Jason3S
I added the option but it is not working for me, what could I be missing?
"@cspell/spellchecker": ["warn", { customWordListFile: "words.txt" }],
"words.txt" is in the same directory as ".eslintrc.js" and "cspell.config.js"
@marcoSven,
As far as I can tell, ESLint plug-ins do not know which file loaded them. If you use a relative path name, the plug-in will use the current working directory as the base.
Please try:
"@cspell/spellchecker": ["warn", { customWordListFile: __dirname + "/words.txt" }],
@Jason3S thank you for the suggestion unfortunately using the absolute path is also not working.
Using eslint v8.6.0 and cspell plgin v6.4.2
What else can I try?
id: @cspell/spellchecker cwd: /users/marco/project filename: /users/marco/project/text.js physicalFilename: /users/marco/project/text.js scope: global
id: @cspell/spellchecker cwd: /users/marco/project filename: /users/marco/project/text.js physicalFilename: /users/marco/project/text.js scope: global
Comment.line: ' spell spellchek' Suggestions: [ 'spellcheck', 'spellchecks', 'shellcheck', 'spellchecked', 'spellchecker', 'sepulcher', "spellcheck's", 'spelled', [length]: 8 ]
/users/marco/project/text.js 1:10 warning Unknown word: "spellchek" @cspell/spellchecker
✖ 1 problem (0 errors, 1 warning)


@marcoSven What are you hoping for? Option to add words or to read the words from you list?
To add words, use: ”addWords”: true
opinion.
Reading words should work fine. But, adding words if flaky. The hack used to support that option does play well with the ESLint plug-in. Sometimes words are added as you type.
Yes, I would like to add words to the dictionary from the quick fix.
Getting this error below, I must be missing something obvious.
"Configuration for rule "@cspell/spellchecker" is invalid: Value {"addWords":true,"customWordListFile":"/users/marco/project/words.txt","checkComments":true,"checkIdentifiers":true,"checkStringTemplates":true,"checkStrings":true,"debugMode":false,"generateSuggestions":true,"ignoreImportProperties":true,"ignoreImports":true,"numSuggestions":8} should NOT have additional properties."
Here is my config { addWords: true, customWordListFile: __dirname + "/words.txt",
Don't see the addWords
option here
Sometimes words are added as you type.
Good to know thanks.
I'm on my phone, so please forgive the formatting:
Please try something like:
{ customWordListFile: { path:"...", addWords: true }}
🙏 that works!
@marcoSven,
Please double check the dictionary file. It might be full of junk that was added as you type. See: https://github.com/streetsidesoftware/cspell/issues/3233#issuecomment-1188848954
Thank you, I have not tested it yet.
Per the RFC discussion on ESLint (https://github.com/eslint/rfcs/pull/93), using ESLint to add words to a file is not possible.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.