Skip to content

Commit 648916c

Browse files
authored
refactor: replace lint/fmt with unified vp check (#135)
* refactor: replace lint/fmt with unified vp check - Replace separate lint, fmt, fmt:check scripts with unified check/check:fix - Update CI to use single 'vp run check' step instead of separate fmt:check + lint - Update ready script to use check instead of fmt + lint - Upgrade vite-plus to 0.0.0-g61d318d2.20260227-0939 - Fix lint errors caught by new rules: - Wrap SidebarContext value in useMemo to prevent unnecessary rerenders - Use entry.name instead of array index for Cell keys in BundleSizeChart * feat: add husky + lint-staged for pre-commit hooks - Add husky and lint-staged as devDependencies (catalog mode) - Pre-commit hook runs 'vp check --fix' on staged files - Covers all file types via wildcard glob
1 parent fa920f5 commit 648916c

8 files changed

Lines changed: 681 additions & 270 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ jobs:
2828

2929
- run: npx playwright install chromium
3030

31-
- run: vp run fmt:check
31+
- name: Check
32+
run: vp run check
3233

33-
- run: vp run lint --format github
34+
- name: Test
35+
run: vp run test
3436

35-
- run: vp run test
37+
- name: Build
38+
run: vp run @vibe/dashboard#build
3639

37-
- run: vp run @vibe/dashboard#build
38-
39-
- run: vp run ready
40+
- name: Ready
41+
run: vp run ready

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

apps/dashboard/src/components/rolldown/BundleSizeChart.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ export function BundleSizeChart() {
8888
}}
8989
style={{ fontSize: "11px", fill: "#94a3b8" }}
9090
/>
91-
{bundleSizeDiffData.map((entry: any, index: number) => (
91+
{bundleSizeDiffData.map((entry: any) => (
9292
<Cell
93-
key={`cell-${index}`}
93+
key={`cell-${entry.name}`}
9494
fill={entry.isBaseline ? "#94a3b8" : entry.value >= 0 ? "#dc2626" : "#16a34a"}
9595
/>
9696
))}

apps/dashboard/src/context/SidebarContext.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createContext, useContext, useState } from "react";
1+
import { createContext, useContext, useMemo, useState } from "react";
22

33
interface SidebarContextType {
44
collapsed: boolean;
@@ -9,12 +9,9 @@ const SidebarContext = createContext<SidebarContextType | undefined>(undefined);
99

1010
export function SidebarProvider({ children }: { children: React.ReactNode }) {
1111
const [collapsed, setCollapsed] = useState(false);
12+
const value = useMemo(() => ({ collapsed, setCollapsed }), [collapsed]);
1213

13-
return (
14-
<SidebarContext.Provider value={{ collapsed, setCollapsed }}>
15-
{children}
16-
</SidebarContext.Provider>
17-
);
14+
return <SidebarContext.Provider value={value}>{children}</SidebarContext.Provider>;
1815
}
1916

2017
export function useSidebar() {

data/rolldown-version-stats.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,4 +889,4 @@
889889
"totalSize": 720281,
890890
"buildTime": 917
891891
}
892-
]
892+
]

package.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,25 @@
55
"description": "A frontend dashboard for displaying different metrics",
66
"type": "module",
77
"scripts": {
8-
"ready": "vite run fmt && vite run lint && vite run test && vite run build",
8+
"ready": "vite run check && vite run test && vite run build",
99
"dev": "vite run @vibe/dashboard#dev",
1010
"build": "vite run @vibe/dashboard#build",
11-
"lint": "vite lint --deny-warnings --type-aware --type-check",
11+
"check": "vp check",
12+
"check:fix": "vp check --fix",
1213
"test": "vite test",
13-
"fmt": "vite fmt",
14-
"fmt:check": "vite fmt --check",
1514
"cache:clean": "vite cache clean",
16-
"generate": "node tools/override-rolldown.mjs --stats"
15+
"generate": "node tools/override-rolldown.mjs --stats",
16+
"prepare": "husky"
1717
},
1818
"devDependencies": {
19+
"husky": "catalog:",
20+
"lint-staged": "catalog:",
1921
"playwright": "catalog:",
2022
"top-github-dependents-by-stars": "catalog:",
2123
"vite-plus": "catalog:"
2224
},
25+
"lint-staged": {
26+
"*": "vp check --fix"
27+
},
2328
"packageManager": "pnpm@10.26.0"
2429
}

pnpm-lock.yaml

Lines changed: 653 additions & 249 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ catalog:
1919
semver: ^7.7.2
2020
tailwindcss: ^4.1.13
2121
top-github-dependents-by-stars: ^1.0.4
22+
husky: ^9.1.7
23+
lint-staged: ^16.2.7
2224
typescript: ^5.9.2
2325
vite: npm:@voidzero-dev/vite-plus-core@latest
24-
vite-plus: 0.0.0-ffb4d08a8edafe855c59736c0a38ee85a2373ebb
26+
vite-plus: 0.0.0-g61d318d2.20260227-0939
2527
vitest: npm:@voidzero-dev/vite-plus-test@latest
2628

2729
minimumReleaseAge: 1440

0 commit comments

Comments
 (0)