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

Configuring jshint using grunt and gradle

I was trying to configure jshint using grunt and combining with gradle, while I am trying to run my task below is the error that I am facing Loading "jshint.js" tasks...ERROR >> Error: Cannot find module 'jshint' >> at…
Gary
  • 13
  • 1
  • 4
0
votes
2 answers

This 'switch' should be an 'if' - why?

I am running my code through JSHint, and I'm hitting this error: This switch should be an if On this block of code: switch(true) { case Major === 0 && Minor === 0 && Patch < 433: upgraded = upgraded.replace(/(\s+)skill(\d)=/gm,…
Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
0
votes
1 answer

How to set the list of options in JSHint?

I want to suppress some warnings/errors in JSHint. In the document it says to pass it as an argument, but I am a bit confused. source = "...."; // JavaScript source content var success = JSHINT(source, options, globals); For example, I want to…
Gandalf
  • 920
  • 3
  • 10
  • 24
0
votes
2 answers

Detect unused AMD dependencies

Is there any tool that can analyze my files for unused AMD modules so that I can clean up my code if I remove a previously used dependency? I know to a certain degree jshint can do this with the unused option, but setting it to true ignores unused…
Martin Hansen
  • 5,154
  • 3
  • 32
  • 53
0
votes
1 answer

JSHint tolerate braceless If Statements

Is there a flag to allow braceless If statements in JSHINT? ie: if (true) return false; I've looked through the docs, but didn't find anything...
Lane
  • 6,532
  • 5
  • 28
  • 27
0
votes
1 answer

Node sequelize callback promises expect a function, is there a method for removing declared function with a function call

I'm having an issue with the node sequelize library. When using the success promise as shown below: for (index = 0; index < models.length; index++) { model = models[index]; model.drop().success(function() { …
Gerard Downes
  • 643
  • 11
  • 25
0
votes
1 answer

Using both JSLint and JSHint

The project I joined is using JSLint and JSHint at the same time. They're launched for the same files, with a unique grunt task. My understanding is that one could use one of them, but when using both of them there's an overlap on the analysis and…
DjebbZ
  • 1,594
  • 1
  • 18
  • 34
0
votes
2 answers

In Javascript, under what conditions is it appropriate to only use `this` in constructor functions?

I found an interesting line of code in JSHint's config options. The comment associated with the option reads Tolerate using this in a non-constructor function. I am confused. Am I misunderstanding the config option? Aren't there a lot of cases where…
Cho Naseo
  • 96
  • 1
  • 8
0
votes
1 answer

Code mirror get uncomment code only

I have implemented the latest code mirror in our asp.net application. the editor allows to type javascript which has commented code and un commented code. I want to know whether all the code written in the editor is commented or not. Can anyone…
Shiras
  • 115
  • 1
  • 1
  • 7
0
votes
2 answers

How to export/import settings and change advanced settings

I'm using VS 2012 Extension Web Essentials 2012 and I have some questions about it: I'm trying to export its settings so they can be shared on other machines. But I can't find any hint on that. And if it is somehow possible, how can I extend the…
0
votes
1 answer

jshint vimrc SpellBad customization does not stick

Using " Customize jshint highlights hi clear SpellBad hi SpellBad cterm=underline,bold ctermfg=white ctermbg=black I was able to customize my jshint SpellBad highlights to the colors I desire when I first open a buffer containing jshint errors.…
Calvin Cheng
  • 35,640
  • 39
  • 116
  • 167
0
votes
2 answers

JSHint chaining method calls

I have the following code in an Angular app: 'use strict'; angular.module('fooApp') .controller('FooCtrl', function ($scope) { }); When I run JSHint (with indent set to 4) on this code, I get the following error: [L6:C5] W015: Expected…
cdmckay
  • 31,832
  • 25
  • 83
  • 114
0
votes
1 answer

JSHint Eclipse Plugin Predefined Variables Throwing Not Defined Warning

After a lot of troubleshooting, I've simplified my test case to just this... I'm using only a brand new download of Eclipse Juno and the JSHint plugin. Then I start a new project. The checkbox 'Enable project specific settings' within JSHint's…
jpgrace
  • 401
  • 4
  • 9
0
votes
1 answer

How do I configure JSHint with Adsafe?

Does anybody know how to configure JShint with the safe and adsafe options? I went through http://www.jshint.com/docs/ but didn't find anysuch option.
TheRookierLearner
  • 3,643
  • 8
  • 35
  • 53
0
votes
4 answers

Is it safe to change == to === according to jshint's error detection without further checking

I'm checking JavaScript code based on JSHint tool. This tool detected lots of errors about using "===" instead of "==". My question is that Is it safe to just follow what JSHint said? Do I need to check further (about their types and values) before…
crazy_in_love
  • 145
  • 3
  • 13