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
1 answer

Put semicolons in asi mode before brackets

I'm linting my JavaScript with JSHint, and have this option enabled "asi": true, "white": true to avoid semicolons in my code. But I have to begin my new line with a bracket, so I have to put a semicolon before the opening of that one ;(function ()…
Luke
  • 2,976
  • 6
  • 34
  • 44
0
votes
1 answer

Running JSHint using JavaScriptCore with options passes when it should fail

From within the jshint directory running the following fails as expected: env/jsc.sh ${REPO}/${FILE} But when trying to add options, it passes: env/jsc.sh ${REPO}/${FILE} "{browser:true}" Am I setting the options correctly? The code it evaluates…
Sam3k
  • 960
  • 1
  • 11
  • 22
0
votes
1 answer

Javascript: refactor function outside of loop

So JSHint tells me I should not make functions within a loop. I then usually make a function outside the loop. But now I have a part where this is more difficult: for (r=0;r
clamp
  • 33,000
  • 75
  • 203
  • 299
0
votes
2 answers

jsLint/jsHint maven site reporting

We are looking to incorporate jsLint or jsHint into our continuous integration process, I have found many maven plugins that will execute jsLint or jsHint and will break the build if the rules have been violated. We do not, however, have the luxury…
user975060
  • 335
  • 4
  • 16
0
votes
0 answers

Setting this to a var causes possible strict violation:

Possible Duplicate: Why is JSHINT complaining that this is a strict violation? In the abbreviated code below I use this function for determining if a function argument is an element id or an object. This way I always have the element to work…
CS_2013
  • 1,158
  • 3
  • 13
  • 24
0
votes
1 answer

jshint: funky code vs semicolons; how to silence all of jshint's complaints about semicolons here?

I'm not a fan of ASI. But given that this is perfectly legit JavaScript, where exactly is it here that jshint (repeatedly, 8 times over) is expecting to find a semicolon? script.addEventListener('load', function () { ++i !==…
BrianFreud
  • 7,094
  • 6
  • 33
  • 50
-1
votes
2 answers

Connection to server got closed. Server will restart. events.js:292 errno: -4058,code: 'ENOENT'

could somebody help me handle this issue? Explain to me why it happens, please. If some more data is needed, just ask. thank you. events.js:292 throw er; // Unhandled 'error' event ^ Error: spawn C:\Program Files\Microsoft VS…
oOHumen
  • 1
  • 1
-1
votes
1 answer

How to use jsHint to extract code metrics in the CLI report?

I am trying to get code metrics from jshint like on jshint.com: Metrics There is only one function in this file. It takes no arguments. This function contains 2 statements. Cyclomatic complexity number for this function is 1. The cli execution…
PhD
  • 11,202
  • 14
  • 64
  • 112
-1
votes
1 answer

error in javascript code detected in sidebar

I am Beginner and making sidebar, I used JsHint to check js code error following error is showing but the sidebar is working please guide to fix error This was the error Two unused variables 1 openFunction 5 closeFunction And here is my…
-1
votes
1 answer

Installing JSHint on VS Code

I tried to install JSHint through command, but I'm getting this error: C:\Users\user>npm install -g jshint 'npm' is not recognized as an internal or external command, operable program or batch file.
Mawadda
  • 7
  • 1
  • 8
-1
votes
2 answers

I can't fix the "let" warning in JSHint plugin for vscode in all the new projects I create

When I write: let name = "Henry"; The following warning message appear: 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). I don't have any idea what to do for correct that warning. The answers I found are create…
Joan-GS
  • 15
  • 1
  • 6
-1
votes
1 answer

Expected an assignment or function call and instead saw an expression when calling function

I am making a flashcard/test program. For some reason, I'm not checking the result when I call the function getAns. JSHint is giving this error: Expected an assignment or function call and instead saw an expression. Here's my code: function…
ARI FISHER
  • 343
  • 1
  • 13
-1
votes
1 answer

How to fix 'Function declarations should not be placed in blocks' error in Javascript es6?

After a long time without using Javascript, I try to do understand what is es6, modules and iife. So I make a little piece of code : { 'use strict'; let version = '1.0.0'; function init(){ /* ... */ } window.Test = { …
S.MyName
  • 3
  • 2
-1
votes
1 answer

SublimeLinter JSHint stopped working

System configuration is: Win 7 x64 SublimeText 3 SublimeLinter-JSHint Everything was installed properly and worked fine (node.js, jshint installed through npm). At some point the linter just stopped seeing JS syntax errors. Except for JSHint, some…
0leg
  • 13,464
  • 16
  • 70
  • 94
-1
votes
1 answer

Is javascript eval still dangerous if code is checked using (for example) jshint before eval?

Imagine for example (authorized) users are allowed to submit custom formatters to a nodejs server that would have some code like this. var JSHINT = require('jshint').JSHINT; function formatterFactory(code) { // we could pass more options to…
redben
  • 5,578
  • 5
  • 47
  • 63