Integrating JavaScriptLint with mvim

Neeraj Singh

Neeraj Singh

September 8, 2009

I use JavaScriptLint along with JavaScriptLint.vim on mvim to catch any JavaScript syntax error or missing semicolons. It works great except in cases when I am chaining methods like this.

var select_col1 = $("<select></select>")
  .addClass("ram_drop_down")
  .addClass("ram_drop_down_col1")
  .attr("name", "adv_search[" + random_num + "_row][col1]")
  .attr("id", random_num + "_ram_drop_down_col1");

In such cases JavaScriptLint had warnings for me.

unexpected end of line. It is ambiguous whether these lines are part of the same statement.

JavaScriptLint wants me to put the dot at the end of the line and not at the beginning of the line. Well, I like having dots at the beginning of lines and I wanted to turn off such warning.

JavaScriptLint comes with a default config file. I copied the config file to a personal directory and disabled the warning.

before: +ambiguous_newline
after: -ambiguous_newline

Also I had to comment out +process jsl-test.js at the very bottom. Now tell your plugin to use this configuration file rather than the default one. Add the following line to your vimrc file.

let jslint_command_options = '-conf "/Users/neeraj/vim/plugin/jslint/jsl.custom.conf" -nofilelisting -nocontext -nosummary -nologo -process'

This is the vim settings I use and it has been configured to take care of it. Just go to vimrc.local and change the path to your config file. Also don't forget to remove " at the beginning of the line to uncomment it.

If this blog was helpful, check out our full blog archive.

Stay up to date with our blogs.

Subscribe to receive email notifications for new blog posts.