Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: JAVASCRIPT-1.2
-
Component/s: JavaScript
-
Labels:None
-
Number of attachments :
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
- is related to
-
SONARPLUGINS-2517
Parser: "future reserved words" can be used as identifiers in non-strict code
-
-
SONARPLUGINS-2515
Update the SQALE mapping for new rules
-
- relates to
-
SONARPLUGINS-2508
Rule : Source should comply with the javascript strict mode
-
Manually tested.