Questions tagged [jshint]

A community-driven tool to detect errors and potential problems in JavaScript code and to enforce coding conventions.

About

JSHint is a community-driven tool to detect errors and potential problems in JavaScript code and to enforce coding conventions.

JSHint is very flexible so you can easily adjust it to your particular coding guidelines and the environment you expect your code to execute in.

Interface

JSHint is available:

  • Via a web interface at http://jshint.com/
  • Via npm with npm install jshint or npm install -g jshint for global install
  • As plugins for many text editors and IDEs.

History

JSHint is a fork of JSLint, the tool written and maintained by Douglas Crockford.

The project originally started as an effort to make a more configurable version of JSLint - the one that doesn't enforce one particular coding style on its users — but it then transformed into a separate static analysis tool with its own goals and ideals.

Goals

JSHint's goal is to help JavaScript developers write complex programs without worrying about typos and language gotchas.

Its developers believe that static code analysis programs — as well as other code quality tools — are important and beneficial to the JavaScript community and, thus, should not alienate their users.

Resources

Related Tags

983 questions
0
votes
2 answers

JSHint not recognizing "intended scopes" for variables

Based on the description of the funcscope option in its documentation, it seems JSHint recognizes the utility of the variables being declared in "intended scopes" e.g. control structures etc. (even though in reality within a function in JS there is…
Himanshu P
  • 9,586
  • 6
  • 37
  • 46
0
votes
1 answer

JsHint, can I target all unused parameters in a function definition instead of just last?

This is more a sanity check idea. Currently unused:true only makes sure the last function parameter is used, but sometimes I want to make sure that I'm using what everything passed in. Is there an override to make see all unused function…
Core
  • 840
  • 11
  • 24
0
votes
1 answer

Comma first validation with no space

I am building a JSHint set for a JavaScript suite that I am writing. My habit with writing objects is as follows: var obj = { hello: 'World' ,foo: 'Bar' ,name: 'Dave' }; I use Grunt and grunt-contrib-jshint to run the validations with the…
Dave Long
  • 9,569
  • 14
  • 59
  • 89
0
votes
3 answers

coffeescript + jshint = Unused variable: _this

Compiling any code with bare = false and linting it with JShint results in Unused variable: _this. Solutions to this? bare = true should remain, besides I'm pretty happy to have jshint checking for unused variables. I just want an exception…
Alex
  • 11,479
  • 6
  • 28
  • 50
0
votes
1 answer

jshint error with regular expression

Does anyone know why jsHint says this regular expression has a "Bad Escapement"? var regexp = new RegExp('^http(s)?:\/\/([a-z]+\.)?(' + this.opts.domain + ')', 'ig'); It's complaining about the escaped period \. The regex still works without…
Michael Turnwall
  • 649
  • 7
  • 21
0
votes
1 answer

jshint not recognizing devel

I'm using jshint and have the following options defined: /*global $, _*/ /*jshint devel:true*/ My understanding is that by having /*jshint devel:true*/ it should allow console and alert, but I continue to get errors on them. Any ideas if there's…
dzm
  • 22,844
  • 47
  • 146
  • 226
0
votes
1 answer

JavaScript: Getting rid of three JSHint errors

Please find below a snippet of my Node.JS server code: // Define the user API var API = { list: 'private', login: 'public', logout: 'private', add: 'admin', remove: 'admin', edit: 'admin' }; // Attach API handlers for(var…
Randomblue
  • 112,777
  • 145
  • 353
  • 547
0
votes
1 answer

Which is the basic structure of a code syntax error detection using javascript?

I am designing a language, and I would like to enhance the user experience with a rich code editor. First I tough in CodeMirror, but then I found ACE Editor, which is open source too :) I have read everything and decided for the second option. But I…
Miguel Jiménez
  • 1,276
  • 1
  • 16
  • 24
0
votes
1 answer

jshint functions with dots in the name

I'm running jshint on a javascript file, and some of the functions have dots in their names (as a way of namespacing). In particular, I'm using the d3 library, and I have a lot of code that looks like d3.select("something") Do I just need to turn…
Jeff Storey
  • 56,312
  • 72
  • 233
  • 406
0
votes
1 answer

Remove function creation in loop - closure

I want to remove the function creation in my code, but I don't know how? Can anyone here help me? for (var eventName in this.events) { var eventFunc = this.events[eventName], splitEventName = eventName.split(" "), …
TryingToImprove
  • 7,047
  • 4
  • 30
  • 39
0
votes
1 answer

Why is JS Lint is reporting an error in the JQuery library?

Possible Duplicate: What good is JSLint if jQuery fails the validation Why am I getting JS Hint error "missing space after 'function'." for an empty mvc 3 project? The error is in file "jquery-1.5.1-vsdoc.js" on line 28 "(function( window,…
Tim K
  • 1
0
votes
1 answer

JSHint + Flymake - infinite loop error checking

I've tried to figure the problem myself, and will probably continue, but due to poor error reporting it's just too time consuming. So, perhaps, if anyone had encountered this problem before, please share. What happens: after flymake-jshint…
user797257
0
votes
2 answers

How to get JSHint smarttabs option working in Sublime Text 2

I can't seem to get the Sublime Text 2 SublimeLinter package to stop showing the "Mixed tabs and spaces" warning. I've set "smarttabs" : true in the settings, but it's still not taking. Has anyone else solved this problem yet? Here's my user…
evanmcd
  • 1,967
  • 3
  • 32
  • 52
0
votes
1 answer

Vim throwing a "Not an editor command: JSHint" error

I have JSHint installed and working in vim as evidenced by the fact that when I save a file, I can see it pointing out the errors in the code. But when I type in :JSHint at the command line, it says it's not a command. I'm using the pathogen.vim…
StevieD
  • 6,925
  • 2
  • 25
  • 45
0
votes
2 answers

jshint complaining about not defined?

Why does jshint warn that gConfiguration is not defined? I have it defined before the start of the func. I also tried placing it inside. I know I can declare it as a global variable in the configuration but I don't see what this is wrong? requirejs…
ryan
  • 6,541
  • 5
  • 43
  • 68