Fork me on GitHub

JSLint Error Explanations

JSLint will hurt your feelings. It's time to make them better!


This is an ES5 feature

When do I get this error?

JSLint will throw the "This is an ES5 feature" error when it encounters a multiline string. In the following example we attempt to assign a multiline string to the variable myString:

JSLint will also throw this error when it 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:

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.

For the first example above, ECMAScript 5 modified the definition of string literals to allow line terminator characters (ES5 §7.8.4):

A line terminator character cannot appear in a string literal, except as part of a LineContinuation to produce the empty character sequence.

If you are sure that your code does not need to run in older browsers that do not support multiline strings, you can fix this error by simply using the es5 option:

For the second example above, 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 }

Again, 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:


comments powered by Disqus