Permalink
Browse files

Added JSLint plugin.

  • Loading branch information...
1 parent 60a308b commit 932913f640272d8c60400a366e4f2d98f3a1e8b9 alessioalex committed May 6, 2011
@@ -0,0 +1,2 @@
+*~
+*.swp
@@ -0,0 +1,13 @@
+# jslint.vim change log
+
+## v0.7
+
+- Updated jslint to version 2010-08-08.
+- Now checks for errors on leaving insert mode, cursor hold, and buffer save.
+- Changed from plugin to ftplugin specific to JavaScript files.
+- Supported JavaScript interpreters now include Node.js, Rhino, Spidermonkey,
+ Windows Script Host, and that interpreter that is installed by default in Mac
+ OS X.
+- Added support for overriding the JavaScript interpreter that is used by
+ setting a value for the JS_CMD environment variable.
+- Fixes bugs when running in Windows.
@@ -0,0 +1,22 @@
+Copyright (c) 2008-2009 Jesse Hallett <hallettj@gmail.com>, 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.
@@ -0,0 +1,177 @@
+jslint.vim
+=============
+
+Vim plugin and command line tool for running [JSLint][].
+
+[JSLint]: http://jslint.com/
+
+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][nodejs].
+
+ [nodejs]: http://nodejs.org/
+
+ 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.
+
+[quickfix]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html "Vim documentation: quickfix"
+
+
+Alternative Plugins
+---------------------
+
+There are other plugins for Vim that integrate [JavaScript Lint][]. JavaScript
+Lint is another JavaScript checker that is similar to JSLint.
+
+[JavaScript Lint]: http://www.javascriptlint.com/
+
+[jsl.vim][] uses Vim's compiler infrastructure making its use consistent with
+syntax checkers for other languages.
+
+[jsl.vim]: http://www.vim.org/scripts/script.php?script_id=2630
+
+[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.
+
+[javaScriptLint.vim]: http://www.vim.org/scripts/script.php?script_id=2578
+
+
+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
+
+
+License
+---------
+
+Copyright (c) 2008-2011 Jesse Hallett <hallettj@gmail.com>, 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.
@@ -0,0 +1,61 @@
+# written by travis jeffery <travisjeffery@gmail.com>
+# contributions by scrooloose <github:scrooloose>
+
+require 'rake'
+require 'find'
+require 'pathname'
+
+PLUGIN = [
+ "ftplugin/javascript/jslint.vim",
+ "ftplugin/javascript/jslint/jslint-core.js",
+ "ftplugin/javascript/jslint/runjslint.js",
+ "ftplugin/javascript/jslint/runjslint.wsf",
+]
+
+files = PLUGIN
+
+desc 'Zip up the project files'
+task :zip do
+ zip_name = File.basename(File.dirname(__FILE__))
+ zip_name.gsub!(/ /, '_')
+ zip_name = "#{zip_name}.zip"
+
+ if File.exist?(zip_name)
+ abort("Zip file #{zip_name} already exists. Remove it first.")
+ end
+
+ puts "Creating zip file: #{zip_name}"
+ system("zip #{zip_name} #{files.join(" ")}")
+end
+
+desc 'Install plugin and documentation'
+task :install do
+ vimfiles = if ENV['VIMFILES']
+ ENV['VIMFILES']
+ elsif RUBY_PLATFORM =~ /(win|w)32$/
+ File.expand_path("~/vimfiles")
+ else
+ File.expand_path("~/.vim")
+ end
+ files.each do |file|
+ target = File.join(vimfiles, file)
+ target_dir = File.dirname(target)
+ FileUtils.mkdir_p target_dir
+ FileUtils.cp file, target
+ puts "Installed #{file} to #{target_dir}/"
+ end
+
+end
+
+desc 'Pulls from origin'
+task :pull do
+ puts "Updating local repo..."
+ system("cd " << Dir.new(File.dirname(__FILE__)).path << " && git pull")
+end
+
+desc 'Calls pull task and then install task'
+task :update => ['pull', 'install'] do
+ puts "Update of vim script complete."
+end
+
+task :default => ['update']
@@ -0,0 +1,25 @@
+#!/usr/bin/env ruby
+
+target = File.expand_path(ARGV.first)
+
+if RUBY_PLATFORM =~ /win32/i
+ js_cmd = 'cscript'
+ runjslint_ext = 'wsf'
+ plugin_path = File.join(ENV['HOME'], 'vimfiles')
+else
+ if ENV['JS_CMD']
+ js_cmd = ENV['JS_CMD']
+ else
+ js_cmd = 'js'
+ end
+ runjslint_ext = 'js'
+ plugin_path = File.join(ENV['HOME'], '.vim')
+end
+
+Dir.chdir(File.join(plugin_path, 'ftplugin', 'javascript', 'jslint')) do |dir|
+ IO.popen("#{js_cmd} runjslint.#{runjslint_ext}", 'r+') do |jslint|
+ jslint.write(File.open(target, 'r') { |f| f.read })
+ jslint.close_write
+ $stdout.write(jslint.read)
+ end
+end
Oops, something went wrong.

0 comments on commit 932913f

Please sign in to comment.