hosseinmd / prettier-plugin-jsdoc

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

Add parentheses around union types #190

Closed yoriiis closed 1 year ago

yoriiis commented 1 year ago

First, thanks for the plugin!

JSDoc seems to enforce the use of parentheses around several types, however the plugin removes them. Can we change this or add an option to customize the behavior? Thanks

Before

/**
 * @param {('open' | 'close')} action Action type
 */
export default function sampleFunction(action) {}

After

/**
 * @param {'open' | 'close'} action Action type
 */
export default function sampleFunction(action) {}

Resources:

hosseinmd commented 1 year ago

Jsdoc don't force you to use/not-use parentheses. Removing parentheses is prettier behavior for multiple type. For example, if you define a type like that in a typescript file, prettier will be remove parentheses.