ESLint - object-curly-newline

Viewed 3999

Is there a way to allow for {} (an empty object) while keeping the rest as is?

    "object-curly-newline": [
      "error",
      {
        "ObjectExpression": "always",
        "ObjectPattern": { "multiline": true },
        "ImportDeclaration": { "multiline": true, "minProperties": 4 },
        "ExportDeclaration": "never"
      }
    ]
1 Answers

An empty object {} is ObjectExpression, so it always breaks line with your rule by specifying always. You can keep empty object without breaking line by configuring minProperties > 1:

{
  "ObjectExpression": { "multiline": true, "minProperties": 1 },
}
Related