spaceInParensRule.md

May 22, 2017 ยท View on GitHub

space-in-parens (ESLint: space-in-parens)

rule_source test_source

require or disallow spaces inside parentheses

Rationale

This rule will enforce consistency of spacing directly inside of parentheses, by disallowing or requiring one or more spaces to the right of (and to the left of). In either case, () will still be allowed.

Config

There are two options for this rule:

  • "never" (default) enforces zero spaces inside of parentheses
  • "always" enforces a space inside of parentheses

Depending on your coding conventions, you can choose either option by specifying it in your configuration.

Examples

"space-in-parens": [true, "always"]
"space-in-parens": [true, "never"]
"space-in-parens": [true, "always", { "exceptions": [ "{}", "[]", "()", "empty" ] }]

Schema

{
  "type": "array",
  "items": [
    {
      "enum": [
        "always",
        "never"
      ]
    },
    {
      "type": "object",
      "properties": {
        "exceptions": {
          "type": "array",
          "items": [
            {
              "enum": [
                "{}",
                "[]",
                "()",
                "empty"
              ]
            }
          ],
          "uniqueItems": true
        }
      },
      "additionalProperties": false
    }
  ],
  "minItems": 0,
  "maxItems": 2
}