Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSHint giving 'Read Only' error for reassignment of $

I'm using the node-jshint command line to lint all of my JS files. I'm doing a reassignment of the $ by:

$ = someWindowObj.document.id;

and its giving me the error "Read Only." I am using Mootools so I am setting the option mootools to true. When I turn the option off in the file itself, via /*jshint mootools:false*/ I'm still getting the error. Shouldn't disabling the mootools (or jquery) option also disable the error? When I remove the mootools option completely from the ~/.jshintrc and the JS file, the error doesn't report.

I'm not sure if this is a bug or the intended behavior so I thought I put it to SO before submitting a bug.

like image 939
Spencer Carnage Avatar asked Dec 13 '11 22:12

Spencer Carnage


People also ask

How do I ignore Jshint warning?

In October 2013 jshint added a way to ignore blocks of code like this: // Code here will be linted with JSHint. /* jshint ignore:start */ // Code here will be ignored by JSHint. /* jshint ignore:end */ // Code here will be linted with JSHint. Show activity on this post. Show activity on this post.


1 Answers

If the project settings overwrite in-file settings you should file a bug report for the node-jshint project. In the meantime, you can always do /*global $:true */. This tells JSHint that it is okay to overwrite $ global variable.

like image 107
Anton Kovalyov Avatar answered Oct 24 '22 19:10

Anton Kovalyov