hosseinmd / prettier-plugin-jsdoc

A Prettier plugin to format JSDoc comments.
MIT License
232 stars 28 forks source link

fix: ensure formatting matches Prettier markdown formatter #147

Closed G-Rath closed 2 years ago

G-Rath commented 2 years ago

Fixes #142

Have also added a test using the sample markdown the Prettier playground uses, to ensure the formatting remains consistent.

G-Rath commented 2 years ago

CI failure looks unrelated to this change:

error An unexpected error occurred: "could not find a copy of prettier to link in /home/runner/work/prettier-plugin-jsdoc/prettier-plugin-jsdoc/node_modules/@react-native-community/eslint-config/node_modules".
hosseinmd commented 2 years ago

CI failure looks unrelated to this change:

error An unexpected error occurred: "could not find a copy of prettier to link in /home/runner/work/prettier-plugin-jsdoc/prettier-plugin-jsdoc/node_modules/@react-native-community/eslint-config/node_modules".

This error occur in last version of prettier, last version of prettier

hosseinmd commented 2 years ago

mdast-util-from-markdown has few updated. But i don't know how we can migrate to new version because new version is esm module. Do you have a solution for this?

G-Rath commented 2 years ago

@hosseinmd do you need to update mdast-util-from-markdown? and if so, what is it being used for?

The solutions I know of are:

I think the quickest one would be to transpile and vendor the dependency, but the ideal would be switching to another package if possible.

hosseinmd commented 2 years ago

We used this package to convert description md string to a model. I don't know another package to do this. Now this package growing, but I can't use new versions. Convert package into non-esm is a good idea, but i don't know how can i do it.

sxxov commented 2 years ago

@hosseinmd have you looked into using a loader?

here's an example of using esm to load esmodules into a commonjs environment:

const fromMarkdown = require('esm')(module)('mdast-util-from-markdown');
G-Rath commented 2 years ago

@Sxxov I didn't think about using a sync loader to handle this - not sure how much of a fan I am of it but it probably is fine. It looks like esm is unmaintained, but I'll hunt around to see if there's another loader that could do the job.

@hosseinmd if you want to create a new issue for this and assign it to me, I'll try and get a solution together (either by transpiling/vendoring or now maybe using a loader). I'm assuming this isn't critical, so will probably get into it next week once I've cleared a few other things on my plate 🙂

hosseinmd commented 2 years ago

@hosseinmd have you looked into using a loader?

here's an example of using esm to load esmodules into a commonjs environment:

const fromMarkdown = require('esm')(module)('mdast-util-from-markdown');

I created an issue for this https://github.com/hosseinmd/prettier-plugin-jsdoc/issues/150