How to group "get" and "set"

What does the JS dev community recommend for grouping of “get” and “set” . group by “get” - “set” or by the object being “get” and “set” ?

In other words:

get
get
get
set
set
set

or:

get
set
get
set
get
set

Personally, I’d define the getter and setter for each property together:

get property() {
}
set property(value) {
}

But I imagine there will be arguments for the other way as well. I think the main thing would be to make sure you are consistent whichever way you choose.

Eslint wants it grouped by the object.

What do you mean? ESLint doesn’t specify, though it can (I think true by default) try to ensure that you always have the pair of them (if you have a setter, 99% of the time you also want a getter and vice versa, and it’s easy to forget)

I’d always want them in pairs as they are implicitly connected things that should be together, and I’ve never seen code where they aren’t written that way. But that’s with the caveat that aren’t commonly used in most JS codebases so I very rarely see any code with them in (and I never use them so maybe others have other conventions :man_shrugging:t3:)