TypeScript-ESLint is trying to parse markdown files

I've not tried to setup ESLint like this before; I want to have a single source of truth at the root of a monorepo, and from there I'll be formatting *.ts, *.svelte, *.md, and *.[c|m]?js. Basically, I have no idea what I'm doing, and the documentation doesn't have a section on "what to do when a TS parser parses markdown". I've tried looking online, but I must be using the wrong search terms, all im getting is the packages, not any info on the conflict between them. The plugins I'm using are (from package.json devDeps);
{
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-markdownlint": "^0.4.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-svelte3": "^4.0.0",
"prettier": "^2.6.2",
"prettier-plugin-svelte": "^2.7.0",
}
{
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-markdownlint": "^0.4.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-svelte3": "^4.0.0",
"prettier": "^2.6.2",
"prettier-plugin-svelte": "^2.7.0",
}
In my .eslintrc.cjs I've set parser: "@typescript-eslint/parser", however in the overrides I've added the following object to the array;
{
files: ["*.md"],
parser: "eslint-plugin-markdownlint/parser",
extends: ["plugin:markdownlint/recommended"],
}
{
files: ["*.md"],
parser: "eslint-plugin-markdownlint/parser",
extends: ["plugin:markdownlint/recommended"],
}
Which I thought would override the parser for *.md files, apparently not. This error is produced for the first (alphabetically) markdown file in the project, with the first (alphabetically) rule from plugin:@typescript-eslint/recommended-requiring-type-checking. Interestingly, even if I explicitly exclude the file in the top-level tsconfig via "exclude": ["./README.md"] (or whatever name I want to exclude), TS ESLint will still try to parse it, and of course fail.
Error: Error while loading rule '@typescript-eslint/[rule]': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.

Occurred while linting /path/to/project/[file].md
Error: Error while loading rule '@typescript-eslint/[rule]': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.

Occurred while linting /path/to/project/[file].md
Full config files; TSConfig: https://pastebin.com/0RGBfAru ESLintRC: https://pastebin.com/nTCW0vjc PrettierRC: https://pastebin.com/bK0NjR0N Package.json: https://pastebin.com/H0fiQ5wM
1 Reply
WillsterJohnson
WillsterJohnsonOP3y ago
I managed to sort it out, but it took way more effort than it should. I think the config has been patch ontop of patch for some time and is probably due an overhaul
Want results from more Discord servers?
Add your server