Gulp returns 0 when tasks fail

You need to ‘return gulp.src(…’ so that the task waits for the returned stream. EDIT Gulp tasks are asynchronous by nature. The actual task is not executed yet at the time of ‘gulp.src(…).pipe(…);’. In your example, the gulp tasks mark their results as success before the actual tasks are executed. There are some ways to … Read more

jshint expects the new ‘prefix’ for functions

If newcap is enabled, JSHint expects functions starting with a capital letter to be constructors and therefore to be called with the new keyword. Solution: Either disable this option or rename your functions. From the documentation: This option requires you to capitalize names of constructor functions. Capitalizing functions that are intended to be used with … Read more

setup pre-commit hook jshint

There’s an easier way of doing pre-commit checks (e.g. JSHint) in your Node.js workflow: Install jshint from NPM: npm install jshint Next create a .jshintrc file in your project if you don’t already have one. e.g: https://github.com/nelsonic/learn-jshint/blob/master/.jshintrc Now install pre-commit module (and save it as a dev dependency): npm install pre-commit –save-dev Next you will … Read more

How to tell JSHint to ignore all undefined variables in one file?

The correct way to tell JSHint about globals is to use the globals directive. For example: /*globals globalFunction, anotherGlobal, oneMore */ This will prevent “{a} is not defined” warnings when JSHint encounters any of the listed identifiers. Alternatively, if you really want to ignore all “not defined” warnings in that file, and you’re using JSHint … Read more