Skip to content

Commit

Permalink
Merge pull request #189 from markstory/eslint-extensions
Browse files Browse the repository at this point in the history
Pull in some changes from #179
  • Loading branch information
markstory authored Mar 8, 2018
2 parents 7ff09d3 + 6265e2c commit e4a827c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
6 changes: 3 additions & 3 deletions docker/Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source 'https://rubygems.org'

gem 'rubocop'
gem 'puppet-lint'
gem 'foodcritic'
gem 'rubocop', '~>0.49'
gem 'puppet-lint', '~>2.2'
gem 'foodcritic', '~>12.0'
2 changes: 1 addition & 1 deletion docker/ruby2.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:2.5-alpine
FROM ruby:2.4-alpine

RUN mkdir /src \
&& mkdir /tool \
Expand Down
4 changes: 3 additions & 1 deletion lintreview/tools/eslint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import os
import re
from lintreview.config import comma_value
from lintreview.review import IssueComment
from lintreview.tools import Tool, process_checkstyle
import lintreview.docker as docker
Expand All @@ -23,7 +24,8 @@ def match_file(self, filename):
"""
base = os.path.basename(filename)
name, ext = os.path.splitext(base)
return ext == '.js' or ext == '.jsx'
extensions = comma_value(self.options.get('extensions', '.js,.jsx'))
return ext in extensions

def has_fixer(self):
"""Eslint has a fixer that can be enabled
Expand Down
9 changes: 5 additions & 4 deletions settings.sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def env(key, default=None, cast=str):
# gunicorn config
bind = env('LINTREVIEW_GUNICORN_BIND', '127.0.0.1:5000')
errorlog = env('LINTREVIEW_GUNICORN_LOG_ERROR',
'lintreview.error.log')
'lintreview.error.log')
accesslog = env('LINTREVIEW_GUNICORN_LOG_ACCESS',
'lintreview.access.log')
'lintreview.access.log')
debug = env('LINTREVIEW_GUNICORN_DEBUG', True, bool)
loglevel = env('LINTREVIEW_GUNICORN_LOGLEVEL', 'debug')

Expand Down Expand Up @@ -87,8 +87,9 @@ def env(key, default=None, cast=str):
SUMMARY_THRESHOLD = env('LINTREVIEW_SUMMARY_THRESHOLD', 50, int)

# Used as the author information when making commits
GITHUB_AUTHOR_NAME = 'lintreview'
GITHUB_AUTHOR_EMAIL = '[email protected]'
GITHUB_AUTHOR_NAME = env('LINTREVIEW_GITHUB_AUTHOR_NAME', 'lintreview')
GITHUB_AUTHOR_EMAIL = env('LINTREVIEW_GITHUB_AUTHOR_EMAIL',
'[email protected]')

# Status Configuration
######################
Expand Down
10 changes: 10 additions & 0 deletions tests/tools/test_eslint.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ def test_match_file(self):
self.assertTrue(self.tool.match_file('test.jsx'))
self.assertTrue(self.tool.match_file('dir/name/test.js'))

def test_match_file__extensions(self):
options = {
'extensions': '.js,.jsm'
}
tool = Eslint(self.problems, options)
self.assertFalse(tool.match_file('test.php'))
self.assertFalse(tool.match_file('test.jsx'))
self.assertTrue(tool.match_file('test.js'))
self.assertTrue(tool.match_file('test.jsm'))

@requires_image('nodejs')
def test_check_dependencies(self):
self.assertTrue(self.tool.check_dependencies())
Expand Down

0 comments on commit e4a827c

Please sign in to comment.