streetsidesoftware / vscode-spell-checker

A simple source code spell checker for code
https://streetsidesoftware.github.io/vscode-spell-checker/
Other
1.38k stars 124 forks source link

Dealing with code in inline code markup #1427

Open Pomax opened 2 years ago

Pomax commented 2 years ago

If I'm writing markdown documentation and have something like this:

you just need tests to make sure that at critical points in your code paths,
`data instanceof ThatModelTheyShouldBe` is still true.

then that instanceof gets highlighted as a potential problem case. However, in JS (but not in every language, and certainly not in plain English) this is a known keyword, so it feels like there's something missing, in order to tell Code Spell Checker that this is not to be added to the dictionary as a proper spelling, but to accept it inside code formatting (inline or not) by telling it which language(s) it is going to run across in my documentation.

Jason3S commented 2 years ago

@Pomax ,

There are a few things you can try:

Add the typescript dictionary

you just need tests to make sure that at critical points in your code paths,
`data instanceof ThatModelTheyShouldBe` is still true.

The line below is a comment and will not show up in the rendered document:
<!--- cspell:dictionaries typescript  -->

Ignore the word instanceof

you just need tests to make sure that at critical points in your code paths,
`data instanceof ThatModelTheyShouldBe` is still true.

<!--- cspell:ignore instanceof  -->
Pomax commented 2 years ago

Cheers. I was hoping for something that didn't require "per project"/"per file" exceptions though, since I have a lot of projects to which this would apply.

Jason3S commented 2 years ago

You have a few options:

VS Code

Add typescript as a dictionary

image

    "cSpell.customDictionaries": {
        "typescript": true
    },

Add typescript as a dictionary only formarkdown`

image

    "cSpell.languageSettings": [
    {
        "languageId": "markdown",
        "dictionaries": ["typescript"]
    }
    ],