DavidAnson / vscode-markdownlint

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

Support for automatic custom rule installation #317

Closed skwde closed 6 months ago

skwde commented 8 months ago

This is kind of a follow up to https://github.com/DavidAnson/vscode-markdownlint/issues/180.

I think it would be good if the option

// Array of paths for custom rules to include when linting
"markdownlint.customRules": [],

not only supports local files, but also remote files, i.e. something like

  "markdownlint.customRules": [
      "https://github.com/JoshuaKGoldberg/sentences-per-line/blob/master/index.js"
  ],

gives the error

[11:52:02] ERROR: Exception while linting with markdownlint-cli2:
AggregateError: Unable to require or import module 'https://github.com/JoshuaKGoldberg/sentences-per-line/blob/master/index.js'.

Related:

DavidAnson commented 8 months ago

This MAY already work today for ESM modules - but if so, it will NOT work within VS Code because Electron does not load ESM modules (yet). You could try this via CLI2 directly - my thinking is that the existing fallback of require to import may/should "just work" for this.

skwde commented 8 months ago

I have no idea what you are talking about.

Obviously it doesn't work, but it would be nice if it does. It would no longer require to have a node install just for an additional lint rule.

DavidAnson commented 8 months ago

If you're talking about markdownlint-cli2 automatically running npm or yarn to install custom rule packages, that's outside the scope of what I think this tool should do. If you're suggesting markdownlint-cli2 should try to download all the the implicit/explicit scripts and (sub-)dependencies of an arbitrary JavaScript file as shown above, that's even further out of scope in my mind.

The way something like this could work is via ESM modules... however trying that myself produces the following error from Node 20, so I don't think this is practical yet:

    Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. Received protocol 'http:'