-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathes-lint.sh
executable file
·48 lines (37 loc) · 1.48 KB
/
es-lint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
echo "=============================================================================="
echo "Script: $(basename "$0")"
echo "This script runs es-lint"
echo "=============================================================================="
# ==============================================================================
# Setup
# ==============================================================================
# Exit immediately if a command exits with a non-zero status.
set -e
# OS settings
if [ "$(uname)" = "Darwin" ]; then
[ -z "$( brew ls --versions findutils )" ] && brew install findutils
[ -z "$( brew ls --versions coreutils )" ] && brew install coreutils
READLINK="greadlink"
XARGS="gxargs"
else
READLINK="readlink"
XARGS="xargs"
fi
SCRIPT_PATH=$( ${READLINK} -f $0 )
SCRIPT_DIR=$( dirname $( ${READLINK} -f $0 ) )
# ==============================================================================
# Inputs
# ==============================================================================
export ESLINT_CONFIG_PATH=${ESLINT_CONFIG_PATH:-".eslintrc"}
export AUTO_FIX=${AUTO_FIX:-true}
# ==============================================================================
# Script
# ==============================================================================
if [ $AUTO_FIX != "true" ]; then unset AUTO_FIX; fi;
# Lint
echo "Linting with eslint"
npx eslint -c ${ESLINT_CONFIG_PATH} ${AUTO_FIX:+--fix} "$@"
# Prettier
echo "Running prettier"
npx prettier --check ${AUTO_FIX:+--write} "$@"