BigBinary Blog

We write about Ruby on Rails, React.js, React Native, remote work, open source, engineering and design.

Integrating JavaScriptLint with mvim

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.

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

In such cases JavaScriptLint had warnings for me.

1unexpected 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.

1before: +ambiguous_newline
2after: -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.

1let 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.

Neeraj Singh in JavaScript
September 8, 2009
Share

Subscribe to our newsletter