Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Jolley committed Dec 8, 2011
0 parents commit 1a44d5a
Show file tree
Hide file tree
Showing 16 changed files with 692 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
*.pyc
node_modules

12 changes: 12 additions & 0 deletions Default (Linux).sublime-keymap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"keys": ["ctrl+j"],
"__doc__": "Run JSLint",
"command": "jslint"
},
{
"keys": ["shift+ctrl+j"],
"__doc__": "Hide JSLint Viewer",
"command": "hide_jslint_result"
}
]
12 changes: 12 additions & 0 deletions Default (OSX).sublime-keymap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"keys": ["ctrl+j"],
"__doc__": "Run JSLint",
"command": "jslint"
},
{
"keys": ["shift+ctrl+j"],
"__doc__": "Hide JSLint Viewer",
"command": "hide_jslint_result"
}
]
12 changes: 12 additions & 0 deletions Default (Windows).sublime-keymap
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"keys": ["ctrl+j"],
"__doc__": "Run JSLint",
"command": "jslint"
},
{
"keys": ["shift+ctrl+j"],
"__doc__": "Hide JSLint Viewer",
"command": "hide_jslint_result"
}
]
28 changes: 28 additions & 0 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[
{
"caption": "Bolt: Run JSLint",
"command": "jslint"
},
{
"caption": "Bolt: Show JSLint Result",
"command": "show_jslint_result"
},
{
"caption": "Bolt: Hide JSLint Result",
"command": "hide_jslint_result"
},
{
"caption": "Preferences: Bolt Settings – Default",
"command": "open_file", "args":
{
"file": "${packages}/sublime-bolt/sublime-bolt.sublime-settings"
}
},
{
"caption": "Preferences: Bolt Settings – User",
"command": "open_file", "args":
{
"file": "${packages}/User/sublime-bolt.sublime-settings"
}
}
]
26 changes: 26 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
New BSD License

Copyright (c) 2011, Robin Zhong <fbzhong@gmail.com>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Robin Zhong nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66 changes: 66 additions & 0 deletions Main.sublime-menu
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[
{
"id": "tools",
"children":
[
{
"caption": "Bolt",
"id": "bolt",
"children":
[
{
"caption": "Run JSLint",
"command": "jslint"
},
{
"caption": "Show JSLint Result",
"command": "show_jslint_result"
},
{
"caption": "Hide JSLint Result",
"command": "hide_jslint_result"
},
{
"caption": "Toggle Autolint",
"command": "toggle_js_autolint"
}
]
}
]
},
{
"id": "preferences",
"children":
[
{
"caption": "Package Settings",
"id": "package-settings",
"children":
[
{
"caption": "Bolt",
"children":
[
{
"caption": "Settings – Default",
"command": "open_file",
"args":
{
"file": "${packages}/sublime-bolt/sublime-bolt.sublime-settings"
}
},
{
"caption": "Settings – User",
"command": "open_file",
"args":
{
"file": "${packages}/User/sublime-bolt.sublime-settings"
}
}
]
}
]
}
]
}
]
102 changes: 102 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
JSLint support for Sublime Text 2 by using jslint4java
========================

Sublime Text 2 (http://www.sublimetext.com/2) is a sophisticated text editor for code, html and prose. You'll love the slick user interface and extraordinary features.

JSLint4Java (http://code.google.com/p/jslint4java/) is a java wrapper around the fabulous tool by Douglas Crockford, [jslint](http://jslint.com). It provides a simple interface for detecting potential problems in JavaScript code.

This project provide a plugin to add JSLint support for Sublime Text 2.

Features
-------------

- JSLint: Run JSLint (ctrl+j)

- JSLint: Show JSLint Result

- Highlight error line by click on the result view

- Cross platform: support Windows, Linux and Mac OS X

Requirements
-------------

- java, and make sure java has been added to PATH

Installation
-------------

- Using Package Control http://wbond.net/sublime_packages/package_control
> Add Repository: https://github.com/fbzhong/sublime-jslint
- Download and extract to Sublime Text 2 Packages folder
> Windows: %APPDATA%\Sublime Text 2\Packages
> Mac OS X: ~/Library/Application Support/Sublime Text 2/Packages
> Linux: ~/.config/sublime-text-2/Packages
How to use?
-------------

- Using the Command Palette (Windows and Linux: Ctrl+Shift+P, OSX: Command+Shift+P) then search for:

- JSLint: Run JSLint (ctrl+j)
- JSLint: Show JSLint Result

Open up a .js file and hit ctrl+j to run JSLint. An new output panel will appear giving you the JSLint results:

Screenshots
-------------

![](https://github.com/fbzhong/sublime-jslint/raw/master/images/screenshot.png)

Settings
-------------

Settings can be opened via the Command Palette, or the Preferences > Package Settings > JSLint > Settings – User menu entry.

{
// Path to the jslint jar.
// Leave blank to use bundled jar.
"jslint_jar": "",

// Options pass to jslint.
"jslint_options": "",

// Ignore errors, regex.
"ignore_errors":
[
// "Expected an identifier and instead saw 'undefined' \(a reserved word\)"
],

// debug flag.
"debug": false
}

New BSD License
-------------

Copyright (c) 2011, Robin Zhong <fbzhong@gmail.com>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Robin Zhong nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48 changes: 48 additions & 0 deletions asyncprocess.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import os
import thread
import subprocess
import functools
import time
import sublime

class AsyncProcess(object):
def __init__(self, cmd, listener):
self.cmd = cmd
self.listener = listener
#print "DEBUG_EXEC: " + str(self.cmd)
self.proc = subprocess.Popen([self.cmd], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

if self.proc.stdout:
thread.start_new_thread(self.read_stdout, ())

if self.proc.stderr:
thread.start_new_thread(self.read_stderr, ())

thread.start_new_thread(self.poll, ())

def poll(self):
while True:
if self.proc.poll() != None:
sublime.set_timeout(functools.partial(self.listener.proc_terminated, self.proc), 0)
break
time.sleep(0.1)

def read_stdout(self):
while True:
data = os.read(self.proc.stdout.fileno(), 2**15)
if data != "":
sublime.set_timeout(functools.partial(self.listener.append_data, self.proc, data), 0)
else:
self.proc.stdout.close()
self.listener.is_running = False
break

def read_stderr(self):
while True:
data = os.read(self.proc.stderr.fileno(), 2**15)
if data != "":
sublime.set_timeout(functools.partial(self.listener.append_data, self.proc, data), 0)
else:
self.proc.stderr.close()
self.listener.is_running = False
break
Binary file added images/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1a44d5a

Please sign in to comment.