Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-3524

Braces and parentheses should be used consistently with arrow functions

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Hide
      * [Add|Remove] parentheses around the parameter of this arrow function.
      * Add curly braces and "return" to this arrow function body.
      * Remove curly braces and "return" from this arrow function body.
      Show
      * [Add|Remove] parentheses around the parameter of this arrow function. * Add curly braces and "return" to this arrow function body. * Remove curly braces and "return" from this arrow function body.
    • Highlighting:
      Hide

      The part that needs changing

      Show
      The part that needs changing
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Targeted languages:
      TypeScript
    • Covered Languages:
      JavaScript
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      2min
    • ESLint:
      arrow-body-style, arrow-parens
    • TSLint:
      arrow-parens, arrow-return-shorthand

      Description

      Shared coding conventions allow teams to collaborate effectively. This rule raises an issue when the use of parentheses with an arrow function does not conform to the configured requirements.

      Noncompliant Code Example

      With the configured defaults forbidding parentheses

      var foo = (a) => { /* ... */ };  // Noncompliant; remove parens from arg
      var bar = (a, b) => { return 0; };  // Noncompliant; remove curly braces from body
      

      Compliant Solution

      var foo = a => { /* ... */ };
      var bar = (a, b) => 0;
      

        Attachments

        1.
        JavaScript RSPEC-4114 Language-Specification Active Unassigned

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            ann.campbell.2 Ann Campbell
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: