Skip to content

Commit

Permalink
chore: improve prettier setup (#169)
Browse files Browse the repository at this point in the history
- We now use the shared `@sanity/prettier-config`
- All files are formatted
- Astro files as well
  • Loading branch information
christianhg authored May 22, 2024
1 parent ed086ff commit 29970fa
Show file tree
Hide file tree
Showing 14 changed files with 256 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
pull_request:
types: [closed]
schedule:
- cron: '0 0 * * *'
- cron: "0 0 * * *"
workflow_dispatch:

permissions:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
author: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
body: I ran `npm run format` 🧑‍💻
branch: actions/prettier
commit-message: 'chore(prettier): 🤖 ✨'
commit-message: "chore(prettier): 🤖 ✨"
labels: 🤖 bot
title: 'chore(prettier): 🤖 ✨'
title: "chore(prettier): 🤖 ✨"
token: ${{ steps.generate-token.outputs.token }}
2 changes: 1 addition & 1 deletion .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
with:
cache: npm
node-version: lts/*
registry-url: 'https://registry.npmjs.org'
registry-url: "https://registry.npmjs.org"
- run: corepack enable && npm --version && npm ci --ignore-scripts && npm audit signatures
if: ${{ steps.release.outputs.releases_created }}
# Release Please has already incremented versions and published tags, so we just
Expand Down
9 changes: 9 additions & 0 deletions .prettierer.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const preset = require("@sanity/prettier-config");

/** @type {import("prettier").Config} */
const config = {
...preset,
plugins: [...preset.plugins, "prettier-plugin-astro"],
};

module.exports = config;
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist
CHANGELOG.md
16 changes: 8 additions & 8 deletions apps/example-ssr/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import sanity from '@sanity/astro'
import { defineConfig } from 'astro/config'
import vercel from '@astrojs/vercel/serverless';
import react from '@astrojs/react';
import sanity from "@sanity/astro";
import { defineConfig } from "astro/config";
import vercel from "@astrojs/vercel/serverless";
import react from "@astrojs/react";

// https://astro.build/config
export default defineConfig({
integrations: [
sanity({
projectId: '3do82whm',
dataset: 'next',
projectId: "3do82whm",
dataset: "next",
// If you are doing static builds you may want opt out of the CDN
useCdn: true,
studioBasePath: "/admin",
}),
react(),
],
output: 'server',
output: "server",
adapter: vercel({
edgeMiddleware: true,
}),
})
});
2 changes: 1 addition & 1 deletion apps/example-ssr/src/components/NewsBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function NewsBar() {
const [news, setNews] = useState({ message: "Loading news…" });
const getNews = useCallback(async () => {
const response = await sanityClient.fetch(
`*[_type == "sanityIoSettings"][0].banner`
`*[_type == "sanityIoSettings"][0].banner`,
);
setNews(response || { message: "no news" });
}, [sanityClient]);
Expand Down
2 changes: 1 addition & 1 deletion apps/example-ssr/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "astro/tsconfigs/strict"
}
}
4 changes: 2 additions & 2 deletions apps/example/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sanity from "@sanity/astro";
import { defineConfig } from "astro/config";
import react from '@astrojs/react';
import react from "@astrojs/react";

// https://astro.build/config
export default defineConfig({
Expand All @@ -12,6 +12,6 @@ export default defineConfig({
useCdn: false,
studioBasePath: "/admin",
}),
react()
react(),
],
});
2 changes: 1 addition & 1 deletion apps/example/src/components/NewsBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function NewsBar() {
const [news, setNews] = useState({ message: "Loading news…" });
const getNews = useCallback(async () => {
const response = await sanityClient.fetch(
`*[_type == "sanityIoSettings"][0].banner`
`*[_type == "sanityIoSettings"][0].banner`,
);
setNews(response || { message: "no news" });
}, [sanityClient]);
Expand Down
2 changes: 1 addition & 1 deletion apps/example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "astro/tsconfigs/strict"
}
}
Loading

0 comments on commit 29970fa

Please sign in to comment.