I would like to allow single-line declarations like this:
const allowed = { foo: 1, bar: 2 }
And multi-line declarations like this:
const allowed = {
foo: 1,
bar: 2
}
const alsoAllowed = {
foo: 1
}
While forbidding multiple properties on the same line of a multi-line declaration, like this
const forbidden = {
foo: 1, bar: 2
}
Is that possible with ESLint? I've tried to achieve this by tweaking object-curly-newline and object-property-newline, but I can't seem to find the right combination.
I've gotten close with the following settings, but alsoAllowed above then violates object-curly-newline. Trying to mitigate that with the consistent and minProperties options seems to result in allowing the unwanted syntax too.
"object-curly-newline": [
"warn",
{
"ObjectExpression": { "multiline": true },
"ObjectPattern": { "multiline": true },
"ImportDeclaration": { "multiline": true },
"ExportDeclaration": { "multiline": true }
}
],
"object-property-newline": [
"warn",
{ "allowAllPropertiesOnSameLine": true }
],