SonarQube JavaScript
  1. SonarQube JavaScript
  2. SONARJS-84

Rule: Do not use additional "future reserved words" as identifiers

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      title

      Do not use additional future reserved words as identifiers

      description

      The following words may be used as keywords in future evolutions of the language, so using them as identifiers should be avoided to allow an easier adoption of those potential future evolutions:

      • implements
      • let
      • private
      • public
      • yield
      • interface
      • package
      • protected
      • static

      Usage of those words as identifiers would produce an error in JavaScript strict mode code. See http://www.ecma-international.org/ecma-262/5.1/#sec-7.6.1.2.

      The following code snippet illustrates this rule :

      var package = document.getElementsByName("foo"); // non-compliant
      var elements = document.getElementsByName("foo"); // compliant
      var data = { package: true }; // compliant, as it is not used as an identifier here 
      

      message

      Rename "

      {0}

      " identifier to prevent potential conflicts with future evolutions of the JavaScript language.

      severity

      Critical

      in Sonar way?

      Yes

        Issue Links

          Activity

          Hide
          Fabrice Bellingard added a comment -

          Manually tested.

          Show
          Fabrice Bellingard added a comment - Manually tested.

            People

            • Assignee:
              Evgeny Mandrikov
              Reporter:
              Evgeny Mandrikov
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: