Skip to content

Commit 1a983e6

Browse files
cijiugechucsr632
andauthored
chore: use prettier to format code (#82)
* chore: introduce prettier * chore: use husky to run pre-commit format * ci: add format * chore: ignore missing lib * format should ignore copied files * reset workflow Co-authored-by: csr632 <[email protected]>
1 parent 399ba8c commit 1a983e6

File tree

16 files changed

+79
-45
lines changed

16 files changed

+79
-45
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+
pnpm format

.prettierignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
packages/**/node_modules
2+
packages/**/dist
3+
packages/**/lib
4+
packages/playground-temp
5+
6+
packages/react-pages/src/client/jotai/index.js
7+
packages/react-pages/src/client/jotai/utils.js
8+
9+
doc-site/dist
10+
doc-site/node_modules
11+
12+
playground-report

doc-site/pages/_theme.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import { createTheme, defaultSideNavs } from 'vite-pages-theme-doc'
33

4-
import Component404 from "./404";
4+
import Component404 from './404'
55

66
export default createTheme({
77
topNavs: [

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"main": "index.js",
66
"license": "MIT",
77
"scripts": {
8+
"format": "prettier --write ./**/*.{js,ts,tsx}",
89
"ver": "pnpm recursive --filter create-vite-pages --filter vite-plugin-react-pages --filter vite-pages-theme-basic --filter vite-pages-theme-doc exec -- npm version",
910
"ver:p": "npm run ver -- patch",
1011
"ver:mi": "npm run ver -- minor",
@@ -19,7 +20,8 @@
1920
"test-debug": "pnpm test -- --debug",
2021
"build:docs": "pnpm --filter doc-site run ssr-for-deploy",
2122
"postinstall": "node ./scripts/linkBins.js",
22-
"install-test-deps": "playwright install --with-deps chromium"
23+
"install-test-deps": "playwright install --with-deps chromium",
24+
"prepare": "husky install"
2325
},
2426
"devDependencies": {
2527
"@playwright/test": "~1.23.4",
@@ -30,6 +32,8 @@
3032
"cross-env": "^7.0.3",
3133
"execa": "^5.1.1",
3234
"get-port": "^5.1.1",
35+
"husky": "^8.0.1",
36+
"prettier": "^2.7.1",
3337
"sirv": "^2.0.2",
3438
"slash": "^3.0.0",
3539
"typescript": "^4.7.4",

packages/playground/custom-find-pages/vite.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ module.exports = {
2828
runtimeDataPaths[demoPath] = absolute
2929
const staticData = api.getStaticData(pageId)
3030
staticData[demoPath] = await helpers.extractStaticData(file)
31-
if (!staticData.title)
32-
staticData.title = `${componentName} Title`
31+
if (!staticData.title) staticData.title = `${componentName} Title`
3332
}
3433
)
3534

packages/playground/custom-find-pages2/pages/sub-path/index.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
* @sort 2
44
*/
55

6-
import React from 'react'
6+
import React from 'react'
77

8-
const Page = () => {
9-
return (
10-
<div>
11-
<h1>sub-path</h1>
12-
</div>
13-
)
14-
}
15-
16-
export default Page
17-
8+
const Page = () => {
9+
return (
10+
<div>
11+
<h1>sub-path</h1>
12+
</div>
13+
)
14+
}
15+
16+
export default Page

packages/playground/lib-monorepo/packages/demos/vite.demos.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ module.exports = {
2828
runtimeDataPaths[demoPath] = absolute
2929
const staticData = api.getStaticData(pageId)
3030
staticData[demoPath] = await helpers.extractStaticData(file)
31-
if (!staticData.title)
32-
staticData.title = `${componentName} Title`
31+
if (!staticData.title) staticData.title = `${componentName} Title`
3332
}
3433
)
3534

packages/react-pages/client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import type { UseStaticData } from './clientTypes'
1010

1111
// access globalThis['__vite_pages_use_static_data'] lazily
1212
export const useStaticData: UseStaticData = (...params: any[]) => {
13-
const actualUseStaticData = (globalThis as any)['__vite_pages_use_static_data']
13+
const actualUseStaticData = (globalThis as any)[
14+
'__vite_pages_use_static_data'
15+
]
1416
return actualUseStaticData(...params)
1517
}
1618

packages/react-pages/src/client/PageLoader.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ const PageLoader = React.memo(({ routePath }: Props) => {
1212
const loadState = useAppState(routePath)
1313
const dataCache = useContext(dataCacheCtx)
1414

15-
return (
16-
<Theme
17-
loadState={loadState}
18-
loadedData={dataCache}
19-
/>
20-
)
15+
return <Theme loadState={loadState} loadedData={dataCache} />
2116
})
2217

2318
export default PageLoader
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import fs from 'fs-extra';
2-
import * as path from 'path';
1+
import fs from 'fs-extra'
2+
import * as path from 'path'
33

44
export class File {
5-
content: Promise<string> | null = null;
5+
content: Promise<string> | null = null
66

7-
constructor(readonly path: string, readonly base: string) { }
7+
constructor(readonly path: string, readonly base: string) {}
88

99
get relative() {
10-
return path.posix.relative(this.base, this.path);
10+
return path.posix.relative(this.base, this.path)
1111
}
1212

1313
get extname() {
14-
return path.posix.extname(this.path).slice(1);
14+
return path.posix.extname(this.path).slice(1)
1515
}
1616

1717
read() {
18-
return this.content || (this.content = fs.readFile(this.path, 'utf-8'));
18+
return this.content || (this.content = fs.readFile(this.path, 'utf-8'))
1919
}
2020
}

0 commit comments

Comments
 (0)