FAQ Database Discussion Community


JSHint - Indent to bracket

indentation,jshint
I have my JSHint configured to validate indentation in my code. Here's rule indent: 4 This rule warns places where I have indentation to bracket. How do I get this fixed? Here's the code that I am referring to slug : { type: String, required: true, unique: true } Here's...

Why jshint alerts Read only on lastSelectedRow

javascript,jslint,jshint
Code below pasted to jshint.com site causes error Read only at line lastSelectedRow = 1; Why this error occurs and how to fix it? jslint does not thow this error. /*global lastSelectedRow */ function main() { lastSelectedRow = 1; return 'Hello, World!'; } main(); ...

JSLint - Undeclared 'jQuery' warning

javascript,jquery,jslint,jshint
I am trying to make the following jQuery code JSLint compliant. (function ($) { "use strict"; $('.addition').click(function () { $('.textbox:last,.addition:last,.subtraction:last,.replace:last').clone(true).appendTo('.replace:last'); $('.textbox:last').val(""); $('.addition:not(:last),.subtraction:not(:last)').attr('disabled','true'); }); $('.subtraction').click(function () { if($('.replace').length === 1) { $('.subtraction').click(function (event) { event.preventDefault(); }); } else {...

Prevent jshint from reporting that a variable is unused for specific local variables?

javascript,jshint
When running jshint on several of my javascript files, I get warnings like this: file.js: line X, col 93, 'fromParams' is defined but never used. file.js: line X, col 72, 'toParams' is defined but never used. file.js: line X, col 63, 'toState' is defined but never used. file.js: line X,...

Unable to run/find JSHint

node.js,gruntjs,jshint
Brand new to Grunt trying to put together a configuration file and having some difficulties. I'm trying to run JSHint, and the file is unable to be found. Directory set up is ./htdocs/[js, css, sass, images, html files] ./build/[] .node_modules/[grunt,grunt-contrib-compass/watch/htmlmin/uglify, jshint, matchdep] ./Gruntfile.js, package.json Currently JSHint is installed globally using...

jshint and variable names out of my control

javascript,angularjs,oauth,jshint
I'm handling an oauth response from twitter in an angular page that reads the parameter like this: var oauthToken = $location.search().oauth_token; Jshint will complain because line 13 col 0 Identifier 'oauth_token' is not in camel case. Alternatively I can write it as var oauthToken = $location.search()['oauth_token']; But then jshint will...

Fail subsequent gulp tasks if first task fails

gulp,jshint
I have my default task in my gulpfile.js that looks something like this: gulp.task('default', [ 'jshint', ... ]); What I'd like to do is have the rest of the tasks not execute if task jshint returns warnings. In other words, "fail fast." Is this possible? It appears to me that...

Which tool can I use to generate a .jshintrc file with default options?

jshint
I've being using JSLint for some time now and recently found JSHint. Reading the docs I learned that it can be configured using a .jshintrc file but I could not found if it's possible to generate this file using the CLI. Is there a flag in the CLI to generate...

JShint not working in any text editor

sublimetext3,jshint,brackets,sublimelinter
JShint will not run in any text editor I have (Sublime Text 3 and Brackets). JShint is installed globally on my system. SublimeLinter and SublimeLinter-jshint are installed in Sublime Text 3. JShint is installed in Brackets and the added: "language": { "javascript": { "linting.prefer": "JSHint", "linting.usePreferredOnly": true } } to...

How can I declare globals for jshint to ignore in ember-cli?

ember.js,ember-cli,jshint,sinon
I'm using sinon in my specs and including it in the Brocfile as describe in the ember-cli docs. This works and I can use sinon in my specs. But, jshint is complaining that sinon is not defined: 1 error: expected false to be truthy AssertionError: unit/views/edit-todo-test.js should pass jshint. unit/views/edit-todo-test.js:...

How to prevent “missing use strict” at end of IIFE assigned to variable?

javascript,jshint
Using jshint, if you have something like: var Thing = (function(){ "use strict"; // code and stuff... }()); I get a "missing use strict" error on the last line. I suppose this is because the var Thing = falls outside of the strict scope. Is there a way to prevent...

How to make JsHint sbt plugin more useful?

jshint,sbt-plugin,playframework-2.4
When I have jshint sbt plugin enable in my Play project, I get these annoying errors which are really not errors. How can I turn them off, or avoid them? Thanks ...

Where did style related rules go in jshint?

jshint
It seems the team behind jshint, decided to remove all style related rules/options (read more about it here). like: smarttabs indent nomen and a couple of others. Is there a way I can reactivate them?...

Jshint: Anonmyous function within a loop (Issue)

javascript,jshint
My problem is similar to JSHint won't let me use 'forEach' in a 'for' loop We have about 2k JS lines in currently project, recently included jshint checking, one common issue is the below sample code would throw Don't make functions within a loop. sample code: var s1 = '12345'.split('');...

Why does JSHint claim I'm missing a semicolon? [closed]

jquery,jshint,semicolon
JSHint is telling me that the last line is missing a semicolon: $('#radbtnEmp').click(function () { if ($('#radbtnEmp').attr('checked', true)) { alert("radbtnEmp checked"); } else { alert("radbtnEmp not checked"); } }; As you can plainly see, I've got a semicolon there; surely it's not blind or gluttonous (not seeing the semicolon, or...

javascript and jshint, undefined

javascript,jshint,defined
Today I wrote this code: (function (window) { 'use strict'; function ViewPort() { var getSize = function () { var e = window, a = 'inner'; if (!('innerWidth' in window)) { a = 'client'; e = Document.documentElement || Document.body; } return { width : e[a + 'Width'], height : e[a...

Looping through elements - how to avoid “(var) is defined but not used” errors?

jquery,jshint
This is my code: $.each($('.pages a[href!="#"]'), function (idx, elem) { var href = $(this).attr('href') // other code }) So basically, I'm using JQuery's .each to loop through the selected elements, but I'm using $(this) to access each element's attribute. JSHint complains about this, saying that elem and idx are defined...

Expected ')' to match '(' from instead saw while running the JSHint [closed]

javascript,d3.js,jshint
I am using the d3 library to draw a path/line, for this I need to use stroke-dasharray property as given below. This works fine for me, vis.append("path") .attr("class", "predictedLowerCI") .attr("d", valueline5(scope.rowdata)) .attr({ 'stroke-dasharray': (2, 2) }) When I run JSHint, I get the following error "Expected ')' to match '('...

jshint - ignore node_modules directory

jshint,eslint
I am simply running: $> jshint . which looks through my project's directory for .js files, but it is also looking into the node_modules directory which has a shit-ton of .js files that I don't really want to know about. I might mention that eslint works out of the box...

JSHint is not working

node.js,jshint
I have installed jshint using the following command npm install -g jshint I have test.js file with the following statement console.log(a) I tested the file using the following command jshint test.js Problem: jshint is not working It should throw the following error/warning One warning - Missing semicolon One undefined variable...

JShint warning: jQuery plugin marked incorrectly 'defined but never used' in AMD

javascript,jquery,requirejs,amd,jshint
JSHint is throwing a "jQueryPlugin is defined but never used" error on the declaration of jQueryPlugin. How do I tell JSHint to either ignore this specific error or define jQueryPlugin in a way JSHint understands. define([ 'jquery', 'underscore', 'backbone', 'some-jquery-plugin' ], function ($, _, Backbone, jQueryPlugin) //here is the error...

Jshint jasmine functions undefined in mean.js

jshint
I have a mean.js application running, and every jasmine function name returns undefined even when i did what the following told me to do: JSHint thinks Jasmine functions are undefined This is the relevant code from my project: .jshintrc { "node": true, // Enable globals available when code is running...

Error in installing JShint in Vagrant environment

vagrant,jshint
Good day to all: I had these error while installing JShint and CSS Linter thru my Vagrant environment. I'm using Vagrant in Windows and Ubuntu is on my vagrant box. I already installed npm and nodejs, tried lot of updates way but no luck. Maybe others can shed a light....

JSHint file location to add “-W041”: false

javascript,jshint
i want to find the location of jshint file for adding below code but i cannot find where the jshint file. { "-W041": false } I installed JSLint via notepad++ plugin manager....

JSHint Gulp to error window VS2015

gulp,jshint,visual-studio-2015
How can I get the output from JSHint to show up in my Error List in Visual Studio 2015 when using Gulp, rather than just output to the Task Runner? I've tried this package but that doesn't seem to do anything except format the Gulp output slightly differently. This is...