Git Product home page Git Product logo

jslint.vim's Introduction

This project is no longer under active development. For alternatives take a look at the Alternative Plugins section below. Or check out the actively developed forks of this project: wookiehangover/jshint.vim and FuDesign2008/jslint.vim.

jslint.vim

Vim plugin and command line tool for running JSLint.

JSLint is a handy tool that spots errors and common mistakes in JavaScript code.

The source code for jslint.vim is hosted at http://github.com/hallettj/jslint.vim.

This is alpha software and is under heavy development.

Installation

  • Make sure you have a JavaScript interpreter installed. On Linux jslint.vim supports Spidermonkey, Rhino, and node.js. Spidermonkey or node.js are recommended because Rhino tends to have a long startup time.

    In Ubuntu you can install the Spidermonkey shell with this command:

      $ sudo apt-get install spidermonkey-bin
    

    Latest Ubuntu versions don't have spidermonkey in the default repositories. You can use rhino instead:

      $ sudo apt-get install rhino
    

    Or you can find instructions for installing node.js on the node.js website.

    On Windows you can use cscript.exe - which is probably already installed.

    On MacOS X you don't need to install any JavaScript interpreter because one is included with OS X by default.

  • If you have rake installed, run:

      $ rake install
    

    Otherwise copy the directory ftplugin/ into your Vim ftplugin directory. Usually this is ~/.vim/ftplugin/. On Windows it is ~/vimfiles/ftplugin/.

  • Finally, activate filetype plugins in your .vimrc, by adding the following line:

      filetype plugin on
    

Usage

  • This plugin automatically checks the JavaScript source and highlights the lines with errors.

    It also will display more information about the error in the commandline if the curser is in the same line.

  • You also can call it manually via :JSLintUpdate

  • You can toggle automatic checking on or off with the command :JSLintToggle. You can modify your ~/.vimrc file to bind this command to a key or to turn off error checking by default.

  • (optional) Add any valid JSLint options to ~/.jslintrc file, they will be used as global options for all JavaScript files. For example:

      /*jslint browser: true, regexp: true */
      /*global jQuery, $ */
    
      /* vim: set ft=javascript: */
    

To get a detailed report of any issues in your JavaScript file outside of Vim, run the bin/jslint executable in a terminal. For example:

$ bin/jslint ftplugin/jslint/fulljslint.js

You can copy bin/jslint into for PATH for easier access. The executable requires that the Vim plugin is installed and also requires Ruby.

To disable error highlighting altogether add this line to your ~/.vimrc file:

let g:JSLintHighlightErrorLine = 0

Working with quickfix

When automatic error checking is enabled jslint.vim will automatically display errors in the quickfix window in addition to highlighting them.

You can open and close the quickfix window with the commands :copen and :cclose. Use the command :cn to go to the next error or :cc [nr] to go to a specific error, where [nr] is a number. The first error in the list is 1, the second is 2, and so on.

Once an error is fixed the corresponding quickfix line will disappear.

Alternative Plugins

Syntastic supports syntax checking for a number of languages, including JavaScript via jshint or JSLint.

There are other plugins for Vim that integrate JavaScript Lint. JavaScript Lint is another JavaScript checker that is similar to JSLint.

jsl.vim uses Vim's compiler infrastructure making its use consistent with syntax checkers for other languages.

javaScriptLint.vim runs the contents of a JavaScript file through JavaScript Lint after the file's buffer is saved and places any warnings in the quickfix error window.

Credits

  • Jesse Hallett -- original author
  • Nathan Smith -- Windows compatibility, quickfix integration, better OS X compatibility, support for node.js, and other improvements
  • Travis Jeffery -- Easy plugin installation with rake
  • Sam Goldstein -- Display of problem report for the current line and bug fixes
  • Bryan Chow -- Fixes for formatting issues and typos
  • Jeff Buttars -- Options to remove and to disable error highlighting
  • Rainux Luo -- Support for reading JSLint options from a ~/.jslintrc file, Pathogen compatibility on Windows
  • Pascal Hartig -- Support for running jslint with rhino and other updates
  • Martin Schürrer -- Fixing path issues and error handling
  • Nik Graf -- Documentation updates
  • Ian McCracken -- Real-time error checking
  • Luke Smith -- Enhancement of OS X support
  • Michael Smith -- Feature to customize JavaScript executable that is used by setting JS_CMD environment variable
  • Szilágyi Szilveszter -- Fixes for bugs when running in Windows
  • Yasuhiro Matsumoto -- Pathogen compatibility and :JSLintToggle command
  • Ben Loveridge -- Integrated quickfix with automatic error checking
  • Brian Egan -- Documentation for enabling filetype plugins
  • Trent Mick -- Feature to ignore #! lines for compatibility with shell scripts
  • Christopher Sexton -- Fixed errors in MacVim on Lion and Snow Leopard
  • Brian Donovan -- Fix for non-POSIX shells
  • guileen (Lin Gui) -- Prefer node over jsc on Mac OS
  • daethorian (Lowe Thiderman) -- Fix for error in updated spidermonkey version
  • afairley -- Check for nodejs executable if node is not present

License

Copyright (c) 2008-2012 Jesse Hallett [email protected], except where otherwise noted

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

The Software shall be used for Good, not Evil.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

jslint.vim's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

jslint.vim's Issues

Windows command prompt focus pull

On Windows the stupid command prompt seems to want to pull focus. Not sure what to do about this. It pull focus for just long enough for a character or two to go missing while I'm typing. I know I can turn off the automatic checking, but I rather like it and would like to keep it. Any ideas?

Change Highlight Color

Is there any way to change the color used for highlighting errors? I have a black background in my terminal, and with the red highlighting characters of certain syntax colors disappear

Thanks, tried looking around but couldn't find where its specified.

jslint mess up vim input in terminal

jslint works fine with macvim, but in terminal, things go wrong.

  1. under vim insert mode, chars I didn't input will somehow be inputed.
  2. under vim normal mode, some words will be replace when cursor move over it, but only change in display, not file change. refresh by page down and up will get these changed word recover.

Error on Windows when path contains spaces

I'm seeing an issue on my Windows 7 64-bit machine that seems to result from s:plugin_path containing spaces.

plugin_path = C:\Program Files (x86)\Vim\vim73\ftplugin\javascript\jslint\

This causes the command to fail. I've temporarily fixed it with the following:

let s:cmd = 'cd "' . s:plugin_path . '" && ' . s:cmd . ' "' . s:plugin_path . 'runjslint.' . s:runjslint_ext . '"'

Which results in:

cd "C:\Program Files (x86)\Vim\vim73\ftplugin\javascript\jslint" && cscript /NoLogo "C:\Program Files (x86)\Vim\vim73\ftplugin\javascript\jslint\runjslint.wsf"

But obviously, an environment-agnostic solution would be preferred.

Thoughts about supporting jshint with this plugin?

I love this plugin, but would be interested in having it support jshint. If you have plans for it, great. Otherwise, maybe I'll fork what you have and try my hand at it. Thanks for this awesome plugin.

JSLint Hijacks Quickfix

I'm using the 'Ack' plugin. If i do an ack search, I get the results of the search in the quickfix window. However, if I then go to one of the entries in a javascript file, jslint will replace my ack search quickfix results with any results from jslinting the file. I suspect, though I haven't confirmed, that the jslint program will replace any quickfix entries with its own after going to a js file from the quickfix list.

Can I easily change from having the jslint plugin be an ftplugin to something I can map? After a quick glance at the source, it seems like I should be able to map a key to "s:JSLint()". However, I'm not extremely familiar with vimscript.

Thanks, otherwise love the plugin and use it all the time.

jslint-core.js crashes with spidermonkey 1.8.5

jslint-core.js:5655: ReferenceError: assignment to undeclared variable exports
using spidermonkey 1.8.5 2011-03-31

The fix is easy; just add a var statement to the declaration on that very row. I'm not sure how kosher that is, but it makes it work.

Vim(echoerr): could not invoke JSLint

Hi,

I am getting this error ( the one in the title ) when I try to open a .js file. In addition I get:

Error detected while processing function 87_JSLint:
Line 33:
could not invoke JSLint!

I am running Ubuntu 10.04. I am using jslint.vim_0.7. I have installed it with rake install. I have installed both node and spidermonkey.

where to put .jslintrc for jslint usage from command line

I'm trying to run jslint from the command line, but it seems to ignore my .jslintrc file. I have .jslintrc in my home directory and it works nicely inside Vim. I tried copying .jslintrc to the directory with the jslint, and to the directory where I was running it against .js files, but no luck.

I would really like to use this utility from the command line with my own jslint preferences, so any help would be greatly appreciated.

Running on Windows 7

Is there some special magic that I'm missing to get this script working on Windows 7? (or XP for that matter).

I've installed it using Pathogen and it just doesn't work. Seems like the matchlist() call doesn't work with the regular expression on Windows.

Is there something I need to set up in my _vimrc file to make this script work?

jshint.vim plugin hangs macvim on osx lion

Have no idea what happens, but it looks like macvim works just fine on lion without jshint plugin enabled and completely freezes app if jshint is enabled. It hangs macvim when switching from input mode to normal mode.

Annoying error message

The warning message "The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype" appears while moving through the lines and tripping in a unwrapped for loop. It takes the cursor to the command-line and requires a lot of typing to get out, particularly with the k key, the j it dismisses with one key stroke.

It does not happen every time. Normally I close and reopen the window a few times and the problem goes away.

can't install on; error message enclosed

I have tried various ways of installing. I use pathogen, would appreciate instructions on how to do that right...

But I also tried just putting the ftplugin in .vim/... the best I ever got was a message upon vim startup:

Error detected while processing function 14_JSLint:
line 40:
could not invoke JSLint!

I tried grep'ing around in the plugin, but couldn't find any of those symbols.

Thanks.

Error on Windows 7 (x64)

I use hallettj / jslint.vim on Ubuntu 12.04, everything is ok. but on windows 7(x64), it displays error:

Error detected while processing function <SNR>42_JSLint:
line 47:
The filename, directory name, or volume label syntax is incorrect ^@

Error detected while processing function <SNR>42_JSLint:
line 48:
could not invoke JSLint!

I try to solve the problem as follow, but not work:

  • rename jslint.vim/bim/jslint to jslint.exe then add to PATH

  • modify jslint.vim file:

    " let s:install_dir = expand(":p:h")

    if has("win32")
    let s:install_dir = '"' .
    expand("C:\Users\Administrator.vim\bundle\jslint.vim\ftplugin\javascript"). '"'
    else
    let s:install_dir = expand(":p:h")
    endif

  • install node.js, npm using npm install jslint -g to install jslint om cmd.exe


BTW: I adopt Vindle to manage my plugins.
This is my _vimrc.

how to set maxerr: parameter of jshint?

the maxerr limit for jshint is super annoying (and is likely to be removed from jshint core soon)
instantdelay/jshint@e99e47b
since it prevents you from seeing errors at the end of the file.

apparently you can set the maxerr parameter of jshint to 1000 or some arbitrary number that is so high it will not disguise any errors. How would I add this parameter (and maybe others) when I invoke :JSHint in command mode?

Is this project active?

I can't tell if anyone is going to maintain this project or not. The last commit was over a year ago. There are pending pull requests that I'd like to see merged into the project. Does anyone know if this project is going to be updated?

Thanks,

TR

Installation Error?

Hello,

I'm a vim nub, and when I can get this JSLint plugin to work it's my fav. Using MacVim.

When I use the "Rake Install" method, and it doesn't seem to work at all... I have also tried copying the javascript directory into my "ftplugin" dir and that does nothing. When I also copy the files from the "JavaScript" directory into my "~/.vim/plugin" dir, it works if I manually call :JSLintUpdate, but not if I'm moving around the file making changes, which is the ideal.

On Snow Leopard, using MacVim.

Thanks for your help!

when copying pasting comments get messed up

When I copy and paste something like:

        /** api: event[beforelayerselectionchange]
         *  Fired before the selected set of layers changes.  Listeners 
         *  can return ``false`` to stop the selected layers from being 
         *  changed.
         *
         *  Listeners arguments:
         *
         *  * layerRecord - ``GeoExt.data.LayerRecord`` the record of the
         *    selected layer, or null if no layer is selected.
         */

I end up with instead:

        /** api: event[beforelayerselectionchange]
  •          \*  Fired before the selected set of layers changes.  Listeners 
    
  •                       \*  can return `false` to stop the selected layers from being 
    
  •                                    \*  changed.
    
  •                                                 *
    
  •                                                              \*  Listeners arguments:
    
  •                                                                           *
    
  •                                                                                        \*  \* layerRecord - `GeoExt.data.LayerRecord` the record of the
    
  •                                                                                                     \*    selected layer, or null if no layer is selected.
    
  •                                                                                                                  */
    

Quick fix has empty list on Windows 7.

Hi, guys.
Thank you for this awesome project, and I really love it.

However, today, I found that it works differrently based on platform.
I have a windows 7 machine, and a mac osx machine.

Mac has no problem using jslint.vim. It gives more suggestions and works with quick fix very well.
On Windows, less suggestions and quick fix list is empty when I :copen.

I don't think this is the #24 issue.

I do have node.js on both machines. Can I change the csript.exe to node.exe?

Thank you very much.

wrong line numbers

I have a discovered a problem. It seems all errors are shown some lines before the actual error is. The number of lines it differs to the real error seems kind of random, ranging from approx. 5 to 15 lines.
This effects the highlighted error lines and the quickfix window.

I'm using Windows7 and gvim, but it also appears in normal vim on Windows.

Installation on Windows

How can I install the plugin correctly for GVim on Windows XP? I copied the plugin into ftplugin. After :JSLintUpdate, the following errors are displayed:

Error detected while processing function 33_JSLintUpdate..33_JSLInt:
line 23:
E484: Can't open file C:\DOCUME1\MICHAL1\LOCALS~1\Temp\TIoAC.tmp
line 25:
could not invoke JSLint!

Thank you,
Michal

exit code

JSLint should exit with code=1 if it found errors.

JSON and HTML checking

Since this has been changed to an ftplugin you can't syntax check JSON and HTML files, on which JSLint normally works, at least as far as I can tell.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.