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:


James Allardice

This article was written by James Allardice, an enthusiastic young JavaScript developer at Global Personals (we're looking for developers so please apply). He is passionate about writing clean, maintainable JavaScript and uses JSHint every day to help achieve this.

You can follow him on Twitter, fork him on GitHub and find him on Google+.


Proceeds generated by this site are donated to help advance other open source projects



comments powered by Disqus