Open jerone opened 7 months ago
Apparently, JavaScript config files are not supported: https://github.com/streetsidesoftware/vscode-spell-checker/blob/df8229e8d7a584ffecfe9048438eb91187583dfb/packages/client/src/settings/configFileReadWrite.ts#L17-L21
Aldo, it's in the list of supported config file names: https://cspell.org/configuration/#configuration
@jerone,
It is not possible for the spell checker to add words to a JavaScript file. The complexity of correctly adding words to code is beyond the capabilities of the spell checker. If you create a dictionary file, the spell check can add words to that.
cspell.config.js
const cspell = {
version: "0.2",
language: "en",
dictionaryDefinitions: [
{ name: "custom-words", path: "./words.txt", addWords: true },
],
dictionaries: ["custom-words"],
};
module.exports = cspell;
words.txt
# one word per line.
Thank for the explanation and the workaround (will try that later).
The confusion started because of the "Add: XXX to config: project/cspell.config.js" quick fix:
Maybe clicking that can result in a message that only JSON config files are supported. Or hide the option at all if the project config file is not of a supported type.
@jerone,
Thank you. I'll look into why it was presented as an option. It should not have been.
Adding a word to the words list in the config file, within VSCode, results in the following error modal:
The output for CSpell was empty, but I did find the error in the "Window" output filter.
``` 2024-02-17 12:58:06.650 [error] [Extension Host] Error: context (Register command: cSpell.addWordsToConfigFileFromServer): [tl [Error]: Unhandled file type: "cspell.config.js" at wq (c:\Users\jeron\.vscode\extensions\streetsidesoftware.code-spell-checker-3.0.1\packages\client\dist\extension.js:402:7874) at rg (c:\Users\jeron\.vscode\extensions\streetsidesoftware.code-spell-checker-3.0.1\packages\client\dist\extension.js:402:7810) at Cc (c:\Users\jeron\.vscode\extensions\streetsidesoftware.code-spell-checker-3.0.1\packages\client\dist\extension.js:405:6760) at cSpell.addWordsToConfigFileFromServer (c:\Users\jeron\.vscode\extensions\streetsidesoftware.code-spell-checker-3.0.1\packages\client\dist\extension.js:407:2314) at c:\Users\jeron\.vscode\extensions\streetsidesoftware.code-spell-checker-3.0.1\packages\client\dist\extension.js:405:16835 at c:\Users\jeron\.vscode\extensions\streetsidesoftware.code-spell-checker-3.0.1\packages\client\dist\extension.js:405:16767 at An (c:\Users\jeron\.vscode\extensions\streetsidesoftware.code-spell-checker-3.0.1\packages\client\dist\extension.js:405:16771) at c:\Users\jeron\.vscode\extensions\streetsidesoftware.code-spell-checker-3.0.1\packages\client\dist\extension.js:405:16828 at s.h (c:\Users\jeron\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:150:175243) at s.g (c:\Users\jeron\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:150:174235) at s.executeCommand (c:\Users\jeron\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:150:174142) at d.h (c:\Users\jeron\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:150:177580) at s.h (c:\Users\jeron\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:150:175243) at s.$executeContributedCommand (c:\Users\jeron\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:150:176103) at d.S (c:\Users\jeron\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:147:5520) at d.Q (c:\Users\jeron\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:147:5286) at d.M (c:\Users\jeron\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:147:4376) at d.L (c:\Users\jeron\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:147:3455) at g.value (c:\Users\jeron\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:147:2242) at r.y (c:\Users\jeron\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:1902) at r.fire (c:\Users\jeron\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:2119) at n.fire (c:\Users\jeron\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:105:14073) at g.value (c:\Users\jeron\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:173:8051) at r.y (c:\Users\jeron\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:1902) at r.fire (c:\Users\jeron\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:80:2119) at n.fire (c:\Users\jeron\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:105:14073) at MessagePortMain.Config file
Version
VSCode: 1.86.2 (user setup) Code Spell Checker extension: v3.0.1 OS: Windows_NT x64 10.0.19045
Steps to reproduce
cspell.config.js
with the contents from above.Expected behavior
Expected no error and unknown word to be added to the words list in
cspell.config.js
.