electrovir / prettier-plugin-multiline-arrays

Prettier plugin to force array elements to wrap onto new lines.
https://www.npmjs.com/package/prettier-plugin-multiline-arrays
Creative Commons Zero v1.0 Universal
135 stars 6 forks source link

Allow to wrap only when the one line array's closing bracket is reaching a limit in characters #17

Closed calag4n closed 1 year ago

calag4n commented 1 year ago

It would be great if we could choose to set the threshold in term of characters instead of array elements. Maybe just following the printWidth property for the limit.

electrovir commented 1 year ago

Could you please provide more details on what you're requesting? Prettier without this plugin already and only wraps by character count. This plugin does not interfere with that but also wraps in more conditions (when the element count threshold is passed). To wrap by character count alone, ignoring element account, this plugin should not be used.

electrovir commented 1 year ago

Closing due to lack of response. Please feel free to re-open with more details!

calag4n commented 1 year ago

Could you please provide more details on what you're requesting? Prettier without this plugin already and only wraps by character count. This plugin does not interfere with that but also wraps in more conditions (when the element count threshold is passed). To wrap by character count alone, ignoring element account, this plugin should not be used.

I probably misunderstand how it is supposed to work, sorry. My issue is that I don't want small arrays to be wrapped in one line.

For example, if a set prettier with "multilineArraysWrapThreshold": 4

  const foo = [1, 2, 3, 4, 5]

will be formatted in

  const a = [
    1,
    2,
    3,
    4,
    5,
  ]

That I want to avoid. Otherwise it's a great plugin, good job, bravo !

electrovir commented 1 year ago

Thanks for the details!

What are you hoping this plugin will do for you? Or, in other words, what are you hoping to get out of setting the wrap threshold to 4? (Rather than relying on Prettier's default array wrapping behavior.)

I'm trying to understand your use case as it seems to me that you want to set a threshold but then ignore the threshold. In that case, I don't know when you expect the threshold to not be ignored.

Otherwise it's a great plugin, good job, bravo !

Thank you kindly :grin: