Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting it to work in VSCode? #112

Closed
greggman opened this issue Dec 27, 2018 · 4 comments · Fixed by GoogleForCreators/web-stories-wp#6765
Closed

Getting it to work in VSCode? #112

greggman opened this issue Dec 27, 2018 · 4 comments · Fixed by GoogleForCreators/web-stories-wp#6765

Comments

@greggman
Copy link

greggman commented Dec 27, 2018

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?

@btmills
Copy link
Member

btmills commented Jan 2, 2019

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:

screenshot 2019-01-02 14 46 58

But for some reason, syntax errors are all shown on the first line:

screenshot 2019-01-02 14 49 20

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:

screenshot 2019-01-02 14 56 18

Does this match what you're seeing?

@greggman
Copy link
Author

greggman commented Jan 3, 2019

Actually now that you mention it yes, that's what I'm seeing but it's not just syntax errors, it's any eslint error.

Here the only error is a style error, spaces after foo

screen shot 2019-01-03 at 10 52 02

with the space removed

screen shot 2019-01-03 at 10 52 11

btmills added a commit that referenced this issue Jul 20, 2020
Issue #112 reported VSCode drawing squigglies all the way from the top
of a file to a line in a code block with a syntax error rather than just
squigglying the line with the syntax error. For messages that only
specified start locations, the processor was adding `endLine: NaN`.
@btmills
Copy link
Member

btmills commented Jul 20, 2020

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.

@mightyiam
Copy link

😍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants