Skip to content
This repository has been archived by the owner on Sep 25, 2020. It is now read-only.

Commit

Permalink
Added (currently defunct) rhino support
Browse files Browse the repository at this point in the history
  • Loading branch information
passy authored and MSch committed Aug 2, 2010
1 parent bc119cb commit 99834ee
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ Credits
- 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
- Pascal Hartig -- Support for running jslint with rhino


License
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require 'find'
require 'pathname'

PLUGIN = [
<<<<<<< HEAD
"ftplugin/javascript/jslint.vim",
"ftplugin/javascript/jslint/fulljslint.js",
"ftplugin/javascript/jslint/runjslint.js",
Expand Down
7 changes: 6 additions & 1 deletion bin/jslint
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ if RUBY_PLATFORM =~ /win32/i
runjslint_ext = 'wsf'
plugin_path = File.join(ENV['HOME'], 'vimfiles')
else
if RUBY_PLATFORM =~ /linux/
runjslint_ext = 'rhino.js'
else
runjslint_ext = 'js'
end

js_cmd = 'js'
runjslint_ext = 'js'
plugin_path = File.join(ENV['HOME'], '.vim')
end

Expand Down
35 changes: 35 additions & 0 deletions ftplugin/javascript/jslint.rhino.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*global JSLINT load readline print */

load('fulljslint.js');
importPackage(java.io);
importPackage(java.lang);

function readSTDIN() {
// setup the input buffer and output buffer
var stdin = new BufferedReader(new InputStreamReader(System['in'])),
lines = [];

// read stdin buffer until EOF (or skip)
while (stdin.ready()){
lines.push(stdin.readLine());
}

return lines.join('\n');
}

var body = readSTDIN() || arguments[0],
ok = JSLINT(body),
i,
error,
errorCount;

if (!ok) {
errorCount = JSLINT.errors.length;
for (i = 0; i < errorCount; i += 1) {
error = JSLINT.errors[i];
if (error && error.reason && error.reason.match(/^Stopping/) === null) {
print([error.line, error.character, error.reason].join(":"));
}
}
}

2 changes: 2 additions & 0 deletions ftplugin/javascript/jslint.vim
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ else
elseif executable('js')
let s:cmd = 'js'
let s:runjslint_ext = 'js'
" TODO: If js is not spidermonkey but Rhino we are screwed. Need a way to
" find out what we're dealing with.
else
echoerr('No JS interpreter found. Checked for jsc, js (spidermonkey)')
endif
Expand Down

0 comments on commit 99834ee

Please sign in to comment.