cspell icon indicating copy to clipboard operation
cspell copied to clipboard

CSpell ESLint Plugin support Markdown

Open jerone opened this issue 3 years ago • 6 comments

It looks like the CSpell ESLint Plugin does not support Markdown files.

Via overrides it's possible to extend ESLint with different parsers. For example for Markdown files. It would be nice if CSpell ESLint Plugin would support that.

Example ESLint config file.
{
  "root": true,
  "overrides": [
    {
      "files": ["*.md"],
      "parser": "eslint-plugin-markdownlint/parser",
      "extends": [
        "plugin:markdownlint/recommended",
        "plugin:@cspell/recommended"
      ]
    }
  ]
}
An plugin that supports a different parser is Prettier.
{
  "root": true,
  "overrides": [
    {
      "files": ["*.md"],
      "parser": "eslint-plugin-markdownlint/parser",
      "extends": [
        "plugin:markdownlint/recommended",
        "plugin:prettier/recommended"
      ],
      "rules": {
        "prettier/prettier": ["error", { "parser": "markdown" }]
      }
    }
  ]
}

CSpell ESLint Plugin version: v6.8.0 ESLint version: v8.22.0

jerone avatar Aug 21 '22 14:08 jerone

@jerone,

Thank you for the request. What behavior are you expecting? My understanding of the eslint-plugin-markdownlint/parser plugin is that it only allows ESLint to check JavaScript code blocks.

Are you expecting:

  1. To spell check just the JavaScript code blocks?
  2. To spell check the entire Markdown file?
  3. Something else.

Kind regards, Jason

Jason3S avatar Aug 21 '22 15:08 Jason3S

Hi @Jason3S. I would expect CSpell ESLint Plugin to spell-check the whole Markdown file.

eslint-plugin-markdownlint/parser does indeed only check JavaScript code blocks.

plugin:markdownlint runs on the whole Markdown file.

plugin:prettier with rule config { "parser": "markdown" } runs on the whole Markdown file.

jerone avatar Aug 21 '22 16:08 jerone

This feature probably requires RFC-0003 Parsing files.

jerone avatar Feb 04 '24 11:02 jerone

@jerone,

I took a look at this while try to add Yaml support #5741. I thought it would be easy, but it is far more involved than I originally thought. The eslint-plugin-markdown preprocessor filters out everything but supported code blocks. Which is not what you wanted.

Another issue is that ESLint doesn't even call the spell checker plug-in if there isn't a supported code block in the Markdown file.

Jason3S avatar Jun 13 '24 16:06 Jason3S

eslint-plugin-markdown might maybe not the best reference.

eslint-plugin-markdownlint & eslint-plugin-prettier on the other hand do run whole files (with an optional custom parser option set).

jerone avatar Jun 18 '24 11:06 jerone