prettier-plugin-multiline-arrays icon indicating copy to clipboard operation
prettier-plugin-multiline-arrays copied to clipboard

don't wrap last array item when trailingComma is 'none'

Open artembelik opened this issue 1 year ago • 2 comments

Hi, thanks for the awesome plugin, but I noticed a strange behavior when trailingComma is 'none'

.prettierrc

{
    printWidth: 120,
    tabWidth: 4,
    useTabs: false,
    singleQuote: true,
    trailingComma: 'none', // <---
    plugins: ['prettier-plugin-multiline-arrays'],
}

source:

const { join } = require('path');

const arr = [
    join('...', '...'),
    join('...', '...')
]; // <---

after prettier --write:

const { join } = require('path');

const arr = [
    join('...', '...'),
    join('...', '...')]; // <---

artembelik avatar Jul 30 '24 14:07 artembelik

Nice catch! I'll try to repro and fix.

electrovir avatar Jul 31 '24 01:07 electrovir

Note: this also happens in JSON (since JSON doesn't allow trailing commas)

electrovir avatar Aug 02 '24 00:08 electrovir

I have the same issue with trailingComma: 'es5'

Original code

{
    "files": [],
    "references": [
        {"path": "./tsconfig.app.json"},
        {"path": "./tsconfig.node.json"}
    ]
}

after this plugin is executed, I ended up with

{
    "files": [],
    "references": [
        {"path": "./tsconfig.app.json"},
        {"path": "./tsconfig.node.json"}]
}

adiroiban avatar Oct 14 '24 19:10 adiroiban

fixed for the next release

electrovir avatar Dec 15 '24 01:12 electrovir

released in v4.0.0

electrovir avatar Dec 15 '24 03:12 electrovir