Verify JavaScript with JSLint during build using Nant

image Project I’m working on has a lot of JavaScript. We are minimizing JavaScript files during the build and combining them into one file. Problem is when someone checks in some invalid JavaScript into repository that doesn’t minify properly. As a result you can end up with not working JavaScript at all. There is a tool called JSLint. It is created by Douglas Crockford who is also the author of a very good book about JavaScript: “JavaScript: The Good Pars”.

JSLint is a very strict JavaScript verifier. JS files corrected to a JSLint specification could be minified with confidence.

We made the decision that build should brake when JSLint detects invalid JavaScript file, so developer will need to fix it before the code checkin.

Prepare the tool base

As a first step we need to get all the tools that will execute JSLint validation against our codebase. You can grab fulljslint.js from the JSLint home page. There is no executable binary for JSLint, it is just a JavaScript file with set of rules and function to execute verification. Our working environment is Windows we can execute validation using cscript.exe command line tool that Windows has. There is a very useful script created by Jason Diamond that helps to execute JSLint validation. You can get it from from here: jslint.wsf. One last thing is a command line batch file that helps execute this tool. You can name it whatever you would like to. I named it jslint.bat. The content of it looks like this:

@cscript //nologo %~dp0\jslint.wsf %*

I put all those three files into build tree, in tools folder. You can check if all the files are valid and working properly by running this command from command line:

jslint.bat c:\path\to\your\js\file.js

Create a build target

Now that we have all the tools we can create a build target. We are using Nant as a build tool. I created Nant target and called it jslint. It looks like this.

<target name="jslint" description="validates JS files">

    <foreach item="File" property="jsfile">



                <include name="path\to\scripts\folder\**\*.js" />




            <exec program="jslint.bat" commandline="${jsfile}" />




There is a lot of stuff that could be turned on/off during validation. If you type jslint.bat without any parameters it will give you a list of possible options. Those could as well be tweaked in the jslint.wsf file.

Hope this helps you as it did for us.

Some says that JSLint might hurt your feelings. I say, bring it on 🙂


The machine that changed the world

image I heard a lot about Lean software development. By heard a lot I mean that I heard people saying the world, not actually knowing what it really is. Being a very curious man I decided to read about it. Colleague of mine, Jason Yip recommended this book “The Machine That Changed The World: The Story of Lean Production – Toyota’s Secret Weapon in Global Car Wars That Is Revolutionizing World Industry” by James P. Womack, Daniel T. Jones and Daniel Roos. I have to agree, the tile is rather long. It tells a story of Lean Production in a way it was born, in car industry after World War II. I started to read it and decided that I’m going to blog what’s in the chapters that I go through. I hope it will serve me as a notes from the book and as a teaser for anyone else.


What I learned in introduction is:

  • a bunch of scientists that meet in MIT decided to collect all the information from all major car manufacturers around the world about every single aspect of car manufacturing
  • team of 65 people were gathering information from all major car manufacturing companies
  • book is based on academic research but presents a dry summary of findings, instead of being a report

Continue reading

Custom JavaScript KungFu and management for Microsoft MVC.NET

Rails community got a lot things right for web application. One of them is the way they manage JavaScript files. I’m working on a web project where I use a lot of JavaScript and MVC.NET as Web Framework. Team is quite big and JavaScript is getting out of control. Files are everywhere with a lot of code. And then when it goes into production it is the best to have it as one compressed and minified file. So, here what we did.

Where am I, ups, production, I better behave

The easiest possible way of telling the app where it is running will be in Web.config. There is already a bunch of custom setting in there, so why not just have one more. When the time comes based on the Environment information we can decide if we will still spit out single un-minified files for a development environment or serve one minified file for lightning fast production performance.

Continue reading

MySQL console beep … grrrrrrr

Sitting and doing some evening bed time development is usually not a stressful event. Listening to a calm music and than, in a middle of a chilled out thinking process, awesome, LOUD beep from a PC speaker announcing to my neighbours 10 floors up that I just made a typo when I tried to execute SQL query from mysql console. This awesome feature cased me a heart attack and Wife attack (I got a slap in a head for the attempt of waking my Daughter up).

After a 10 minute relaxation session I decided to put a ripped out speaker back to its original spot in the machine and google for a solution.

It looks like when you are starting the command line MySQL terminal there is a way of disabling the fantastic feature so happily put there by the awesome MySQL team. –b option does it.

C:\projects\>mysql –b –u root –p

Hope you will avoid the little BEEP sound that could wake up dead.

Cheers, Greg