Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #7 from trentm/issue6

issue #6: allow spaces around jsl control comments
  • Loading branch information...
commit 5693fd3ce6f31f66f85bfde275ab64e609ea04d0 2 parents f09d42f + 5ba7c37
David Pacheco authored February 16, 2012

Showing 1 changed file with 8 additions and 7 deletions. Show diff stats Hide diff stats

  1. 15  javascriptlint/lint.py
15  javascriptlint/lint.py
@@ -18,7 +18,7 @@
18 18
     'eof', 'comma', 'dot', 'semi', 'colon', 'lc', 'rc', 'lp', 'rb', 'assign',
19 19
     'relop', 'hook', 'plus', 'minus', 'star', 'divop', 'eqop', 'shop', 'or',
20 20
     'and', 'bitor', 'bitxor', 'bitand', 'else', 'try'
21  
-) 
  21
+)
22 22
 
23 23
 _globals = frozenset([
24 24
     'Array', 'Boolean', 'Math', 'Number', 'String', 'RegExp', 'Script', 'Date',
@@ -26,7 +26,7 @@
26 26
     'eval', 'NaN', 'Infinity',
27 27
     'escape', 'unescape', 'uneval',
28 28
     'decodeURI', 'encodeURI', 'decodeURIComponent', 'encodeURIComponent',
29  
-    'Function', 'Object', 
  29
+    'Function', 'Object',
30 30
     'Error', 'InternalError', 'EvalError', 'RangeError', 'ReferenceError',
31 31
     'SyntaxError', 'TypeError', 'URIError',
32 32
     'arguments', 'undefined'
@@ -47,10 +47,12 @@ def _find_functions(node):
47 47
 
48 48
 def _parse_control_comment(comment):
49 49
     """ Returns None or (keyword, parms) """
50  
-    if comment.atom.lower().startswith('jsl:'):
51  
-        control_comment = comment.atom[4:]
52  
-    elif comment.atom.startswith('@') and comment.atom.endswith('@'):
53  
-        control_comment = comment.atom[1:-1]
  50
+    atom = comment.atom.strip()
  51
+    atom_lower = atom.lower()
  52
+    if atom_lower.startswith('jsl:'):
  53
+        control_comment = atom[4:]
  54
+    elif atom.startswith('@') and atom.endswith('@'):
  55
+        control_comment = atom[1:-1]
54 56
     else:
55 57
         return None
56 58
 
@@ -709,4 +711,3 @@ def parsetag(starttag, default_version=None):
709 711
         script = parsetag('<script type="" language="mocha">',
710 712
                               util.JSVersion('1.2', False))
711 713
         self.assertEquals(script['jsversion'], util.JSVersion.default())
712  
-

0 notes on commit 5693fd3

Please sign in to comment.
Something went wrong with that request. Please try again.