All Downloads are FREE. Search and download functionalities are using the official Maven repository.

rules.jshint.E034.html Maven / Gradle / Ivy

Go to download

Consume reports generated by jshint for code quality. Also consume reports for code duplication (either simian or cpd). Consumes the unit/integration tests reports (generated by Jasmin) coverage report (lcov generated by Istanbul). The information generated by reports are added in Sonar

There is a newer version: 2.1.0
Show newest version

    

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
 
1
var 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
JSLint found no errorsVersion 1.1.0

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:

14
 
1
/*jslint es5: true */
2
/*jshint es5: true */
3
var x = {
4
    actual: 10,
5
    get x () {
6
        "use strict";
7
        return this.actual / 2;
8
    },
9
    set x (value) {
10
        "use strict";
11
        this.actual = value;
12
    }
13
};
14
JSLint found no errorsVersion 1.1.0




© 2015 - 2025 Weber Informatics LLC | Privacy Policy