hosseinmd / prettier-plugin-jsdoc

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

Indented block formatting not stable #155

Closed turadg closed 1 year ago

turadg commented 2 years ago

Bug description

A code block like this is stable,

   *   ```md
   *   Then the bounds    would iterate over the key sequence
   *   ----------------   -----------------------------------
   *   'bar', 'goomba'    bar, baz, foocount, foopriority
   *   'bar', 'joober'    bar, baz, foocount, foopriority
   * ```

But when the code block's syntax isn't specified, the tool changes to indentation syntax, which is not stable.

Actual

Example Pass 0: ``` * ``` * Then the bounds would iterate over the key sequence * ---------------- ----------------------------------- * 'bar', 'goomba' bar, baz, foocount, foopriority * 'bar', 'joober' bar, baz, foocount, foopriority * ``` ``` Pass 1: ``` * Then the bounds would iterate over the key sequence * ---------------- ----------------------------------- * 'bar', 'goomba' bar, baz, foocount, foopriority * 'bar', 'joober' bar, baz, foocount, foopriority ``` Pass 2: ``` * Then the bounds would iterate over the key sequence * ---------------- ----------------------------------- * 'bar', 'goomba' bar, baz, foocount, foopriority * 'bar', 'joober' bar, baz, foocount, foopriority ``` Pass 3: ``` * Then the bounds would iterate over the key sequence * ---------------- ----------------------------------- * 'bar', 'goomba' bar, baz, foocount, foopriority * 'bar', 'joober' bar, baz, foocount, foopriority ``` Pass 4: ``` * Then the bounds would iterate over the key sequence * ---------------- ----------------------------------- * 'bar', 'goomba' bar, baz, foocount, foopriority * 'bar', 'joober' bar, baz, foocount, foopriority ``` Pass 5: ``` * Then the bounds would iterate over the key sequence * ---------------- ----------------------------------- * 'bar', 'goomba' bar, baz, foocount, foopriority * 'bar', 'joober' bar, baz, foocount, foopriority ``` Pass 6: ``` * Then the bounds would iterate over the key sequence * ---------------- ----------------------------------- * 'bar', 'goomba' bar, baz, foocount, foopriority * 'bar', 'joober' bar, baz, foocount, foopriority ``` Pass 7: ``` * Then the bounds would iterate over the key sequence * ---------------- ----------------------------------- * 'bar', 'goomba' bar, baz, foocount, foopriority * 'bar', 'joober' bar, baz, foocount, foopriority ```

Expected

hosseinmd commented 2 years ago

Use intention instead of backtick, when you're wrapping with backtick, plugin assume this is code and formatting them as code. Add four space as intention like this

   *     Then the bounds    would iterate over the key sequence
   *     ----------------   -----------------------------------
   *     'bar', 'goomba'    bar, baz, foocount, foopriority
   *     'bar', 'joober'    bar, baz, foocount, foopriority
turadg commented 2 years ago

I think what you're advising is exactly what's in Pass 1. Notice that on the next format it moves and on each format it moves again. ie not stable

hosseinmd commented 2 years ago

Please give me your comment completely.

turadg commented 2 years ago

Here's a failing case in 0.3.34:

 /**
   * @returns {boolean} result
   *
   *         Then the bounds    would iterate over the key sequence
   *         ----------------   -----------------------------------
   *         'bar', 'goomba'    bar, baz, foocount, foopriority
   *         'bar', 'joober'    bar, baz, foocount, foopriority
   */
turadg commented 2 years ago

@hosseinmd have you confirmed this is a bug? Is it one you intend to work on or will it require a community fix?

hosseinmd commented 2 years ago

Yes, this is a bug. I will, but Now I don't have enough time.

turadg commented 1 year ago

May be fixed by https://github.com/prettier/prettier/pull/13532

If so will require https://github.com/hosseinmd/prettier-plugin-jsdoc/issues/194

turadg commented 1 year ago

It's not fully stable but I think the remaining problem is https://github.com/hosseinmd/prettier-plugin-jsdoc/issues/178