Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
jswartwood committed May 13, 2012
2 parents feb129e + ea10fac commit d4bbef6
Show file tree
Hide file tree
Showing 12 changed files with 147 additions and 30 deletions.
8 changes: 4 additions & 4 deletions Default.sublime-commands
Expand Up @@ -10,22 +10,22 @@
"args": {"action": "lint", "show_popup": true}
},
{
"caption": "SublimeLinter: Enable Background Linting",
"caption": "SublimeLinter: Background Linting",
"command": "sublimelinter_lint",
"args": {"action": "on"}
},
{
"caption": "SublimeLinter: Enable Load-Save Linting",
"caption": "SublimeLinter: Load-Save Linting",
"command": "sublimelinter_enable_load_save",
"args": {"action": "load-save"}
},
{
"caption": "SublimeLinter: Enable Save-Only Linting",
"caption": "SublimeLinter: Save-Only Linting",
"command": "sublimelinter_enable_save_only",
"args": {"action": "save-only"}
},
{
"caption": "SublimeLinter: Disable Background Linting",
"caption": "SublimeLinter: Disable Linting",
"command": "sublimelinter_disable",
"args": {"action": "off"}
},
Expand Down
23 changes: 13 additions & 10 deletions README.md
Expand Up @@ -8,15 +8,15 @@ can be quickly located.

SublimeLinter has built in linters for the following languages:

* CoffeeScript - lint via `coffee.cmd -l`
* CoffeeScript - lint via `coffee -s -l`
* CSS - lint via built-in [csslint](http://csslint.net)
* java - lint via `javac -Xlint`
* Java - lint via `javac -Xlint`
* Javascript - lint via built in [jshint](http://jshint.org), [jslint](http://jslint.com), or the [closure linter (gjslint)](https://developers.google.com/closure/utilities/docs/linter_howto) (if installed)
* Objective-J - lint via built-in [capp_lint](https://github.com/aparajita/capp_lint)
* perl - lint via [Perl:Critic](http://perlcritic.com/) or syntax+deprecation checking via `perl -c`
* php - syntax checking via `php -l`
* python - native, moderately-complete lint
* ruby - syntax checking via `ruby -wc`
* Perl - lint via [Perl:Critic](http://perlcritic.com/) or syntax+deprecation checking via `perl -c`
* PHP - syntax checking via `php -l`
* Python - native, moderately-complete lint
* Ruby - syntax checking via `ruby -wc`


Installing
Expand Down Expand Up @@ -59,10 +59,10 @@ Within a file whose language/syntax is supported by SublimeLinter, you can contr

* **SublimeLinter: Lint Current File** - Lints the current file, highlights any errors and displays how many errors were found.
* **SublimeLinter: Show Error List** - Lints the current file, highlights any errors and displays a quick panel with any errors that are found. Selecting an item from the quick panel jumps to that line.
* **SublimeLinter: Enable Background Linting** - Enables background linting mode for the current view and lints it.
* **SublimeLinter: Disable Background Linting** - Disables background linting mode for the current view and clears all lint errors.
* **SublimeLinter: Enable Load-Save Linting** - Enables load-save linting mode for the current view and clears all lint errors.
* **SublimeLinter: Enable Save-Only Linting** - Enables save-only linting mode for the current view and clears all lint errors.
* **SublimeLinter: Background Linting** - Enables background linting mode for the current view and lints it.
* **SublimeLinter: Disable Linting** - Disables linting mode for the current view and clears all lint errors.
* **SublimeLinter: Load-Save Linting** - Enables load-save linting mode for the current view and clears all lint errors.
* **SublimeLinter: Save-Only Linting** - Enables save-only linting mode for the current view and clears all lint errors.
* **SublimeLinter: Reset** - Clears all lint errors and sets the linting mode to the value in the SublimeLinter.sublime-settings file.

Depending on the file and the current state of background enabling, some of the commands will not be available.
Expand Down Expand Up @@ -106,6 +106,8 @@ Following are notes specific to individual linters that you should be aware of:

You may want to modify the options passed to jshint, jslint, or gjslint. This can be done by using the **jshint_options**, **jslint_options**, or **gjslint_options** setting. Refer to the jshint.org site, the jslint.com site, or run `gjslint --help` for more information on the configuration options available.

SublimeLinter supports `.jshintrc` files. If using JSHint, SublimeLinter will recursively search the directory tree (from the file location to the file-system root directory). This functionality is specified in the [JSHint README](https://github.com/jshint/node-jshint/#within-your-projects-directory-tree).

* **CSS** - This linter runs [csslint](http://csslint.net). This linter requires a Javascript engine (like Node.js) to be installed (see notes above for the JavaScript linters: "jshint" or "jslint").

By default all CSSLint settings are turned on. You may customize CSSLint behavior with the "csslint_options" setting. Please select `Preferences->Package Settings->SublimeLinter->Settings - Default` for more information on turning off or adjusting severity of tests. For more information about options available to CSSLint, see https://github.com/stubbornella/csslint/wiki/Rules.
Expand Down Expand Up @@ -168,6 +170,7 @@ For example, let's say we are editing a Java project and want to use the "java"
}
}

The jshint follows convention set by node-jshint (though node is not required) and will attempt to locate the configuration file for you starting in pwd. (or "present working directory") If this does not yield a .jshintrc file, it will move one level up (..) the directory tree all the way up to the filesystem root. If a file is found, it stops immediately and uses that set of configuration instead of "jshint_options".

### Customizing colors
**IMPORTANT** - The theme style names have recently changed. The old and new color
Expand Down
10 changes: 8 additions & 2 deletions SublimeLinter.py
Expand Up @@ -252,7 +252,7 @@ def erase_lint_marks(view):

def get_lint_regions(view, reverse=False, coalesce=False):
vid = view.id()
underlines = UNDERLINES[vid][:]
underlines = UNDERLINES.get(vid, [])[:]

if (coalesce):
# Each of these regions is one character, so transform it into the character points
Expand Down Expand Up @@ -723,6 +723,12 @@ def is_enabled(self):
return select_linter(self.view) is not None

def find_lint_error(self, forward):
linter = select_linter(self.view, ignore_disabled=True)

if not linter:
return

self.view.run_command('lint', linter.language)
regions = get_lint_regions(self.view, reverse=not forward, coalesce=True)

if len(regions) == 0:
Expand Down Expand Up @@ -909,7 +915,7 @@ def is_enabled(self):
if enabled:
view = self.window.active_view()

if view and not view.settings().get('sublimelinter') == True:
if view and view.settings().get('sublimelinter') == False:
return False

return enabled
27 changes: 27 additions & 0 deletions changelog.txt
Expand Up @@ -222,3 +222,30 @@ Due to a vulnerability (issue #77) with the Perl linter, Perl syntax checking is
enabled by default. The default linter for Perl has been replaced by Perl::Critic.


SublimeLinter 1.6.3 changelog
=============================
NEW FEATURES

- Support for `.jshintrc` files. If using JSHint, SublimeLinter
will recursively search the directory tree (from the file location
to the file-system root directory). This functionality is
specified in the JSHint README.
https://github.com/jshint/node-jshint/#within-your-projects-directory-tree


CHANGES/FIXES

- Fixed README reference in the menu.

- Updated CoffeeScript module to be compatible with the updated
coffee command in version 1.3.


IMPORTANT

If you are using the CoffeeScript linting, please upgrade
the installed coffee-script NPM module to 1.3 or greater.

npm update -g coffee-script


3 changes: 2 additions & 1 deletion messages.json
Expand Up @@ -9,5 +9,6 @@
"1.5.7": "messages/1.5.7.txt",
"1.6.0": "messages/1.6.0.txt",
"1.6.1": "messages/1.6.1.txt",
"1.6.2": "messages/1.6.2.txt"
"1.6.2": "messages/1.6.2.txt",
"1.6.3": "messages/1.6.3.txt"
}
26 changes: 26 additions & 0 deletions messages/1.6.3.txt
@@ -0,0 +1,26 @@
SublimeLinter 1.6.3 changelog

NEW FEATURES

- Support for `.jshintrc` files. If using JSHint, SublimeLinter
will recursively search the directory tree (from the file location
to the file-system root directory). This functionality is
specified in the JSHint README.
https://github.com/jshint/node-jshint/#within-your-projects-directory-tree


CHANGES/FIXES

- Fixed README reference in the menu.

- Updated CoffeeScript module to be compatible with the updated
coffee command in version 1.3.


IMPORTANT

If you are using the CoffeeScript linting, please upgrade
the installed coffee-script NPM module to 1.3 or greater.

npm update -g coffee-script

14 changes: 8 additions & 6 deletions messages/install.txt
Expand Up @@ -8,13 +8,15 @@ can be quickly located.

SublimeLinter has built in linters for the following languages:

* Javascript - lint via built in `jshint <http://jshint.org>`_ or the `closure linter (gjslint) <https://developers.google.com/closure/utilities/docs/linter_howto>`_ (if installed)
* Objective-J - lint via built-in `capp_lint <https://github.com/aparajita/capp_lint>`_
* CoffeeScript - lint via `coffee -s -l`
* CSS - lint via built-in [csslint](http://csslint.net)
* java - lint via `javac -Xlint`
* Javascript - lint via built in [jshint](http://jshint.org), [jslint](http://jslint.com), or the [closure linter (gjslint)](https://developers.google.com/closure/utilities/docs/linter_howto) (if installed)
* Objective-J - lint via built-in [capp_lint](https://github.com/aparajita/capp_lint)
* perl - lint via [Perl:Critic](http://perlcritic.com/) or syntax+deprecation checking via `perl -c`
* php - syntax checking via `php -l`
* python - native, moderately-complete lint
* ruby - syntax checking via "ruby -wc"
* php - syntax checking via "php -l"
* java - lint via "javac -Xlint"
* perl - syntax+deprecation checking via "perl -c"
* ruby - syntax checking via `ruby -wc`


For more information:
Expand Down
6 changes: 3 additions & 3 deletions package_control.json
Expand Up @@ -6,12 +6,12 @@
"description": "Inline lint highlighting for the Sublime Text 2 editor",
"author": "Kronuz, Aparajita Fishman, Jake Swartwood",
"homepage": "http://github.com/Kronuz/SublimeLinter",
"last_modified": "2012-04-16 15:49:15",
"last_modified": "2012-05-13 14:01:15",
"platforms": {
"*": [
{
"version": "1.6.2",
"url": "https://nodeload.github.com/Kronuz/SublimeLinter/zipball/v1.6.2"
"version": "1.6.3",
"url": "https://nodeload.github.com/Kronuz/SublimeLinter/zipball/v1.6.3"
}
]
}
Expand Down
45 changes: 44 additions & 1 deletion sublimelinter/modules/base_linter.py
Expand Up @@ -67,6 +67,9 @@

TEMPFILES_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '.tempfiles'))

JSON_MULTILINE_COMMENT_RE = re.compile(r'\/\*[\s\S]*?\*\/')
JSON_SINGLELINE_COMMENT_RE = re.compile(r'\/\/[^\n\r]*')

if not os.path.exists(TEMPFILES_DIR):
os.mkdir(TEMPFILES_DIR)

Expand Down Expand Up @@ -321,9 +324,43 @@ def jsc_path(self):
has to be dynamically calculated in the future.'''
return self.JSC_PATH

def find_file(self, filename, view):
'''Find a file with the given name, starting in the view's directory,
then ascending the file hierarchy up to root.'''
path = view.file_name()

# quit if the view is temporary
if not path:
return None

dirname = os.path.dirname(path)

while True:
path = os.path.join(dirname, filename)

if os.path.isfile(path):
with open(path, 'r') as f:
return f.read()

# if we hit root, quit
parent = os.path.dirname(dirname)

if parent == dirname:
return None
else:
dirname = parent

def strip_json_comments(self, json_str):
stripped_json = JSON_MULTILINE_COMMENT_RE.sub('', json_str)
stripped_json = JSON_SINGLELINE_COMMENT_RE.sub('', stripped_json)
return json.dumps(json.loads(stripped_json))

def get_javascript_args(self, view, linter, code):
path = os.path.join(self.LIB_PATH, linter)
options = json.dumps(view.settings().get('%s_options' % linter) or {})
options = self.get_javascript_options(view)

if options == None:
options = json.dumps(view.settings().get('%s_options' % linter) or {})

self.get_javascript_engine(view)
engine = self.js_engine
Expand All @@ -335,6 +372,12 @@ def get_javascript_args(self, view, linter, code):

return args

def get_javascript_options(self, view):
'''Subclasses should override this if they want to provide options
for a Javascript-based linter. If the subclass cannot provide
options, it should return None (or not return anything).'''
return None

def get_javascript_engine(self, view):
if self.js_engine == None:
for engine in self.JAVASCRIPT_ENGINES:
Expand Down
7 changes: 4 additions & 3 deletions sublimelinter/modules/coffeescript.py
Expand Up @@ -9,19 +9,20 @@
CONFIG = {
'language': 'coffeescript',
'executable': 'coffee.cmd' if os.name == 'nt' else 'coffee',
'lint_args': '-l'
'lint_args': ['-s', '-l']
}


class Linter(BaseLinter):
def parse_errors(self, view, errors, lines, errorUnderlines,
violationUnderlines, warningUnderlines, errorMessages,
violationMessages, warningMessages):

for line in errors.splitlines():
match = re.match(r'.*?Error: In .+?, Parse error on line '
match = re.match(r'.*?Error: Parse error on line '
r'(?P<line>\d+): (?P<error>.+)', line)
if not match:
match = re.match(r'.*?Error: In .+?, (?P<error>.+) '
match = re.match(r'.*?Error: (?P<error>.+) '
r'on line (?P<line>\d+)', line)

if match:
Expand Down
8 changes: 8 additions & 0 deletions sublimelinter/modules/javascript.py
Expand Up @@ -47,6 +47,14 @@ def get_lint_args(self, view, code, filename):
else:
return []

def get_javascript_options(self, view):
if self.linter == 'jshint':
rc_options = self.find_file('.jshintrc', view)

if rc_options != None:
rc_options = self.strip_json_comments(rc_options)
return json.dumps(json.loads(rc_options))

def parse_errors(self, view, errors, lines, errorUnderlines, violationUnderlines, warningUnderlines, errorMessages, violationMessages, warningMessages):
if (self.linter == 'gjslint'):
ignore = view.settings().get('gjslint_ignore', [])
Expand Down
Empty file modified sublimelinter/modules/libs/capp_lint.py 100755 → 100644
Empty file.

0 comments on commit d4bbef6

Please sign in to comment.