Rule: trailing-comma

Requires or disallows trailing commas in array and object literals, destructuring assignments and named imports.

Config

One argument which is an object with the keys multiline and singleline. Both should be set to either "always" or "never".

  • "multiline" checks multi-line object literals.
  • "singleline" checks single-line object literals.

A array is considered “multiline” if its closing bracket is on a line after the last array element. The same general logic is followed for object literals and named import statements.

Examples
"trailing-comma": [true, {"multiline": "always", "singleline": "never"}]
Schema
{
  "type": "object",
  "properties": {
    "multiline": {
      "type": "string",
      "enum": [
        "always",
        "never"
      ]
    },
    "singleline": {
      "type": "string",
      "enum": [
        "always",
        "never"
      ]
    }
  },
  "additionalProperties": false
}