Skip to content

Commit

Permalink
Prevent VSCode CSpell from checking all code files
Browse files Browse the repository at this point in the history
The VSCode CSpell extension (aka "code-spell-checker") 4.0.19 release
(2024-11-19) changed the `enabledFileTypes` setting default to make it
"easier to extend." The change also made CSpell check all words in all
code files, resulting in a noticeable increase in spell check errors
reported by the extension.

The `"cSpell.enabledFileTypes": { "*": false }` setting suggested in
streetsidesoftware/vscode-spell-checker#3800 does not work correctly
(streetsidesoftware/vscode-spell-checker#3836). Languages must be
configured individually.

This commit will update `cspell.json` to configure common code languages.

- Ruby is disabled to avoid checking commented-out lines in Brewfiles.
- Excluding HTML from the `languageSettings` array will allow CSpell to
  check not only comments, but also prose elements like `<p>`. It's not
  clear how to also check prose elements in JavaScript components.
- When checking Astro, Vue, and other component languages, CSpell should
  check HTML, CSS, and JS comments. All may occur in a single file.
- When checking shell, CSpell should ignore array length references
  (in Bash, the length of an array can be read with `${#ARRAY_NAME}`).
- CSpell still seems to be spell checking keys in VSCode `settings.json`
  even though JSONC is correctly configured to only check comments.

https://cspell.org/configuration/
https://github.com/streetsidesoftware/vscode-spell-checker/releases/tag/code-spell-checker-v4.0.19
  • Loading branch information
br3ndonland committed Jan 2, 2025
1 parent 02f7d34 commit 21ef5bd
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
43 changes: 43 additions & 0 deletions vscode/User/cspell.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
{
"enabledFileTypes": {
"ruby": false
},
"ignoreRegExpList": ["/(`{3})[\\s\\S]+?\\1/g", "/`([\\s\\S]+?)`/g"],
"languageSettings": [
{
"languageId": "css",
"includeRegExpList": ["CStyleComment"]
},
{
"languageId": "go",
"includeRegExpList": ["CStyleComment"]
},
{
"languageId": "hcl",
"includeRegExpList": ["/#.*/", "CStyleComment"]
},
{
"languageId": "python",
"includeRegExpList": ["/#.*/", "/('''|\"\"\")[^\\1]+?\\1/g"]
Expand All @@ -9,13 +24,41 @@
"languageId": "javascript",
"includeRegExpList": ["CStyleComment"]
},
{
"languageId": "javascriptreact",
"includeRegExpList": ["(<!--).*(-->)", "CStyleComment"]
},
{
"languageId": "json",
"includeRegExpList": ["CStyleComment"]
},
{
"languageId": "jsonc",
"includeRegExpList": ["CStyleComment"]
},
{
"languageId": "r",
"includeRegExpList": ["/#.*/"]
},
{
"languageId": "rust",
"includeRegExpList": ["CStyleComment"]
},
{
"languageId": "shellscript",
"includeRegExpList": ["/[^{]#.*/"]
},
{
"languageId": "terraform",
"includeRegExpList": ["/#.*/", "CStyleComment"]
},
{
"languageId": "typescript",
"includeRegExpList": ["CStyleComment"]
},
{
"languageId": "vue",
"includeRegExpList": ["(<!--).*(-->)", "CStyleComment"]
}
],
"words": [
Expand Down
1 change: 0 additions & 1 deletion vscode/User/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@
"aws.telemetry": false,
"cSpell.autoFormatConfigFile": false,
"cSpell.diagnosticLevel": "Information",
"cSpell.enableFiletypes": ["!jsonc"],
"cSpell.import": ["~/.dotfiles/vscode/User/cspell.json"],
"cSpell.spellCheckDelayMs": 5000,
"deno.unstable": false,
Expand Down

0 comments on commit 21ef5bd

Please sign in to comment.