hosseinmd / prettier-plugin-jsdoc

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

Unstable formatting for "Default value" #219

Open GulDilin opened 11 months ago

GulDilin commented 11 months ago

Hello. Thank you for developing this tool.

I faced an issue with the formatted jsdoc result changing over multiple runs for the "Default is" part. The "Default is false" part is added on each run.

Example

Imput code

/**
 * Compute some value
 *
 * @param {Object} param The parameters
 * @param {boolean} [param.isSelectedSomeVal=false] Indicates if selected
 *
 * @returns {string} SomeValue
 */
export const computeSomeValue = ({ isSelectedSomeVal = false }) => {
  // some code
  return undefined
}

Output after run 1

/**
 * Compute some value
 *
 * @param {Object} param The parameters
 * @param {boolean} [param.isSelectedSomeVal=false] Indicates if selected Default is `false`
 *
 * @returns {string} SomeValue
 */
export const computeSomeValue = ({ isSelectedSomeVal = false }) => {
  // some code
  return undefined
}

Expected

// same as output after run 1

Output after run 3

/**
 * Compute some value
 *
 * @param {Object} param The parameters
 * @param {boolean} [param.isSelectedSomeVal=false] Indicates if selected Default is `false` Default
 *   is `false` Default is `false`
 *
 * @returns {string} SomeValue
 */
export const computeSomeValue = ({ isSelectedSomeVal = false }) => {
  // some code
  return undefined
}

Environment

Versions

node
v19.9.0

"prettier": "3.1.0",
"prettier-plugin-jsdoc": "1.1.1"

.prettierrc

{
    "plugins": [
      "prettier-plugin-jsdoc"
    ],
    "trailingComma": "es5",
    "tabWidth": 2,
    "semi": false,
    "singleQuote": true,
    "singleAttributePerLine": true,
    "bracketSameLine": false,
    "arrowParens": "avoid",
    "printWidth": 100,
    "endOfLine": "lf",

    "jsdocVerticalAlignment": false,
    "jsdocKeepUnParseAbleExampleIndent": false,
    "jsdocSeparateReturnsFromParam": true,
    "jsdocSeparateTagGroups": true,
    "tsdoc": true,
    "jsdocPrintWidth": 100
}