DavidAnson / vscode-markdownlint

Markdown linting and style checking for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint
MIT License
894 stars 166 forks source link

ERROR: Exception while linting with markdownlint-cli2: SyntaxError: Unexpected end of JSON input #316

Closed PythonCoderAS closed 5 months ago

PythonCoderAS commented 5 months ago

If I open a brand new Markdown file in the Source Control diff view on github.dev:

[9:24:37 AM] ERROR: Exception while linting with markdownlint-cli2:
SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at eval (https://davidanson.vscode-unpkg.net/DavidAnson/vscode-markdownlint/0.53.0/extension/bundle.web.js#vscode-extension:47:19767)
    at eval (https://davidanson.vscode-unpkg.net/DavidAnson/vscode-markdownlint/0.53.0/extension/bundle.web.js#vscode-extension:47:21082)
    at async Promise.all (index 0)
    at async eval (https://davidanson.vscode-unpkg.net/DavidAnson/vscode-markdownlint/0.53.0/extension/bundle.web.js#vscode-extension:47:25329)
    at async M (https://davidanson.vscode-unpkg.net/DavidAnson/vscode-markdownlint/0.53.0/extension/bundle.web.js#vscode-extension:47:25264)
DavidAnson commented 5 months ago

It sounds like your project or your configuration are referencing an improperly formatted JSON configuration file, possibly one that is empty. If you correct the formatting of that file or remove the reference to it, this should not happen. (Look for files named like ".markdownlint.json".)

PythonCoderAS commented 5 months ago

It sounds like your project or your configuration are referencing an improperly formatted JSON configuration file, possibly one that is empty. If you correct the formatting of that file or remove the reference to it, this should not happen. (Look for files named like ".markdownlint.json".)

My project does not have a .markdownlint.json file.

PythonCoderAS commented 5 months ago

Guaranteed reproduction:

  1. Go to https://github.dev/github/dev
  2. Make a file called test/README.md
  3. Fill it with some content that triggers a rule, such as:
    
    # Test File:

Hello, World!!!


4. Go to source control tab
5. Click the new file
DavidAnson commented 5 months ago

Source control diff view can be tricky because it represents files as a different type. Can you please tell me the exact steps to reproduce this myself? What project? What file do I open? Etc.?

PythonCoderAS commented 5 months ago

https://github.com/DavidAnson/vscode-markdownlint/assets/13932583/f07eb555-e130-48d0-8dbb-824062e5edbe

DavidAnson commented 5 months ago

Our comments crossed paths! Thank you, I will have a look soon!

DavidAnson commented 5 months ago

@PythonCoderAS, I can get this to happen, but only under the EXACT conditions you describe: github.dev (or vscode.dev) accessing a remote repository opening a Markdown file that's being viewed in diff view. If you hit this in any other contexts, please let me know. Otherwise, I think I can detect the problematic scenario and not lint - which was previously the case for diff view so I think something changed in VS Code or its remote repository support. Thank you!

DavidAnson commented 5 months ago

Okay, I can also reproduce this in VS Code Insiders using the Remote Explorer to open the https://github.dev/github/dev repository. That's nice because it means I can work with unminified code and make changes more easily. I think there's a different/related problem with this scenario that will also be resolved by the change I have in mind.