From 6845bcb2088ffc06dbfdb5b3ddf3d39c13251a21 Mon Sep 17 00:00:00 2001 From: Asai Neko Date: Mon, 8 Dec 2025 00:06:01 +0800 Subject: [PATCH] Impl prettier to project - Add prettier json config - Format project with prettier config - Enable prettier in zed project settings Signed-off-by: Asai Neko --- .prettierrc.json | 21 ++++++++++++++++ .yarnrc.yml | 2 +- .zed/settings.json | 2 ++ astro.config.mjs | 58 +++++++++++++++++++++---------------------- package.json | 36 +++++++++++++-------------- src/content.config.ts | 2 +- tsconfig.json | 6 ++--- 7 files changed, 75 insertions(+), 52 deletions(-) create mode 100644 .prettierrc.json diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..1daf706 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,21 @@ +{ + "printWidth": 120, + "tabWidth": 4, + "useTabs": false, + "semi": true, + "singleQuote": true, + "quoteProps": "as-needed", + "jsxSingleQuote": true, + "trailingComma": "all", + "bracketSpacing": true, + "objectWarp": "preserve", + "bracketSameLine": false, + "arrowParens": "always", + "parser": "typescript", + "poseWrap": "preserve", + "htmlWhitespaceSensitivity": "ignore", + "vueIndentScriptAndStyle": false, + "endOfLine": "lf", + "embeddedLanguageFormatting": "auto", + "singleAttributePerLine": false +} diff --git a/.yarnrc.yml b/.yarnrc.yml index 3186f3f..77ebf70 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -1 +1 @@ -nodeLinker: node-modules +nodeLinker: node - modules; diff --git a/.zed/settings.json b/.zed/settings.json index 777a496..33e8b7a 100644 --- a/.zed/settings.json +++ b/.zed/settings.json @@ -4,6 +4,8 @@ // see the documentation: https://zed.dev/docs/configuring-zed#settings-files { + "format_on_save": "on", + "formatter": "prettier", "languages": { "TypeScript": { "language_servers": [ diff --git a/astro.config.mjs b/astro.config.mjs index 9897629..edfe500 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,35 +1,35 @@ // @ts-check -import { defineConfig } from "astro/config"; -import starlight from "@astrojs/starlight"; -import starlightThemeGalaxy from "starlight-theme-galaxy"; +import { defineConfig } from 'astro/config'; +import starlight from '@astrojs/starlight'; +import starlightThemeGalaxy from 'starlight-theme-galaxy'; -import mdx from "@astrojs/mdx"; +import mdx from '@astrojs/mdx'; // https://astro.build/config export default defineConfig({ - integrations: [ - starlight({ - title: "NixCN", - defaultLocale: "root", - locales: { - root: { - label: "简体中文", - lang: "zh-CN", - }, - en: { - label: "English", - }, - }, - social: [ - { - icon: "github", - label: "GitHub", - href: "https://github.com/withastro/starlight", - }, - ], - sidebar: [], - plugins: [starlightThemeGalaxy()], - }), - mdx(), - ], + integrations: [ + starlight({ + title: 'NixCN', + defaultLocale: 'root', + locales: { + root: { + label: '简体中文', + lang: 'zh-CN', + }, + en: { + label: 'English', + }, + }, + social: [ + { + icon: 'github', + label: 'GitHub', + href: 'https://github.com/withastro/starlight', + }, + ], + sidebar: [], + plugins: [starlightThemeGalaxy()], + }), + mdx(), + ], }); diff --git a/package.json b/package.json index 6d4ae15..63e0c3f 100644 --- a/package.json +++ b/package.json @@ -1,20 +1,20 @@ { - "name": "nixcn-web", - "type": "module", - "version": "0.0.1", - "scripts": { - "dev": "astro dev", - "start": "astro dev", - "build": "astro build", - "preview": "astro preview", - "astro": "astro" - }, - "dependencies": { - "@astrojs/mdx": "^4.3.12", - "@astrojs/starlight": "^0.37.0", - "astro": "^5.6.1", - "sharp": "^0.34.2", - "starlight-theme-galaxy": "^0.5.2" - }, - "packageManager": "yarn@4.12.0" + "name": "nixcn-web", + "type": "module", + "version": "0.0.1", + "scripts": { + "dev": "astro dev", + "start": "astro dev", + "build": "astro build", + "preview": "astro preview", + "astro": "astro" + }, + "dependencies": { + "@astrojs/mdx": "^4.3.12", + "@astrojs/starlight": "^0.37.0", + "astro": "^5.6.1", + "sharp": "^0.34.2", + "starlight-theme-galaxy": "^0.5.2" + }, + "packageManager": "yarn@4.12.0" } diff --git a/src/content.config.ts b/src/content.config.ts index d9ee8c9..d68e795 100644 --- a/src/content.config.ts +++ b/src/content.config.ts @@ -3,5 +3,5 @@ import { docsLoader } from '@astrojs/starlight/loaders'; import { docsSchema } from '@astrojs/starlight/schema'; export const collections = { - docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }), + docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }), }; diff --git a/tsconfig.json b/tsconfig.json index 8bf91d3..1e72ac4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "astro/tsconfigs/strict", - "include": [".astro/types.d.ts", "**/*"], - "exclude": ["dist"] + "extends": "astro/tsconfigs/strict", + "include": [".astro/types.d.ts", "**/*"], + "exclude": ["dist"] }