Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .changeset/plugin-kit-oxfmt-0-71.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sanity/plugin-kit': patch
---

Update the optional `oxfmt` peer dependency to ^0.71.0
5 changes: 5 additions & 0 deletions .changeset/plugin-kit-oxfmt-changeset-quotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sanity/plugin-kit': patch
---

The `@sanity/plugin-kit/oxfmt` preset no longer formats `.changeset/*.md` files with double quotes, so their frontmatter gets single quotes like the rest of your code. Changesets 3 formats the changesets it writes with oxfmt when it finds your `oxfmt.config.ts`, or when `.changeset/config.json` sets `"format": "oxfmt"`, so they come out the same way.
1 change: 0 additions & 1 deletion .husky/pre-commit

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"js/ts.experimental.useTsgo": true,
"oxc.fmt.configPath": ".oxfmtrc.json",
"oxc.fmt.configPath": "oxfmt.config.ts",
"oxc.typeAware": true
}
10 changes: 10 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,16 @@ pnpm format

The formatter settings live in the shared `@sanity/plugin-kit/oxfmt` preset (`packages/@sanity/plugin-kit/src/oxfmt.ts`), which the root `oxfmt.config.ts` extends with workspace-specific `ignorePatterns` (for example `turbo/**/*.hbs`). Standalone plugins scaffolded with `plugin-kit init` reuse the same preset. Note that loading the TypeScript config requires Node `^20.19 || >=22.18`.

The oxfmt version, options and ignore patterns match sanity-io/ui's `.oxfmtrc.json`, so keep them in sync. The exceptions are `turbo/**/*.hbs`, which only exists here, and ui's `**/sanity.types.ts`: `pnpm typegen` formats `dev/test-studio/sanity.types.ts` on purpose, since the test studio runs typegen with `formatGeneratedCode: false`. `.vscode/settings.json` points the Oxc extension at `oxfmt.config.ts`; if `oxc.fmt.configPath` names a missing file, the editor silently formats with oxfmt's defaults instead.

Changesets are formatted like any other file, so their frontmatter uses single quotes, and Changesets formats the changesets it writes with oxfmt. Renovate's changeset action writes double quotes, so after a Renovate PR merges, the Auto format workflow opens a `chore(format): 🤖 ✨` PR that requotes it, as in sanity-io/ui.

A lefthook pre-commit hook (`lefthook.yml`, set up like sanity-io/sanity's) runs oxfmt on the staged files and re-stages them. `pnpm install` installs the hook through lefthook's own install script, which `allowBuilds` in `pnpm-workspace.yaml` permits and which skips when `CI` is set. Skip the hook once with `LEFTHOOK=0 git commit`.

- **Clones that ran husky:** they still have `core.hooksPath` set to `.husky/_`, and lefthook won't install there. Run `git config --unset core.hooksPath && pnpm install` once.
- **Hook commands:** they call `node_modules/.bin/oxfmt` directly. `pnpm <bin>` in a hook runs pnpm 12's implicit install, which flips the peer toggle described under pnpm Version.
- **Local scripts:** `pnpm --config.verify-deps-before-run=false <script>` avoids that implicit install too.

### Linting

We use [oxlint](https://oxc.rs/docs/linter.html) for all linting (type-aware, includes TypeScript type checking and [React Compiler rules](https://oxc.rs/blog/2026-08-18-react-compiler-support.html)):
Expand Down
14 changes: 14 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Call node_modules/.bin binaries directly: `pnpm <bin>` runs pnpm 12's implicit install,
# which flips the optional-peer toggle in pnpm-lock.yaml that AGENTS.md describes.
pre-commit:
parallel: true
jobs:
- name: format-scripts
glob: '*.{js,jsx,ts,tsx,mjs,cjs,mts,cts}'
stage_fixed: true
run: node_modules/.bin/oxfmt --no-error-on-unmatched-pattern {staged_files}

- name: format-other
glob: '*.{md,yml,yaml,css,json,jsonc}'
stage_fixed: true
run: node_modules/.bin/oxfmt --no-error-on-unmatched-pattern {staged_files}
7 changes: 6 additions & 1 deletion oxfmt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@ import {defineConfig} from 'oxfmt'
// only workspace-specific ignore patterns belong here.
export default defineConfig({
...pluginKitOxfmt,
ignorePatterns: [...(pluginKitOxfmt.ignorePatterns ?? []), 'turbo/**/*.hbs'],
ignorePatterns: [
...(pluginKitOxfmt.ignorePatterns ?? []),
'storybook-static/**',
'CHANGELOG.md',
'turbo/**/*.hbs',
],
})
9 changes: 1 addition & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"lint:workflows": "if command -v zizmor >/dev/null 2>&1; then zizmor .github --min-severity high; else echo 'zizmor not found. Install it: https://docs.zizmor.sh/installation/'; exit 1; fi",
"oxlint": "oxlint --disable-nested-config",
"postgenerate": "pnpm install && pnpm format && pnpm build",
"postinstall": "husky",
"pregenerate": "turbo run build --filter='./turbo/generators'",
"pretest": "turbo run build --filter='!./dev/*'",
"release": "changeset publish",
Expand All @@ -39,8 +38,6 @@
},
"dependencies": {
"@sanity/plugin-kit": "workspace:*",
"husky": "^9.1.7",
"lint-staged": "^16.4.0",
"oxfmt": "catalog:",
"oxlint": "catalog:",
"oxlint-tsgolint": "catalog:",
Expand All @@ -56,12 +53,8 @@
"@vitest/coverage-v8": "catalog:",
"eslint-plugin-storybook": "^10.6.0",
"knip": "^6.33.0",
"lefthook": "^2.1.14",
"vercel": "^60.1.3"
},
"lint-staged": {
"*.{ts,tsx,js,jsx,json,jsonc,md}": [
"oxfmt --no-error-on-unmatched-pattern"
]
},
"packageManager": "pnpm@12.6.0"
}
6 changes: 0 additions & 6 deletions packages/@sanity/plugin-kit/src/oxfmt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ const config: OxfmtConfig = {
sortImports: true,
sortPackageJson: {sortScripts: true},
ignorePatterns: ['dist/**', 'pnpm-lock.yaml'],
overrides: [
{
files: ['.changeset/*.md'],
options: {singleQuote: false},
},
],
}

export default config
Loading
Loading