streetsidesoftware / cspell

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

CSpell ESLint Plugin support Markdown #3464

Open jerone opened 2 years ago

jerone commented 2 years 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 2 years 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 2 years 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 9 months ago

This feature probably requires RFC-0003 Parsing files.

Jason3S commented 5 months 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 5 months 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).