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

Shorthand object properties should be grouped at the beginning or end of an object declaration

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Hide
      * Group all shorthand properties at the [beginning|end] of this object declaration
      * Group all shorthand properties at either the beginning or end of this object declaration. (When no pattern/preference is evident)
      Show
      * Group all shorthand properties at the [beginning|end] of this object declaration * Group all shorthand properties at either the beginning or end of this object declaration. (When no pattern/preference is evident)
    • Highlighting:
      • primary: First line of declaration
      • Secondary: mis-placed property
        • message:
          • Move to the beginning.
          • Move to the end.
          • Group at beginning or end.
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Covered Languages:
      JavaScript
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      1min

      Description

      Grouping all the shorthand declarations together in an object makes the declaration as a whole more readable. This rule accepts shorthand declarations grouped at either the beginning or end of an object.

      Noncompliant Code Example

      let obj1 = {
        foo,
        a: 1,
        color,  // Noncompliant
        b: 2,
        judyGarland  // Noncompliant
      }
      

      Compliant Solution

      let obj1 = {
        foo,
        color,
        judyGarland,
        a: 1,
        b: 2
      }
      

      or

      let obj1 = {
        a: 1,
        b: 2,
        foo,
        color,
        judyGarland
      }
      

        Attachments

          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: