1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-01 11:29:25 +00:00

Configure lint-staged

This commit is contained in:
2022-04-19 01:04:55 +00:00
parent 48b78fc51b
commit 14d24b084f
2 changed files with 6 additions and 31 deletions

View File

@@ -1,32 +1,4 @@
#!/bin/bash
cd "$(git rev-parse --show-toplevel)"
ESLINT="node_modules/.bin/eslint"
pwd
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
if [[ ! -x "$ESLINT" ]]; then
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 $?
npx lint-staged

3
.lintstagedrc.json Normal file
View File

@@ -0,0 +1,3 @@
{
"*.js": "eslint --fix"
}