jshint

Why does JSHint throw a warning if I am using const?

筅森魡賤 提交于 2019-11-29 19:03:18
This is the error I get when using const: <error line="2" column="1" severity="warning" message="&apos;const&apos; is available in ES6 (use esnext option) or Mozilla JS extensions (use moz)." source="jshint.W104" /> My code looks like this: const Suites = { Spade: 1, Heart: 2, Diamond: 3, Club: 4 }; The code works fine only JSHint is warning me every time. When relying upon ECMAScript 6 features such as const , you should set this option so JSHint doesn't raise unnecessary warnings. /*jshint esnext: true */ ( Edit 2015.12.29 : updated syntax to reflect @Olga's comments ) /*jshint esversion: 6

How do you use JSHint and Browserify together?

混江龙づ霸主 提交于 2019-11-29 17:16:32
问题 I'm attempting to build a project using Angular and Browserify. My controllers.js file looks like this... 'use strict'; module.exports.testController = function($scope){ $scope.message = 'Controller 1'; console.log( 'hello' ); }; As you may expect, that generates three linting errors. Use the function form of Strict 'module' is not defined 'console' is not defined I did find a bit of a solution here that enables JSHint to process Node.js files by putting jslint node: true at the top of the

How do you use JsHint “.jshintrc” file with Visual Studio 2013 Web Essentials extension?

我只是一个虾纸丫 提交于 2019-11-29 16:57:04
问题 I have installed the "Web Essentials" extension into Visual Studio 2013. I am now getting JSHint warnings appearing in my "Error List" window under the Messages section. However, it is complaining about some global variables that it thinks are not defined. From what I read, you can use JSHint's .jshintrc file to list global variables so it will stop complaining about them. I want to have it set up as follows. (so that it will stop complaining about "ko"... which is a KnockoutJs global

Why does jshint not recognize an assignment as an expression?

最后都变了- 提交于 2019-11-29 11:14:02
问题 How do I need to modify these lines to make jshint happy? An assignment is an expression. Why doesn't jshint understand this? Obviously the interpreter does. Line 572: while(bookmark_element=bookmark_list[iterator++]) Expected a conditional expression and instead saw an assignment. Line 582: while(bookmark_element=bookmark_list[iterator++]) Expected a conditional expression and instead saw an assignment. Line 623: while(element_iterator=element_iterator.nextSibling) Expected a conditional

JSHint thinks Jasmine functions are undefined

二次信任 提交于 2019-11-29 04:59:40
问题 I've got a Grunt setup which uses Karma+Jasmine and JSHint. Whenever I run JSHint on my spec file, I get a series of "undefined" errors, most of which are for Jasmine's built-in functions. For example: Running "jshint:test" (jshint) task js/main.spec.js 3 |describe("loadMatrix()", function() { ^ 'describe' is not defined. 4 | it("should not assign a value if no arg is passed.", function() { ^ 'it' is not defined. (I also get some undefined errors for the variables and functions from the JS

Have jshint ignore certain files when building Twitter Bootstrap

独自空忆成欢 提交于 2019-11-29 02:07:11
问题 I often have this problem when using Twitter Bootstrap with other 3rd-party JS libraries, such as html5.js from WordPress' "Twenty Twelve" theme, where the build fails because jshint (or jslint in previous versions of TB I think) throws an error due to the third-party JS library, e.g. \n################################################## Building Bootstrap... ##################################################\n js/html5.js: line 3, col 122, Expected ')' to match '(' from line 3 and instead saw

How to ignore node shebang error in Eclipse?

拈花ヽ惹草 提交于 2019-11-28 23:04:52
I am writing some node command line utilities. They all start with the line: #!/usr/bin/env node With Eclipse Juno and the Nodeclipse Node.js plugin, this line of code produces an error as shown: OK, so # is not a valid comment character in javascript, but it is a valid character in Linux/UNIX as the shebang of the first line in a file. But how can I set up Eclipse to ignore this error? This is a problem for me because code formatting does not work if you have errors. I have to delete the line. Hit CTRL-SHIFT-F and add the line back. I have tried a lot of things and researched, but I can't

Does jshint understand Angular?

本秂侑毒 提交于 2019-11-28 22:54:49
jshint is throwing an error when defining an angular module (or directive, or factory) as recommended by the Angular style guides (by John Papa or Todd Motto ). For example, for a controller like this: (function () { 'use strict'; angular .module('myApp') .controller('myAppCtrl', theController); function theController() {...} })(); ... jshint throws this error: 'theController' was used before it was defined. The angular app works perfectly despite these errors. However I don't know why jshint protests... What am I missing? I wonder if jshint is a good evaluator of the quality of the angular

gulp-jshint: How to fail the build?

南笙酒味 提交于 2019-11-28 22:41:23
I want my Gulp build to fail, if there are errors in JSHint. According to the documentation of gulp-jshint I can use the "fail reporter". However the following does not work: gulp.task("lint", function() { return gulp.src(JS_SOURCES) .pipe(jshint()) .pipe(jshint.reporter("jshint-stylish")) .pipe(jshint.reporter("fail")); }); The task above always returns with exit code 0, even when there are errors in JSHint. I am using gulp 3.8.10 and gulp-jshint 1.9.0. There are discussions in the github issues of gulp-jshint here and here ... but according those discussions I gather that above code should

Jshint.com requires “use strict”. What does this mean? [duplicate]

大城市里の小女人 提交于 2019-11-28 22:12:28
This question already has an answer here: What does “use strict” do in JavaScript, and what is the reasoning behind it? 27 answers Jshint.com is giving the error: Line 36: var signin_found; Missing "use strict" statement. Czarek Tomczak Add "use strict" at the top of your js file (at line 1 of your .js file): "use strict"; ... function initialize_page() { var signin_found; /*Used to determine which page is loaded / reloaded*/ signin_found=document.getElementById('signin_button'); if(signin_found) { More about "use strict" in another question here on stackoverflow: What does "use strict" do in