Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore camelcase variable in JSHint

Having a bit of an issue with JShint and the following line of code.

$location.path('map-' + map.id + '/venue-' + map.attributes.default_venue.value); 

I'm getting the error, Identifier 'default_venue' is not in camel case. This wouldn't be a problem normally but I don't have any control over the variable name - it's brought in via a JSON API.

Is there any way I could suppress this issue for either the affected variables or on the lines in which they appear?

Apologies if this has been asked before, I'm pretty sure it must have been but I can't find a solution.

like image 615
Sam Beckham Avatar asked Oct 18 '13 11:10

Sam Beckham


2 Answers

JSHint obeys directives at a function level, so you can find the enclosing function and add a camelcase option to it. Here's an example:

/*jshint camelcase: true */  var not_camel_case = 1; // Warns  function example() {   /*jshint camelcase: false */   var not_camel_case = 2; // Does not warn } 
like image 116
James Allardice Avatar answered Sep 19 '22 04:09

James Allardice


According to the JSHint Docs, you can make a config file in the same directory called .jshintrc, or any directory all the way to your root directory. I just set mine using this:

  {     "camelcase": false   } 

There are loads of other options here: http://jshint.com/docs/options/#camelcase

like image 31
ryanabooth Avatar answered Sep 20 '22 04:09

ryanabooth