Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
How to allow only multiline or single-line object declarations

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 }
],
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!