This repository has been archived by the owner on Jul 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1585 from YaleSTC/1581_install_eslint
[1581] Remove Hound, add ESLint
- Loading branch information
Showing
7 changed files
with
117 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
extends: standard | ||
installedESLint: true | ||
plugins: | ||
- standard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,6 @@ diff.py | |
Vagrantfile | ||
*.sublime* | ||
coverage/ | ||
.env | ||
.env | ||
node_modules/* | ||
*.swp |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# frozen_string_literal: true | ||
|
||
RUBY = /\.(rb)|(rake)$/ | ||
JS = /\.jsx?$/ | ||
RUBY_PASS = %w(true no\ offenses files\ found).freeze | ||
JS_PASS = %w(true files\ found).freeze | ||
|
||
EXISTING_FILES = /^[^D].*/ | ||
FILE = /^[A-Z]\t(.*)$/ | ||
|
||
desc 'Style checks files that differ from master' | ||
task :check_style do | ||
puts diff_output | ||
puts "\nRunning rubocop..." | ||
puts check_ruby | ||
puts "\nRunning eslint..." | ||
puts check_js | ||
exit evaluate | ||
end | ||
|
||
def diff_output | ||
"Files found in the diff:\n#{diff.join("\n")}\n" | ||
end | ||
|
||
def check(type:, regex:, checker:) | ||
files = files_that_match regex | ||
return "No #{type} files found!" if files.empty? | ||
"#{send(checker, files)}\n#{system send(checker, files)}\n" | ||
end | ||
|
||
def check_ruby | ||
@ruby_results ||= check(type: 'ruby', regex: RUBY, checker: :rubocop) | ||
end | ||
|
||
def check_js | ||
@js_results ||= check(type: 'javascript', regex: JS, checker: :eslint) | ||
end | ||
|
||
def evaluate | ||
return 0 if passed? | ||
1 | ||
end | ||
|
||
def passed? | ||
RUBY_PASS.any? { |m| check_ruby.include? m } && | ||
JS_PASS.any? { |m| check_js.include? m } | ||
end | ||
|
||
def rubocop(files) | ||
"rubocop -D --force-exclusion #{files}" | ||
end | ||
|
||
def eslint(files) | ||
"npm run lint #{files}" | ||
end | ||
|
||
def diff | ||
@diff ||= process_diff | ||
end | ||
|
||
def process_diff | ||
all = `git diff master --name-status` | ||
existing_files = all.split("\n").grep(EXISTING_FILES) | ||
existing_files.map { |f| FILE.match(f)[1] } | ||
end | ||
|
||
def files_that_match(regex) | ||
diff.grep(regex).join(' ') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "reservations", | ||
"version": "6.2.0", | ||
"description": "[![Build Status](https://travis-ci.org/YaleSTC/reservations.svg?branch=master)](https://travis-ci.org/YaleSTC/reservations) [![Code Climate](https://codeclimate.com/github/YaleSTC/reservations/badges/gpa.svg)](https://codeclimate.com/github/YaleSTC/reservations) [![Test Coverage](https://codeclimate.com/github/YaleSTC/reservations/badges/coverage.svg)](https://codeclimate.com/github/YaleSTC/reservations) [![Dependency Status](https://gemnasium.com/YaleSTC/reservations.svg)](https://gemnasium.com/YaleSTC/reservations) [![Inline docs](http://inch-ci.org/github/yalestc/reservations.svg?branch=master&style=flat)](http://inch-ci.org/github/yalestc/reservations)", | ||
"main": "index.js", | ||
"directories": { | ||
"doc": "doc", | ||
"test": "test" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"lint": "node_modules/.bin/eslint" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+ssh://git@github.com/YaleSTC/reservations.git" | ||
}, | ||
"author": "", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/YaleSTC/reservations/issues" | ||
}, | ||
"homepage": "https://github.com/YaleSTC/reservations#readme", | ||
"devDependencies": { | ||
"eslint": "^2.12.0", | ||
"eslint-config-standard": "^5.3.1", | ||
"eslint-plugin-standard": "^1.3.2" | ||
}, | ||
"dependencies": { | ||
"eslint-plugin-promise": "^1.3.2" | ||
} | ||
} |