Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

Latest commit

 

History

History
74 lines (57 loc) · 1.94 KB

terArrowParensRule.md

File metadata and controls

74 lines (57 loc) · 1.94 KB

ter-arrow-parens (ESLint: arrow-parens)

rule_source test_source

require parens in arrow function arguments

Rationale

Arrow functions can omit parentheses when they have exactly one parameter. In all other cases the parameter(s) must be wrapped in parentheses. This rule enforces the consistent use of parentheses in arrow functions.

Config

This rule has a string option and an object one.

String options are:

  • "always" (default) requires parentheses around arguments in all cases.
  • "as-needed" allows omitting parentheses when there is only one argument.

Object properties for variants of the "as-needed" option:

  • "requireForBlockBody": true modifies the as-needed rule in order to require parentheses if the function body is in an instructions block (surrounded by braces).

Examples

"ter-arrow-parens": [true]
"ter-arrow-parens": [true, "always"]
"ter-arrow-parens": [true, "as-needed"]
"ter-arrow-parens": [true, "as-needed", { "requireForBlockBody": true }]

Schema

{
  "type": "array",
  "items": [
    {
      "enum": [
        "always",
        "as-needed"
      ]
    },
    {
      "type": "object",
      "properties": {
        "requireForBlockBody": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    }
  ],
  "maxLength": 1
}

TSLint Rule: arrow-parens