Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

coffeescript linter with style warnings #118

Closed
wants to merge 1 commit into from

6 participants

sjz Aparajita Fishman Benjamin Lupton Ethan J. Brown Allen Bargi Trevor Bortins
sjz

Additional coffeescript linter based on coffeelint

Didn't want to modify the existing coffeescript.py as it shows compile errors pretty nicely whereas coffeelint is more for style

NB the --stdin lint arg is awaiting this

Aparajita Fishman

Cool, thanks for taking the time to do it. However I won't merge it until you merge this with the existing coffeescript.py and add a "coffeescript_linter" setting which determines which linter to use, otherwise there is no easy way for the user to decide which linter to use for coffeescript syntax.

In addition, it would be nice to create some new commands listed in Default.sublime-commands that would lint the current view using coffescript or coffeelint. You would only enable those commands if the current syntax is CoffeeScript.

sjz

Will do. Apologies for the hackishness of the merge - was being a bit overly pragmatic as my main focus was on developing the coffeescript code that this was being tested on. This extension was just a happy side product.

Just thought: It might be useful to have the option to have multiple linters per language (which I had earlier assumed without checking the code). In the case of coffeescript there's a fairly distinct difference between the two linters, and they could be quite complementary if used together.

Aparajita Fishman

Multiple linters could be useful, true. Make a ticket for the idea, maybe someone will implement it.

Benjamin Lupton

What's the status of this?

sjz
Ethan J. Brown

+1 on implementing this.. would def like to see coffeelint support in addition to coffee -l -s

Jacob Swartwood jswartwood referenced this pull request
Closed

Add CoffeeLint support #226

Allen Bargi

Any update on this one?

Trevor Bortins

+1!

Aparajita Fishman

SublimeLinter 3 has landed, should be available on Package Control soon, along with a coffeelint linter and support for multiple linters.

Aparajita Fishman aparajita closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 31 additions and 0 deletions.
  1. +31 −0 sublimelinter/modules/coffeelint.py
31 sublimelinter/modules/coffeelint.py
View
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+# coffeelint.py - sublimelint package for checking coffee files
+# based on coffeescript.py, inspired by https://github.com/clutchski/coffeelint
+
+import re
+import os
+
+from base_linter import BaseLinter
+
+CONFIG = {
+ 'language': 'coffeescript',
+ 'executable': 'coffeelint.cmd' if os.name == 'nt' else 'coffeelint',
+ 'lint_args': '--stdin'
+}
+
+
+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'#(?P<line>\d+) : (?P<type>[a-z]+) : (?P<err>.+)',
+ line)
+ if match:
+ line, err_text = int(match.group('line')), match.group('err')
+ err_type = match.group('type')
+
+ grp = errorMessages if err_type == 'error' else warningMessages
+
+ self.add_message(line, lines, err_text, grp)
Something went wrong with that request. Please try again.