antfu / eslint-plugin-antfu

Anthony extended ESLint rules.
MIT License
116 stars 11 forks source link

`consistent-list-newline` has inconsistent behavior when single or multiple properties in an object ? #32

Open Baloche opened 3 weeks ago

Baloche commented 3 weeks ago

Describe the bug

In an object with a single property :

// The following ...

export const object = { a:1
}

// ... gets fixed to 

export const object = { a: 1,
}

In an object with multiple properties :

// The following ...

export const object = { a: 1, b:2
}

// ... gets fixed to 

export const object = { a: 1, b: 2 }

I would expect that when starting writing properties inline, both brackets stays inline (as it is the case for object with multiline properties in the example above). What is supposed to be the correct behavior ? Can it be configured so that it mimics the behavior of object-curly-newline with consistent: true ?

Reproduction

(code in main description)

System Info

System:
    OS: macOS 14.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 77.67 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.17.0 - ~/Library/pnpm/node
    Yarn: 1.22.22 - ~/Library/pnpm/yarn
    npm: 10.8.2 - ~/Library/pnpm/npm
    pnpm: 9.11.0 - ~/Library/pnpm/pnpm
    Watchman: 2024.03.25.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 129.0.6668.90
    Safari: 17.3.1

Used Package Manager

npm

Validations

Contributions

antfu commented 4 days ago

It sounds like a bug. While this is a bit niche, I currently don't have enough bandwidth to investigate on this - pr welcome if anyone wants to give it a try. Thanks.