5

JSHint override not being respected.

[Output]: [L59:C38] W117: 'alert' is not defined.

[Output]: /*jshint -W117 */alert("failed to load review data..");/*jshint +W117 */

-- Actual line of code:

$scope.example.$get(
    function(data){
       $scope.data =  //do something;
    }, function(message){
        /*jshint -W117 */alert("failed..");/*jshint +W117 */
});

I use these for other warnings, but W117 seems to be ignored.

Community
  • 1
  • 1
Nix
  • 57,072
  • 29
  • 149
  • 198

3 Answers3

6

Try have them on a seperate line

/* jshint -W117 */
alert("failed..");
/* jshint +W117 */

Another option to disable the warning is to add this at the top of the file

/* global alert */
Daniel Magnusson
  • 9,541
  • 2
  • 38
  • 43
1

You can also create a .jshintrc file with this content:

{
  "globals": {
    "alert": false
  }
}

The globals configuration option says that this variable is a global defined elsewhere, and the false value says that it shouldn't be redefined.

Guilherme Garnier
  • 2,208
  • 23
  • 22
1
alert("failed.."); //jshint ignore:line
duncan
  • 31,401
  • 13
  • 78
  • 99
JeanK
  • 292
  • 2
  • 4