Skip to content

Commit d0522a8

Browse files
committed
chore: add code formatting tools.
1 parent e8b844f commit d0522a8

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

.husky/pre-commit

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

.prettierignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package.json
2+
coverage
3+
dist
4+
build
5+
cjs
6+
esm
7+
8+
.vercel
9+
.husky
10+
.github

.prettierrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"printWidth": 120,
5+
"overrides": [
6+
{
7+
"files": ".prettierrc",
8+
"options": { "parser": "json" }
9+
}
10+
]
11+
}

package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"main": "cjs/index.js",
77
"module": "esm/index.js",
88
"scripts": {
9-
"prepare": "npm run build",
9+
"prepare": "husky install && npm run build",
1010
"released": "npm run build && npm run doc",
1111
"doc": "kkt build --app-src ./website",
1212
"start": "kkt start --app-src ./website",
@@ -17,6 +17,7 @@
1717
"css:build": "compile-less -d src -o esm",
1818
"css:watch": "compile-less -d src -o esm --watch",
1919
"css:build:dist": "compile-less -d src --combine dist.css --rm-global",
20+
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,html,less,md,json}'",
2021
"map": "source-map-explorer build/static/js/*.js --html build/website-result.html"
2122
},
2223
"homepage": "https://uiwjs.github.io/react-code-preview",
@@ -37,6 +38,11 @@
3738
"react-code-preview"
3839
],
3940
"license": "MIT",
41+
"lint-staged": {
42+
"*.{js,jsx,ts,tsx,html,less,md,json}": [
43+
"prettier --write"
44+
]
45+
},
4046
"peerDependencies": {
4147
"react": ">=16.9.0",
4248
"react-dom": ">=16.9.0"
@@ -53,7 +59,10 @@
5359
"@uiw/react-markdown-preview": "3.4.7",
5460
"@uiw/reset.css": "1.0.5",
5561
"compile-less-cli": "1.8.11",
62+
"husky": "7.0.4",
5663
"kkt": "7.0.3",
64+
"lint-staged": "12.1.7",
65+
"prettier": "2.5.1",
5766
"react": "17.0.2",
5867
"react-dom": "17.0.2",
5968
"react-test-renderer": "17.0.2",

0 commit comments

Comments
 (0)