jshint read only global error

Created on 20 Jun 2014  ·  3Comments  ·  Source: jshint/jshint

Here is the contents of a JS file:

/*global greeting */
greeting += ' hi!';

I run JSHint and get this error:

$ jshint --verbose ugly.js
ugly.js: line 2, col 1, Read only. (W020)

1 error

Why is JSHint assuming I want the globally imported greeting variable to be read only? This is without any options or .jshintrc

Most helpful comment

You need to use /*global greeting:true */ to tell JSHint that your global variable is writeable.

All 3 comments

+1

You need to use /*global greeting:true */ to tell JSHint that your global variable is writeable.

Thanks @valueof! That's what that's for!

Was this page helpful?
0 / 5 - 0 ratings