Clone this gist:
git clone [email protected]:4d778fe21cca5ba2fea152059c58c132.git
Install required dependencies with npm:
npm install
Create a file with a wrong type:
cat <<EOF >bad.js
//@flow
export const sum = (a: number, b:number):number => "" + a + b
EOF
Commit this file and let git trigger the precommit hook
git add -A
git commit -m 'Add bad file
Flow should output a result similar to:
❯ git commit -m 'Add bad file'
husky > npm run -s precommit (node v8.10.0)
❯ Running tasks for *.js
✖ flow focus-check
✖ "flow focus-check" found some errors. Please fix them and try committing again.
Error ------------------------------------------------------------------------------------------------------ bad.js:3:52
Cannot return `"" + a + b` because string [1] is incompatible with number [2].
bad.js:3:52
3| export const sum = (a: number, b:number):number => "" + a + b
^^^^^^^^^^ [1]
References:
bad.js:3:42
3| export const sum = (a: number, b:number):number => "" + a + b
^^^^^^ [2]
Found 1 error
[2018-06-23 20:28:00.710] Checking 1 files
[2018-06-23 20:28:00.717] executable=/private/tmp/flow-focus-check-example/node_modules/flow-bin/flow-osx-v0.75.0/flow
[2018-06-23 20:28:00.717] version=0.75.0
[2018-06-23 20:28:00.717] Parsing
[2018-06-23 20:28:01.847] Building package heap
[2018-06-23 20:28:01.866] Loading libraries
[2018-06-23 20:28:02.648] Resolving dependencies
[2018-06-23 20:28:02.754] to_merge: Focused: 1, Dependents: 0, Dependencies: 0
[2018-06-23 20:28:02.754] Calculating dependencies
[2018-06-23 20:28:02.754] Merging
[2018-06-23 20:28:02.781] Done
[2018-06-23 20:28:02.781] Checked set: Focused: 1, Dependents: 0, Dependencies: 0
husky > pre-commit hook failed (add --no-verify to bypass)