Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/oxfmt-formatting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@vercel/sandbox-mock": patch
"@vercel/sandbox": patch
"sandbox": patch
---

Format all JavaScript and TypeScript sources with [oxfmt](https://oxc.rs/docs/guide/usage/formatter) and enforce `pnpm run format:check` in CI, so pull requests no longer carry whitespace-only churn. No runtime behaviour changes.
34 changes: 34 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Format

on:
push:
branches:
- main
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
format:
name: Check formatting
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
run_install: false

- uses: actions/setup-node@v4
with:
node-version: "24.16.0"
cache: "pnpm"

- run: pnpm install
shell: bash

- name: Check formatting
run: pnpm run format:check
Comment on lines +15 to +34
20 changes: 20 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"printWidth": 80,
"ignorePatterns": [
"**/dist/**",
"**/build/**",
"**/out/**",
"**/.next/**",
"**/.turbo/**",
"**/.vercel/**",
"**/*.json",
"**/*.jsonc",
"**/*.json5",
"**/*.md",
"**/*.mdx",
"**/*.yml",
"**/*.yaml",
"**/*.css"
]
}
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Contributing

## Formatting

JavaScript and TypeScript are formatted with [oxfmt](https://oxc.rs/docs/guide/usage/formatter),
configured in [`.oxfmtrc.json`](./.oxfmtrc.json). JSON and Markdown are still
formatted with Prettier.

- `pnpm run format` formats every JS/TS file in the repo.
- `pnpm run format:check` reports files that are not formatted. CI runs this on
every pull request, so unformatted code fails the build.

A `pre-commit` hook runs oxfmt over staged JS/TS files, so in practice you
rarely need to run either command by hand.

## Running the tests

NOTE: Running the tests creates actual sandboxes.
Expand Down
18 changes: 9 additions & 9 deletions examples/ai-example/components/ui/badge.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { cva, type VariantProps } from "class-variance-authority";

import { cn } from "@/lib/utils"
import { cn } from "@/lib/utils";

const badgeVariants = cva(
"inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
Expand All @@ -22,8 +22,8 @@ const badgeVariants = cva(
defaultVariants: {
variant: "default",
},
}
)
},
);

function Badge({
className,
Expand All @@ -32,15 +32,15 @@ function Badge({
...props
}: React.ComponentProps<"span"> &
VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
const Comp = asChild ? Slot : "span"
const Comp = asChild ? Slot : "span";

return (
<Comp
data-slot="badge"
className={cn(badgeVariants({ variant }), className)}
{...props}
/>
)
);
}

export { Badge, badgeVariants }
export { Badge, badgeVariants };
20 changes: 10 additions & 10 deletions examples/ai-example/components/ui/button.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { cva, type VariantProps } from "class-variance-authority"
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { cva, type VariantProps } from "class-variance-authority";

import { cn } from "@/lib/utils"
import { cn } from "@/lib/utils";

const buttonVariants = cva(
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
Expand Down Expand Up @@ -32,8 +32,8 @@ const buttonVariants = cva(
variant: "default",
size: "default",
},
}
)
},
);

function Button({
className,
Expand All @@ -43,17 +43,17 @@ function Button({
...props
}: React.ComponentProps<"button"> &
VariantProps<typeof buttonVariants> & {
asChild?: boolean
asChild?: boolean;
}) {
const Comp = asChild ? Slot : "button"
const Comp = asChild ? Slot : "button";

return (
<Comp
data-slot="button"
className={cn(buttonVariants({ variant, size, className }))}
{...props}
/>
)
);
}

export { Button, buttonVariants }
export { Button, buttonVariants };
26 changes: 13 additions & 13 deletions examples/ai-example/components/ui/card.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import * as React from "react"
import * as React from "react";

import { cn } from "@/lib/utils"
import { cn } from "@/lib/utils";

function Card({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card"
className={cn(
"bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",
className
className,
)}
{...props}
/>
)
);
}

function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
Expand All @@ -21,11 +21,11 @@ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
data-slot="card-header"
className={cn(
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
className
className,
)}
{...props}
/>
)
);
}

function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
Expand All @@ -35,7 +35,7 @@ function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
className={cn("leading-none font-semibold", className)}
{...props}
/>
)
);
}

function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
Expand All @@ -45,7 +45,7 @@ function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
className={cn("text-muted-foreground text-sm", className)}
{...props}
/>
)
);
}

function CardAction({ className, ...props }: React.ComponentProps<"div">) {
Expand All @@ -54,11 +54,11 @@ function CardAction({ className, ...props }: React.ComponentProps<"div">) {
data-slot="card-action"
className={cn(
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
className
className,
)}
{...props}
/>
)
);
}

function CardContent({ className, ...props }: React.ComponentProps<"div">) {
Expand All @@ -68,7 +68,7 @@ function CardContent({ className, ...props }: React.ComponentProps<"div">) {
className={cn("px-6", className)}
{...props}
/>
)
);
}

function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
Expand All @@ -78,7 +78,7 @@ function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
{...props}
/>
)
);
}

export {
Expand All @@ -89,4 +89,4 @@ export {
CardAction,
CardDescription,
CardContent,
}
};
Loading
Loading