Prevent 'function(' in JS code.

(imported from commit 1f86de8786ec9db10c54c1630da633690990859b)
This commit is contained in:
Steve Howell 2013-07-05 12:53:43 -04:00
parent 249252f700
commit aacb5c3da9
1 changed files with 15 additions and 0 deletions

View File

@ -63,6 +63,17 @@ def check_trailing_whitespace(fn):
failed = True
return failed
def perform_extra_js_checks(fn):
failed = False
for i, line in enumerate(open(fn)):
line = line.strip('\n')
if re.search('[^_]function\(', line):
sys.stdout.write('The keyword "function" should be followed by a space in %s line %s\n' % (fn, i+1))
print line
failed = True
return failed
def check_python_gotchas(fn):
'''
Check for certain Python gotchas that pyflakes doesn't catch.
@ -114,6 +125,10 @@ try:
if check_python_gotchas(fn):
failed = True
for fn in by_lang['.js']:
if perform_extra_js_checks(fn):
failed = True
pyflakes = subprocess.Popen(['pyflakes'] + by_lang['.py'],
stdout = subprocess.PIPE,
stderr = subprocess.PIPE)