
rules.jshint.E034.html Maven / Gradle / Ivy
Show all versions of sonar-web-frontend-js Show documentation
History
This warning has existed in two forms across JSLint and JSHint. It was
introduced in May 2011 version of JSLint and remained in both tools for a period
of time.
In JSLint between May 2011 and August 2013 the message used was the generic
"This is an ES5 feature"
Before May 2011 and after August 2013 this functionality is not supported in
JSLint
In JSHint prior to version 2.0.0 the message used was "get/set are ES5
features"
In JSHint 2.0.0 and above this functionality is not supported
When do I get this error?
The "get/set are ES5 features" error, and the alternative "This is an ES5
feature", is thrown when JSHint or JSLint encounters an object property getter
or setter. In the following example we create an object x
with a getter and
setter. The getter is intended to always return half of the set value:
x 1var x = {
2 actual: 10,
3 get x () {
4 "use strict";
5 return this.actual / 2;
6 },
7 set x (value) {
8 "use strict";
9 this.actual = value;
10 }
11};
12
Why do I get this error?
This error is raised to highlight the use of a newer language feature that
might not be supported in all the environments in which your code should run.
In particular, various older browsers will be likely to throw syntax errors when
parsing your script.
ECMAScript 5 added support for object property getters and setters as a
mechanism for running a function on property access and modification (ES5
§11.1.5):
PropertyAssignment :
PropertyName : AssignmentExpression
get
PropertyName ( ) {
FunctionBody }
set
PropertyName (
PropertySetParameterList )
{
FunctionBody }
If you're sure that your code doesn't need to run in older browsers that don't
support the ES5 getter/setter syntax, you can fix this error by setting the
es5
option to true
: