Skip to content

Commit b136a92

Browse files
committed
fix: add TypeScript types and improve git hooks
- Export Kit and Tool types from lib/content - Add explicit type annotations to all map/filter/find callbacks - Remove commitlint job from CI (already in pre-commit hook) - Add typecheck to pre-commit hook to catch type errors earlier - Fixes implicit 'any' TypeScript errors
1 parent 852d669 commit b136a92

File tree

8 files changed

+32
-57
lines changed

8 files changed

+32
-57
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -75,30 +75,3 @@ jobs:
7575

7676
- name: Build project
7777
run: pnpm build
78-
79-
commitlint:
80-
name: Commitlint
81-
runs-on: ubuntu-latest
82-
if: github.event_name == 'pull_request'
83-
steps:
84-
- uses: actions/checkout@v4
85-
with:
86-
fetch-depth: 0
87-
88-
- name: Setup pnpm
89-
uses: pnpm/action-setup@v4
90-
with:
91-
version: 9
92-
93-
- name: Setup Node.js
94-
uses: actions/setup-node@v4
95-
with:
96-
node-version: 20
97-
cache: 'pnpm'
98-
99-
- name: Install dependencies
100-
run: pnpm install --frozen-lockfile
101-
102-
- name: Validate PR commits
103-
run: pnpm commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.sha }} --verbose
104-

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/sh
22
pnpm lint-staged
3+
pnpm typecheck
34

app/kits/[slug]/page.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { MDXContent } from "@/components/mdx-content";
1010
import { Badge } from "@/components/ui/badge";
1111
import { Button } from "@/components/ui/button";
1212
import { Separator } from "@/components/ui/separator";
13-
import { kits } from "@/lib/content";
13+
import { type Kit, kits } from "@/lib/content";
1414

1515
interface KitPageProps {
1616
params: Promise<{
@@ -19,14 +19,14 @@ interface KitPageProps {
1919
}
2020

2121
export async function generateStaticParams() {
22-
return kits.map((kit) => ({
22+
return kits.map((kit: Kit) => ({
2323
slug: kit.slug,
2424
}));
2525
}
2626

2727
export async function generateMetadata(props: KitPageProps) {
2828
const params = await props.params;
29-
const kit = kits.find((k) => k.slug === params.slug);
29+
const kit = kits.find((k: Kit) => k.slug === params.slug);
3030

3131
if (!kit) {
3232
return {
@@ -42,7 +42,7 @@ export async function generateMetadata(props: KitPageProps) {
4242

4343
export default async function KitPage(props: KitPageProps) {
4444
const params = await props.params;
45-
const kit = kits.find((k) => k.slug === params.slug);
45+
const kit = kits.find((k: Kit) => k.slug === params.slug);
4646

4747
if (!kit) {
4848
notFound();

app/kits/page.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@
33
import { useState } from "react";
44
import { KitCard } from "@/components/kit-card";
55
import { Button } from "@/components/ui/button";
6-
import { kits } from "@/lib/content";
6+
import { type Kit, kits } from "@/lib/content";
77

88
type StatusFilter = "all" | "stable" | "experimental" | "deprecated";
99

1010
export default function KitsPage() {
1111
const [filter, setFilter] = useState<StatusFilter>("all");
1212

13-
const sortedKits = kits.sort((a, b) => {
13+
const sortedKits = kits.sort((a: Kit, b: Kit) => {
1414
if (a.order !== b.order) return a.order - b.order;
1515
return a.title.localeCompare(b.title);
1616
});
1717

1818
const filteredKits =
1919
filter === "all"
2020
? sortedKits
21-
: sortedKits.filter((kit) => kit.status === filter);
21+
: sortedKits.filter((kit: Kit) => kit.status === filter);
2222

2323
const counts = {
2424
all: kits.length,
25-
stable: kits.filter((k) => k.status === "stable").length,
26-
experimental: kits.filter((k) => k.status === "experimental").length,
27-
deprecated: kits.filter((k) => k.status === "deprecated").length,
25+
stable: kits.filter((k: Kit) => k.status === "stable").length,
26+
experimental: kits.filter((k: Kit) => k.status === "experimental").length,
27+
deprecated: kits.filter((k: Kit) => k.status === "deprecated").length,
2828
};
2929

3030
return (
@@ -80,7 +80,7 @@ export default function KitsPage() {
8080
</div>
8181

8282
<div className="grid gap-3 sm:gap-4 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 min-w-0">
83-
{filteredKits.map((kit) => (
83+
{filteredKits.map((kit: Kit) => (
8484
<KitCard key={kit.slug} kit={kit} />
8585
))}
8686
</div>

app/page.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@ import { KitCard } from "@/components/kit-card";
44
import { ToolCard } from "@/components/tool-card";
55
import { Button } from "@/components/ui/button";
66
import { Separator } from "@/components/ui/separator";
7-
import { kits, tools } from "@/lib/content";
7+
import { type Kit, kits, type Tool, tools } from "@/lib/content";
88

99
export default function Home() {
10-
const sortedKits = kits.sort((a, b) => {
10+
const sortedKits = kits.sort((a: Kit, b: Kit) => {
1111
if (a.order !== b.order) return a.order - b.order;
1212
return a.title.localeCompare(b.title);
1313
});
1414

15-
const sortedTools = tools.sort((a, b) => {
15+
const sortedTools = tools.sort((a: Tool, b: Tool) => {
1616
if (a.order !== b.order) return a.order - b.order;
1717
return a.title.localeCompare(b.title);
1818
});
1919

20-
const featuredKits = sortedKits.filter((kit) => kit.featured);
21-
const featuredTools = sortedTools.filter((tool) => tool.featured);
20+
const featuredKits = sortedKits.filter((kit: Kit) => kit.featured);
21+
const featuredTools = sortedTools.filter((tool: Tool) => tool.featured);
2222
const hasFeatured = featuredKits.length > 0 || featuredTools.length > 0;
2323

2424
// Filter out featured items from regular sections
25-
const regularKits = sortedKits.filter((kit) => !kit.featured);
26-
const regularTools = sortedTools.filter((tool) => !tool.featured);
25+
const regularKits = sortedKits.filter((kit: Kit) => !kit.featured);
26+
const regularTools = sortedTools.filter((tool: Tool) => !tool.featured);
2727

2828
return (
2929
<div className="container px-4 sm:px-6 py-8 md:py-12 lg:py-16 max-w-full">

app/tools/[slug]/page.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { MDXContent } from "@/components/mdx-content";
1111
import { Badge } from "@/components/ui/badge";
1212
import { Button } from "@/components/ui/button";
1313
import { Separator } from "@/components/ui/separator";
14-
import { kits, tools } from "@/lib/content";
14+
import { type Kit, kits, type Tool, tools } from "@/lib/content";
1515

1616
interface ToolPageProps {
1717
params: Promise<{
@@ -20,14 +20,14 @@ interface ToolPageProps {
2020
}
2121

2222
export async function generateStaticParams() {
23-
return tools.map((tool) => ({
23+
return tools.map((tool: Tool) => ({
2424
slug: tool.slug,
2525
}));
2626
}
2727

2828
export async function generateMetadata(props: ToolPageProps) {
2929
const params = await props.params;
30-
const tool = tools.find((t) => t.slug === params.slug);
30+
const tool = tools.find((t: Tool) => t.slug === params.slug);
3131

3232
if (!tool) {
3333
return {
@@ -43,7 +43,7 @@ export async function generateMetadata(props: ToolPageProps) {
4343

4444
export default async function ToolPage(props: ToolPageProps) {
4545
const params = await props.params;
46-
const tool = tools.find((t) => t.slug === params.slug);
46+
const tool = tools.find((t: Tool) => t.slug === params.slug);
4747

4848
if (!tool) {
4949
notFound();
@@ -58,7 +58,7 @@ export default async function ToolPage(props: ToolPageProps) {
5858

5959
// Get kit details for builtOn
6060
const builtOnKits = tool.builtOn
61-
.map((slug: string) => kits.find((k) => k.slug === slug))
61+
.map((slug: string) => kits.find((k: Kit) => k.slug === slug))
6262
.filter(Boolean);
6363

6464
return (

app/tools/page.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@
33
import { useState } from "react";
44
import { ToolCard } from "@/components/tool-card";
55
import { Button } from "@/components/ui/button";
6-
import { tools } from "@/lib/content";
6+
import { type Tool, tools } from "@/lib/content";
77

88
type StatusFilter = "all" | "stable" | "experimental" | "deprecated";
99

1010
export default function ToolsPage() {
1111
const [filter, setFilter] = useState<StatusFilter>("all");
1212

13-
const sortedTools = tools.sort((a, b) => {
13+
const sortedTools = tools.sort((a: Tool, b: Tool) => {
1414
if (a.order !== b.order) return a.order - b.order;
1515
return a.title.localeCompare(b.title);
1616
});
1717

1818
const filteredTools =
1919
filter === "all"
2020
? sortedTools
21-
: sortedTools.filter((tool) => tool.status === filter);
21+
: sortedTools.filter((tool: Tool) => tool.status === filter);
2222

2323
const counts = {
2424
all: tools.length,
25-
stable: tools.filter((t) => t.status === "stable").length,
26-
experimental: tools.filter((t) => t.status === "experimental").length,
27-
deprecated: tools.filter((t) => t.status === "deprecated").length,
25+
stable: tools.filter((t: Tool) => t.status === "stable").length,
26+
experimental: tools.filter((t: Tool) => t.status === "experimental").length,
27+
deprecated: tools.filter((t: Tool) => t.status === "deprecated").length,
2828
};
2929

3030
return (
@@ -80,7 +80,7 @@ export default function ToolsPage() {
8080
</div>
8181

8282
<div className="grid gap-3 sm:gap-4 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 min-w-0">
83-
{filteredTools.map((tool) => (
83+
{filteredTools.map((tool: Tool) => (
8484
<ToolCard key={tool.slug} tool={tool} />
8585
))}
8686
</div>

lib/content.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
import { kits, tools } from "../.velite";
44

55
export { kits, tools };
6+
export type { Kit, Tool } from "../.velite";

0 commit comments

Comments
 (0)