mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 13:59:25 +00:00
Configure lint-staged
This commit is contained in:
@@ -1,32 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
cd "$(git rev-parse --show-toplevel)"
|
. "$(dirname "$0")/_/husky.sh"
|
||||||
ESLINT="node_modules/.bin/eslint"
|
|
||||||
pwd
|
|
||||||
|
|
||||||
if [[ ! -x "$ESLINT" ]]; then
|
npx lint-staged
|
||||||
printf "\t\033[41mPlease install ESlint\033[0m (npm i --save-dev eslint)\n"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
STAGED_FILES=($(git diff --cached --name-only --diff-filter=ACM | grep "\.js$"))
|
|
||||||
|
|
||||||
echo "Linting ${#STAGED_FILES[@]} files"
|
|
||||||
|
|
||||||
if [[ "$STAGED_FILES" = "" ]]; then
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
$ESLINT "${STAGED_FILES[@]}"
|
|
||||||
|
|
||||||
ESLINT_EXIT="$?"
|
|
||||||
|
|
||||||
#ESLINT_EXIT=0
|
|
||||||
|
|
||||||
if [[ "${ESLINT_EXIT}" == 0 ]]; then
|
|
||||||
printf "\n\033[42mCOMMIT SUCCEEDED\033[0m\n"
|
|
||||||
else
|
|
||||||
printf "\n\033[41mCOMMIT FAILED:\033[0m Fix eslint errors and try again\n"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit $?
|
|
||||||
|
|||||||
3
.lintstagedrc.json
Normal file
3
.lintstagedrc.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"*.js": "eslint --fix"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user