Commit 4ce42d5 1 parent 90d76ae commit 4ce42d5 Copy full SHA for 4ce42d5
File tree 3 files changed +53
-1
lines changed
3 files changed +53
-1
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ cp ./.pre-commit ./.git/hooks/pre-commit
4
+ exit 0
Original file line number Diff line number Diff line change
1
+ #! /bin/zsh
2
+
3
+ # function lintit () {
4
+ # OUTPUT=$(git diff --name-only | grep -E '(.js|.jsx)$')
5
+ # a=("${(f)OUTPUT}")
6
+ # e=$(npm run eslint $a)
7
+ # echo $e
8
+ # if [[ "$e" != *"0 errors"* ] || [ "$e" != *"0 errors"* ]]; then
9
+ # echo "ERROR: Check eslint hints."
10
+ # exit 1 # reject
11
+ # fi
12
+ # }
13
+ # lintit
14
+ # exit 0
15
+
16
+ STAGED_FILES=$( git diff --cached --name-only --diff-filter=ACM | grep " .jsx\{0,1\}$" )
17
+
18
+ if [[ " $STAGED_FILES " = " " ]]; then
19
+ exit 0
20
+ fi
21
+
22
+ PASS=true
23
+
24
+ echo " \nValidating Javascript:\n"
25
+
26
+
27
+ for FILE in $STAGED_FILES
28
+ do
29
+ npm run eslint " $FILE "
30
+
31
+ if [[ " $? " == 0 ]]; then
32
+ echo " \t\033[32mESLint Passed: $FILE \033[0m"
33
+ else
34
+ echo " \t\033[41mESLint Failed: $FILE \033[0m"
35
+ PASS=false
36
+ fi
37
+ done
38
+
39
+ echo " \nJavascript validation completed!\n"
40
+
41
+ if ! $PASS ; then
42
+ echo " \033[41mCOMMIT FAILED:\033[0m Your commit contains files that should pass ESLint but do not. Please fix the ESLint errors and try again.\n"
43
+ exit 1
44
+ else
45
+ echo " \033[42mCOMMIT SUCCEEDED\033[0m\n"
46
+ fi
47
+
48
+ exit $?
Original file line number Diff line number Diff line change 3
3
"version" : " 5.2.0" ,
4
4
"private" : true ,
5
5
"scripts" : {
6
- "postinstall" : " remotedev-debugger" ,
6
+ "postinstall" : " remotedev-debugger && sh .add-pre-commit-hook " ,
7
7
"start" : " node_modules/react-native/packager/packager.sh" ,
8
8
"eslint" : " eslint"
9
9
},
You can’t perform that action at this time.
0 commit comments