简体   繁体   中英

ESLint - object-curly-newline

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"
      }
    ]

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 },
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM