#!/bin/sh

set -e

if ! bundle exec rubocop -D -c .rubocop.yml --fail-fast
then
  echo 'rubocop detected issues!'
  bundle exec rubocop -A -D -c .rubocop.yml
  echo 'Tried to auto correct the issues, but must be reviewed manually, commit aborted'
  exit 1
fi

bundle exec brakeman -q -z --no-summary --no-pager
bundle exec mdl ./ -g

# for scss
yarn run stylelint "./app/assets/stylesheets/**/*.scss"

# for erb
bundle exec erb_lint --config .erb-lint.yml --lint-all

# for typescript
tslint -c tslint.json app/javascripts/**/*.ts

# for coffeescript
coffeelint -f .coffeelint.json app/javascripts/**/*.coffee

# for javascript
yarn eslint app/javascripts spec/javascripts
