Skip to content

Commit 15324f7

Browse files
authored
(chore): add husky pre-commit hook to format only staged files with prettier (#58)
* (chore): add husky pre-commit with lint-staged * (chore): update project dependecy - add prettier * (feat): run prettier only on files staged for commit * (chore): update prettier config file
1 parent 9ebaf6b commit 15324f7

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx lint-staged

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./dist

.prettierrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 2,
4+
"printWidth": 120,
5+
"semi": true,
6+
"singleQuote": true,
7+
"useTabs": false,
8+
"quoteProps": "as-needed",
9+
"jsxSingleQuote": false,
10+
"bracketSpacing": true,
11+
"jsxBracketSameLine": true,
12+
"arrowParens": "avoid",
13+
"requirePragma": false,
14+
"insertPragma": false,
15+
"proseWrap": "preserve",
16+
"endOfLine": "lf"
17+
}

package.json

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,25 @@
77
"types": "lib/index.d.ts",
88
"scripts": {
99
"lint": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx .",
10+
"pretty-quick": "pretty-quick",
1011
"lint:fix": "yarn lint --fix",
1112
"test": "jest",
1213
"storybook": "start-storybook -p 6006",
1314
"build-storybook": "build-storybook -c .storybook -o .out",
1415
"build": "rollup -c",
15-
"prepublishOnly": "yarn build"
16+
"prepublishOnly": "yarn build",
17+
"prepare": "husky install"
1618
},
1719
"files": [
1820
"src",
1921
"lib"
2022
],
23+
"lint-staged": {
24+
"*": [
25+
"npm run pretty-quick",
26+
"npm run lint"
27+
]
28+
},
2129
"np": {
2230
"publish": false,
2331
"tests": false
@@ -49,9 +57,11 @@
4957
"eslint-plugin-react": "^7.31.8",
5058
"eslint-plugin-react-hooks": "^4.6.0",
5159
"framer-motion": "^7.5.1",
60+
"husky": "^8.0.0",
5261
"jest": "^29.1.2",
5362
"jest-environment-jsdom": "^29.1.2",
5463
"postcss": "^8.2.1",
64+
"prettier": "^2.8.8",
5565
"react": "^16.13.0",
5666
"react-dom": "^16.13.0",
5767
"react-uuid": "^1.0.2",
@@ -74,7 +84,10 @@
7484
"@emotion/react": "^11.10.4",
7585
"@emotion/styled": "^11.10.4",
7686
"@mui/material": "^5.10.7",
87+
"clsx": "^1.2.1",
7788
"csstype": "^3.1.1",
78-
"clsx": "^1.2.1"
89+
"husky": "^8.0.3",
90+
"lint-staged": "^13.2.3",
91+
"pretty-quick": "^3.1.3"
7992
}
8093
}

0 commit comments

Comments
 (0)