Skip to content

Commit 80973af

Browse files
authored
feat: add pre commit hooks (#3)
* test pre commit * chore: remove prettify script in favor of pre commit hook
1 parent d05a32d commit 80973af

File tree

4 files changed

+569
-16
lines changed

4 files changed

+569
-16
lines changed

Diff for: package.json

+16-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
"license": "MIT",
88
"scripts": {
99
"build": "tsc",
10-
"lint": "eslint ./src --ext .ts,.js",
10+
"lint": "eslint ./src --ext .ts,.js --fix",
1111
"test": "jest",
1212
"test:watch": "jest --watchAll",
13-
"prettify": "prettier --write ./src/**/*.{ts,js}",
1413
"ts-node": "ts-node",
1514
"nodemon": "nodemon"
1615
},
@@ -31,11 +30,26 @@
3130
"eslint-plugin-jsx-a11y": "^6.2.1",
3231
"eslint-plugin-prettier": "^3.0.1",
3332
"eslint-plugin-react": "^7.12.4",
33+
"husky": "^1.3.1",
3434
"jest": "^24.1.0",
35+
"lint-staged": "^8.1.4",
3536
"nodemon": "^1.18.9",
3637
"prettier": "^1.16.4",
38+
"pretty-quick": "^1.10.0",
3739
"ts-jest": "^23.10.5",
3840
"ts-node": "^8.0.2",
3941
"typescript": "^3.3.1"
42+
},
43+
"husky": {
44+
"hooks": {
45+
"pre-commit": "lint-staged"
46+
}
47+
},
48+
"lint-staged": {
49+
"*.{js,ts}": [
50+
"eslint ./src --ext .ts,.js --fix",
51+
"pretty-quick",
52+
"git add"
53+
]
4054
}
4155
}

Diff for: src/index.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import add from './index';
22

33
test('basic test', () => {
4-
expect(add(2, 4)).toBe(6);
4+
expect(add(2, 4, 6)).toBe(12);
55
});

Diff for: src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export default function add(x: number, y: number): number {
2-
return x + y;
1+
export default function add(x: number, y: number, z: number): number {
2+
return x + y + z;
33
}

0 commit comments

Comments
 (0)