hosseinmd / prettier-plugin-jsdoc

A Prettier plugin to format JSDoc comments.
MIT License
228 stars 29 forks source link

In tsdoc mode, various characters that tsdoc wants escaped are unescaped #167

Open beark opened 2 years ago

beark commented 2 years ago

The issue here is the interplay of using eslint-plugin-tsdoc together with prettier-plugin-jsdoc.

Example:

/**
 * @returns True if a >= b.
 */

Here, tsdoc will complain that

tsdoc-escape-greater-than: The ">" character should be escaped using a backslash to avoid confusion with an HTML tag

So, then I change it to

/**
 * @returns True if a \>= b.
 */

But then prettier-plugin-jsdoc strips the backslash and I'm back to the original, which the tsdoc lint doesn't like!

Same pattern happens with, eg

/**
 * Emails look like user@domain.
 */

Where tsdoc wants me to escape the "@", and prettier-plugin-jsdoc immediately removes it.

My current workaround: surround strings with these problem characters in backticks, at which point tsdoc stops complaining:

/**
 * Emails look like `user@domain`.
 */
beark commented 2 years ago

My suggestion: when prettier-plugin-jsdoc is configured with tsdoc: true, backslashes should not be stripped from @, >, and < (those are the triggering characters I've found so far).