Skip to content

Commit

Permalink
Merge pull request #276 from SleeplessByte/chore/eslint-make-qol
Browse files Browse the repository at this point in the history
ESLint, cross-env make, run all tests in 2 minutes (instead of 20)
  • Loading branch information
masters3d authored Aug 16, 2019
2 parents efae60f + 406b3b9 commit 6382524
Show file tree
Hide file tree
Showing 764 changed files with 290,494 additions and 142,890 deletions.
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,20 @@ node_modules
build
babel-output
lintreport.json

# These should be placed in common or maintaining. Only have them in the root
# to make editor plugins work.
/.eslintignore
/.eslintrc
/tsconfig.json

# These are artifacts from running make test. They should be removed by make.
# The correct location for these files is the maintaining folder.
/exercises/package.json
/exercises/tsconfig.json
/exercises/.eslint.track.rc
/exercises/.eslintrc
/exercises/.eslintignore
/exercises/yarn.lock
/exercises/node_modules
exercises/yarn-error.log
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "node"
- "lts/*"

cache: yarn

Expand All @@ -12,11 +12,12 @@ before_install:

before_script:
- npm install -g yarn
- node -v
- yarn -v
- ruby -v

script:
- bin/fetch-configlet
- bin/configlet lint .
- make test

after_success:
- make report
- danger
40 changes: 25 additions & 15 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'pathname';

# Ensure a clean commits history
if git.commits.any? { |c| c.message =~ /^Merge branch '#{github.branch_for_base}'/ }
fail('Please rebase to get rid of the merge commits in this PR')
warn('Please rebase to get rid of the merge commits in this PR, otherwise, if this PR is small, this should be squash-merged so the merge commit is squashed.')
end
can_merge = github.pr_json["mergeable"]
is_merged = github.pr_json["merged"]
Expand All @@ -17,27 +19,35 @@ warn("PR is classed as Work in Progress") if github.pr_title.include? "[WIP]"
# Warn when there is a big PR
warn("Big PR") if git.lines_of_code > 500

#ENSURE THERE IS A SUMMARY FOR A PR
# Ensure there is a summary
warn("Please provide a summary in the Pull Request description. See more info <a href=\"http\://tinyletter.com/exercism/letters/exercism-pull-requests\">here.</a>") if github.pr_body.length < 5

# LINT Comments in for each Line
jsonpath = "lintreport.json"
contents = File.read jsonpath
require "json"
if contents.to_s == ''
contents = "[]"
contents = "[]"
end
json = JSON.parse contents

json.each do |object|
shortFile = object["name"]
shortFile = shortFile.to_s || ''
msg = object["failure"].to_s || ''
line = object["endPosition"]["line"] || 1
#only warn for files that were edited in this PR.
if git.modified_files.include? shortFile
shortFile.prepend("/") # get away from doing inline comments since they are buggy as of Sep-2016
warn(msg, file: shortFile, line: line)
else
message(msg, file: shortFile, line: line)
end
end
# TODO: use env path so it works everwhere
source_file = Pathname.new(object["filePath"])
.relative_path_from(Pathname.new('/home/travis/build/exercism/typescript/')).to_s;

(object["messages"] || []).each do |message|
danger_message = "#{message["message"].to_s} (#{message["ruleId"].to_s})"
source_line = message["line"]

# only warn for files that were edited in this PR.
if git.modified_files.include? source_file
# get away from doing inline comments since they are buggy as of Sep-2016
shortFile.prepend("/") unless source_file[0] == '/'

warn(danger_message, file: source_file, line: source_line)
else
message(danger_message, file: source_file, line: source_line)
end
end
end
Loading

0 comments on commit 6382524

Please sign in to comment.