streetsidesoftware / cspell

A Spell Checker for Code!
https://cspell.org
MIT License
1.17k stars 84 forks source link

CSpell ESLint Plugin support Markdown #3464

Open jerone opened 1 year ago

jerone commented 1 year ago

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. ```json { "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. ```json { "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

Jason3S commented 1 year ago

@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

jerone commented 1 year ago

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 commented 5 months ago

This feature probably requires RFC-0003 Parsing files.

Jason3S commented 3 weeks ago

@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.

jerone commented 2 weeks ago

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).