diff --git a/.eslintrc.json b/.eslintrc.json index 7612cf7791..d58b7822f3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -11,7 +11,8 @@ "rules": { "@next/next/no-html-link-for-pages": "off", "react/jsx-key": "off", - "tailwindcss/no-custom-classname": "off" + "tailwindcss/no-custom-classname": "off", + "tailwindcss/classnames-order": "error" }, "settings": { "tailwindcss": { diff --git a/.github/workflows/code-check.yml b/.github/workflows/code-check.yml new file mode 100644 index 0000000000..e5a59d3220 --- /dev/null +++ b/.github/workflows/code-check.yml @@ -0,0 +1,113 @@ +name: Code check + +on: + pull_request: + branches: ["*"] + +jobs: + lint: + runs-on: ubuntu-latest + name: Lint + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 16 + + - uses: pnpm/action-setup@v2.2.4 + name: Install pnpm + id: pnpm-install + with: + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + - name: Install dependencies + run: pnpm install + + - run: pnpm lint + + format: + runs-on: ubuntu-latest + name: Format + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 16 + + - uses: pnpm/action-setup@v2.2.4 + name: Install pnpm + id: pnpm-install + with: + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install + + - run: pnpm format:check + + tsc: + runs-on: ubuntu-latest + name: TypeScript + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 16 + + - uses: pnpm/action-setup@v2.2.4 + name: Install pnpm + id: pnpm-install + with: + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + - name: Install dependencies + run: pnpm install + + - run: pnpm typecheck diff --git a/.gitignore b/.gitignore index d1d13f0756..24c1ac8243 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,5 @@ yarn-error.log* # turbo .turbo -.contentlayer \ No newline at end of file +.contentlayer +tsconfig.tsbuildinfo \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000000..3aea320e00 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,5 @@ +dist +node_modules +.next +build +.contentlayer \ No newline at end of file diff --git a/apps/www/.prettierignore b/apps/www/.prettierignore new file mode 100644 index 0000000000..3aea320e00 --- /dev/null +++ b/apps/www/.prettierignore @@ -0,0 +1,5 @@ +dist +node_modules +.next +build +.contentlayer \ No newline at end of file diff --git a/apps/www/components/fonts.tsx b/apps/www/components/fonts.tsx index b7305c6ae8..b69ffe3e44 100644 --- a/apps/www/components/fonts.tsx +++ b/apps/www/components/fonts.tsx @@ -8,13 +8,13 @@ import { const fontSans = FontSans({ subsets: ["latin"], variable: "--font-sans", - display: 'swap', + display: "swap", }) const fontMono = FontMono({ subsets: ["latin"], variable: "--font-mono", - display: 'swap', + display: "swap", }) export function Fonts() { diff --git a/apps/www/components/ui/dropdown-menu.tsx b/apps/www/components/ui/dropdown-menu.tsx index 8d5ac68b2b..03cba5d86f 100644 --- a/apps/www/components/ui/dropdown-menu.tsx +++ b/apps/www/components/ui/dropdown-menu.tsx @@ -65,7 +65,7 @@ const DropdownMenuContent = React.forwardRef< ref={ref} sideOffset={sideOffset} className={cn( - "z-50 min-w-[8rem] overflow-hidden rounded-md border border-slate-100 bg-white p-1 text-slate-700 shadow-md dark:border-slate-800 dark:bg-slate-800 dark:text-slate-400 animate-in data-[side=right]:slide-in-from-left-2 data-[side=left]:slide-in-from-right-2 data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2", + "z-50 min-w-[8rem] overflow-hidden rounded-md border border-slate-100 bg-white p-1 text-slate-700 shadow-md animate-in data-[side=right]:slide-in-from-left-2 data-[side=left]:slide-in-from-right-2 data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2 dark:border-slate-800 dark:bg-slate-800 dark:text-slate-400", className )} {...props} diff --git a/apps/www/components/ui/switch.tsx b/apps/www/components/ui/switch.tsx index ec24502c3a..3191c44155 100644 --- a/apps/www/components/ui/switch.tsx +++ b/apps/www/components/ui/switch.tsx @@ -11,7 +11,7 @@ const Switch = React.forwardRef< >(({ className, ...props }, ref) => ( Are you sure absolutely sure? - This action cannot be undone. Are you sure you want to permanently delete this file from our servers? + This action cannot be undone. Are you sure you want to permanently + delete this file from our servers? - + diff --git a/apps/www/package.json b/apps/www/package.json index 839d5d964e..2b4c19b7f2 100644 --- a/apps/www/package.json +++ b/apps/www/package.json @@ -7,7 +7,10 @@ "build": "next build", "start": "next start", "lint": "next lint", - "preview": "next build && next start" + "preview": "next build && next start", + "typecheck": "contentlayer build && tsc --noEmit", + "format:write": "prettier --write \"**/*.{ts,tsx,mdx}\" --cache", + "format:check": "prettier --check \"**/*.{ts,tsx,mdx}\" --cache" }, "dependencies": { "@next/font": "^13.1.6", diff --git a/apps/www/tsconfig.json b/apps/www/tsconfig.json index 12d28000c8..0e25a206bb 100644 --- a/apps/www/tsconfig.json +++ b/apps/www/tsconfig.json @@ -26,6 +26,12 @@ } ] }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], + "include": [ + "next-env.d.ts", + "**/*.ts", + "**/*.tsx", + ".next/types/**/*.ts", + ".contentlayer/generated" + ], "exclude": ["node_modules"] } diff --git a/package.json b/package.json index cb3a7bff20..32f0fe705d 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,9 @@ "dev": "turbo run dev --parallel", "lint": "turbo run lint", "preview": "turbo run preview", - "format": "prettier --write \"**/*.{ts,tsx,md}\"", + "typecheck": "turbo run typecheck", + "format:write": "turbo run format", + "format:check": "turbo run format:check", "sync:templates": "./scripts/sync-templates.sh \"templates/*\"", "prepare": "husky install" }, diff --git a/templates/next-template/.prettierignore b/templates/next-template/.prettierignore index f93be62047..2f730936cf 100644 --- a/templates/next-template/.prettierignore +++ b/templates/next-template/.prettierignore @@ -5,3 +5,8 @@ package-lock.json public CHANGELOG.md .yarn +dist +node_modules +.next +build +.contentlayer \ No newline at end of file diff --git a/templates/next-template/components/site-header.tsx b/templates/next-template/components/site-header.tsx index 763fd05ead..5469b00471 100644 --- a/templates/next-template/components/site-header.tsx +++ b/templates/next-template/components/site-header.tsx @@ -1,6 +1,6 @@ import Link from "next/link" -import { siteConfig } from "@/config/site" +import { siteConfig } from "@/config/site" import { Icons } from "@/components/icons" import { MainNav } from "@/components/main-nav" import { ThemeToggle } from "@/components/theme-toggle" diff --git a/templates/next-template/package.json b/templates/next-template/package.json index 0a6df543d1..4f631279dc 100644 --- a/templates/next-template/package.json +++ b/templates/next-template/package.json @@ -7,7 +7,10 @@ "build": "next build", "start": "next start", "lint": "next lint", - "preview": "next build && next start" + "preview": "next build && next start", + "typecheck": "tsc --noEmit", + "format:write": "prettier --write \"**/*.{ts,tsx,mdx}\" --cache", + "format:check": "prettier --check \"**/*.{ts,tsx,mdx}\" --cache" }, "dependencies": { "@next/font": "^13.1.6", diff --git a/templates/next-template/pages/_app.tsx b/templates/next-template/pages/_app.tsx index 9166e201e8..e734438452 100644 --- a/templates/next-template/pages/_app.tsx +++ b/templates/next-template/pages/_app.tsx @@ -7,7 +7,7 @@ import "@/styles/globals.css" const fontSans = FontSans({ subsets: ["latin"], variable: "--font-sans", - display: 'swap', + display: "swap", }) export default function App({ Component, pageProps }: AppProps) { diff --git a/turbo.json b/turbo.json index 4b96db1867..916b51b6bc 100644 --- a/turbo.json +++ b/turbo.json @@ -19,6 +19,10 @@ "lint": { "outputs": [] }, + "format:check": { + "outputs": [] + }, + "typecheck": {}, "dev": { "cache": false }