Skip to content
This repository

coffeescript linter with style warnings #118

Closed
wants to merge 1 commit into from

6 participants

Aparajita Fishman Benjamin Arthur Lupton Ethan J. Brown Allen Bargi Trevor Bortins
sjz commented March 15, 2012

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
Owner

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 commented March 15, 2012

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
Owner

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

sjz commented March 15, 2012
Benjamin Arthur Lupton

What's the status of this?

sjz commented July 30, 2012
Ethan J. Brown

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

Allen Bargi

Any update on this one?

sjz referenced this pull request in clutchski/coffeelint September 19, 2012
Closed

bump up npm release #47

Aparajita Fishman
Owner

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 December 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 15, 2012
coffeescript linter based on https://github.com/clutchski/coffeelint 2b5e17c
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 31 additions and 0 deletions. Show diff stats Hide diff stats

  1. 31  sublimelinter/modules/coffeelint.py
31  sublimelinter/modules/coffeelint.py
... ...
@@ -0,0 +1,31 @@
  1
+# -*- coding: utf-8 -*-
  2
+# coffeelint.py - sublimelint package for checking coffee files
  3
+# based on coffeescript.py, inspired by https://github.com/clutchski/coffeelint
  4
+
  5
+import re
  6
+import os
  7
+
  8
+from base_linter import BaseLinter
  9
+
  10
+CONFIG = {
  11
+    'language': 'coffeescript',
  12
+    'executable': 'coffeelint.cmd' if os.name == 'nt' else 'coffeelint',
  13
+    'lint_args': '--stdin'
  14
+}
  15
+
  16
+
  17
+class Linter(BaseLinter):
  18
+    def parse_errors(self, view, errors, lines, errorUnderlines,
  19
+                     violationUnderlines, warningUnderlines, errorMessages,
  20
+                     violationMessages, warningMessages):
  21
+
  22
+        for line in errors.splitlines():
  23
+            match = re.match(r'#(?P<line>\d+) : (?P<type>[a-z]+) : (?P<err>.+)',
  24
+                            line)
  25
+            if match:
  26
+                line, err_text = int(match.group('line')), match.group('err')
  27
+                err_type = match.group('type')
  28
+
  29
+                grp = errorMessages if err_type == 'error' else warningMessages
  30
+
  31
+                self.add_message(line, lines, err_text, grp)
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.