Getting it to work in VSCode?
greggman opened this issue · comments
I installed eslint-plugin-markdown in a project I'm editing with VScode and ran into issues
First I added the suggested overrides then I checked for errors in a markdown file, no errors show even thought I put intentional errors.
{
...
"overrides": [
{
"files": [ "**/*.md" ],
"parserOptions": {
"ecmaFeatures": {
"impliedStrict": true
},
},
"rules": {
"strict": "off"
}
}
]
}
I tried adding "markdown"
to the eslint.validate
setting as in in <projectfolder>/.vscode/settings.json
{
"eslint.validate": [ "javascript", "html", "markdown" ]
}
But in that case VSCode seems be trying to lint the entire markdown file as JavaScript. I get errors on the entire file starting with the first line which is just normal text.
Any idea what I'm doing wrong?
I'm able to reproduce something like this with a configuration similar to yours, though I removed the overrides
:
.vscode/settings.json
{
"eslint.validate": ["javascript", "markdown"]
}
.eslintrc.js
module.exports = {
plugins: [
"markdown"
],
extends: [
"eslint:recommended"
],
env: {
browser: true
}
}
In my case, lint rule failures are shown correctly:
But for some reason, syntax errors are all shown on the first line:
It got the column (7) correct, but ignored the line. Running ESLint outside the integration returns the correct line and column:
$ node_modules/.bin/eslint README.md
/Users/brandon/code/eslint/markdown-test/README.md
5:7 error Parsing error: Unexpected token !
✖ 1 problem (1 error, 0 warnings)
I don't get any errors in a file that shouldn't have any:
Does this match what you're seeing?
I finally figured out what was causing this! Most ESLint rules pass both start and end locations, but parse errors only specify start locations. A bug was causing the processor to add endLine: NaN
to those messages, which was understandably confusing VSCode. I opened #154 to fix this.
😍