remarkjs / vscode-remark

Lint and format markdown code with remark
https://marketplace.visualstudio.com/items?itemName=unifiedjs.vscode-remark
MIT License
54 stars 11 forks source link

Vfile API incomplete #107

Closed cm226 closed 2 years ago

cm226 commented 2 years ago

Initial checklist

Affected packages and versions

v1.2.1

Link to runnable example

No response

Steps to reproduce

Use the remark-code-import plugin

Expected behavior

remark-code-import runs and imports code into formatted document

Actual behavior

When using the plugin "TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined" is printed on the output console.

The problem looks to be that the vFile API is only partially implemented on in the object passed to the transformer. remark-code-import uses https://github.com/vfile/vfile#filedirname to get a relative path to the files its importing from.

When I checked the keys on the object passed as the vFile when running in this plugin i saw that only a handful of the keys were present. Would it possible to add the full vFile API to the object passed to the transformer?

Runtime

Electron

Package manager

npm 8

OS

Windows

Build and bundle tools

No response

wooorm commented 2 years ago

Inspecting fields on a file does not present them, because they are getters and setters. What you see (or rather, don’t) hence is not a problem.

There were a lot of issues with this project. This project has been rewritten, but that has not been released yet. There are still a couple of small things missing.

The rewrite, and the next release will almost certainly fix your problem.

cm226 commented 2 years ago

Thanks for getting back, whatever the reason accessing dirname property returns undefined in the object passed as the VFile in the currently version of the plugin, so if there is a getter defined its returning undefined.

Good to know that you guys are re-writing, Ill close this issue given that and try again when you guys release the re-write thanks.

github-actions[bot] commented 2 years ago

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.

wooorm commented 2 years ago

if there is a getter defined its returning undefined.

Yes, the errors means that the file does not have a path at all. I believe we’ve fixed that here