Skip to content

Commit 19813d2

Browse files
authored
ci: add code-check workflow (shadcn-ui#71)
1 parent a94375f commit 19813d2

File tree

17 files changed

+163
-16
lines changed

17 files changed

+163
-16
lines changed

.eslintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"rules": {
1212
"@next/next/no-html-link-for-pages": "off",
1313
"react/jsx-key": "off",
14-
"tailwindcss/no-custom-classname": "off"
14+
"tailwindcss/no-custom-classname": "off",
15+
"tailwindcss/classnames-order": "error"
1516
},
1617
"settings": {
1718
"tailwindcss": {

.github/workflows/code-check.yml

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Code check
2+
3+
on:
4+
pull_request:
5+
branches: ["*"]
6+
7+
jobs:
8+
lint:
9+
runs-on: ubuntu-latest
10+
name: Lint
11+
steps:
12+
- uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Install Node.js
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: 16
20+
21+
- uses: pnpm/[email protected]
22+
name: Install pnpm
23+
id: pnpm-install
24+
with:
25+
run_install: false
26+
27+
- name: Get pnpm store directory
28+
id: pnpm-cache
29+
run: |
30+
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
31+
- uses: actions/cache@v3
32+
name: Setup pnpm cache
33+
with:
34+
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
35+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
36+
restore-keys: |
37+
${{ runner.os }}-pnpm-store-
38+
- name: Install dependencies
39+
run: pnpm install
40+
41+
- run: pnpm lint
42+
43+
format:
44+
runs-on: ubuntu-latest
45+
name: Format
46+
steps:
47+
- uses: actions/checkout@v3
48+
with:
49+
fetch-depth: 0
50+
51+
- name: Install Node.js
52+
uses: actions/setup-node@v3
53+
with:
54+
node-version: 16
55+
56+
- uses: pnpm/[email protected]
57+
name: Install pnpm
58+
id: pnpm-install
59+
with:
60+
run_install: false
61+
62+
- name: Get pnpm store directory
63+
id: pnpm-cache
64+
run: |
65+
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
66+
67+
- uses: actions/cache@v3
68+
name: Setup pnpm cache
69+
with:
70+
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
71+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
72+
restore-keys: |
73+
${{ runner.os }}-pnpm-store-
74+
75+
- name: Install dependencies
76+
run: pnpm install
77+
78+
- run: pnpm format:check
79+
80+
tsc:
81+
runs-on: ubuntu-latest
82+
name: TypeScript
83+
steps:
84+
- uses: actions/checkout@v3
85+
with:
86+
fetch-depth: 0
87+
88+
- name: Install Node.js
89+
uses: actions/setup-node@v3
90+
with:
91+
node-version: 16
92+
93+
- uses: pnpm/[email protected]
94+
name: Install pnpm
95+
id: pnpm-install
96+
with:
97+
run_install: false
98+
99+
- name: Get pnpm store directory
100+
id: pnpm-cache
101+
run: |
102+
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
103+
- uses: actions/cache@v3
104+
name: Setup pnpm cache
105+
with:
106+
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
107+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
108+
restore-keys: |
109+
${{ runner.os }}-pnpm-store-
110+
- name: Install dependencies
111+
run: pnpm install
112+
113+
- run: pnpm typecheck

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ yarn-error.log*
3232
# turbo
3333
.turbo
3434

35-
.contentlayer
35+
.contentlayer
36+
tsconfig.tsbuildinfo

.prettierignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dist
2+
node_modules
3+
.next
4+
build
5+
.contentlayer

apps/www/.prettierignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dist
2+
node_modules
3+
.next
4+
build
5+
.contentlayer

apps/www/components/fonts.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import {
88
const fontSans = FontSans({
99
subsets: ["latin"],
1010
variable: "--font-sans",
11-
display: 'swap',
11+
display: "swap",
1212
})
1313

1414
const fontMono = FontMono({
1515
subsets: ["latin"],
1616
variable: "--font-mono",
17-
display: 'swap',
17+
display: "swap",
1818
})
1919

2020
export function Fonts() {

apps/www/components/ui/dropdown-menu.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const DropdownMenuContent = React.forwardRef<
6565
ref={ref}
6666
sideOffset={sideOffset}
6767
className={cn(
68-
"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",
68+
"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",
6969
className
7070
)}
7171
{...props}

apps/www/components/ui/switch.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const Switch = React.forwardRef<
1111
>(({ className, ...props }, ref) => (
1212
<SwitchPrimitives.Root
1313
className={cn(
14-
"peer inline-flex items-center h-[24px] w-[44px] shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors focus:outline-none focus:ring-2 focus:ring-slate-400 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=unchecked]:bg-slate-200 data-[state=checked]:bg-slate-900 dark:focus:ring-slate-400 dark:focus:ring-offset-slate-900 dark:data-[state=unchecked]:bg-slate-700 dark:data-[state=checked]:bg-slate-400",
14+
"peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus:outline-none focus:ring-2 focus:ring-slate-400 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=unchecked]:bg-slate-200 data-[state=checked]:bg-slate-900 dark:focus:ring-slate-400 dark:focus:ring-offset-slate-900 dark:data-[state=unchecked]:bg-slate-700 dark:data-[state=checked]:bg-slate-400",
1515
className
1616
)}
1717
{...props}

apps/www/content/docs/primitives/dialog.mdx

+3-4
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,12 @@ Dropdown Menu component in the Dialog component. For more information, refer to
8181
<DialogHeader>
8282
<DialogTitle>Are you sure absolutely sure?</DialogTitle>
8383
<DialogDescription>
84-
This action cannot be undone. Are you sure you want to permanently delete this file from our servers?
84+
This action cannot be undone. Are you sure you want to permanently
85+
delete this file from our servers?
8586
</DialogDescription>
8687
</DialogHeader>
8788
<DialogFooter>
88-
<Button type="submit">
89-
Confirm
90-
</Button>
89+
<Button type="submit">Confirm</Button>
9190
</DialogFooter>
9291
</DialogContent>
9392
</Dialog>

apps/www/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
"build": "next build",
88
"start": "next start",
99
"lint": "next lint",
10-
"preview": "next build && next start"
10+
"preview": "next build && next start",
11+
"typecheck": "contentlayer build && tsc --noEmit",
12+
"format:write": "prettier --write \"**/*.{ts,tsx,mdx}\" --cache",
13+
"format:check": "prettier --check \"**/*.{ts,tsx,mdx}\" --cache"
1114
},
1215
"dependencies": {
1316
"@next/font": "^13.1.6",

apps/www/tsconfig.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
}
2727
]
2828
},
29-
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
29+
"include": [
30+
"next-env.d.ts",
31+
"**/*.ts",
32+
"**/*.tsx",
33+
".next/types/**/*.ts",
34+
".contentlayer/generated"
35+
],
3036
"exclude": ["node_modules"]
3137
}

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
"dev": "turbo run dev --parallel",
1818
"lint": "turbo run lint",
1919
"preview": "turbo run preview",
20-
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
20+
"typecheck": "turbo run typecheck",
21+
"format:write": "turbo run format",
22+
"format:check": "turbo run format:check",
2123
"sync:templates": "./scripts/sync-templates.sh \"templates/*\"",
2224
"prepare": "husky install"
2325
},

templates/next-template/.prettierignore

+5
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,8 @@ package-lock.json
55
public
66
CHANGELOG.md
77
.yarn
8+
dist
9+
node_modules
10+
.next
11+
build
12+
.contentlayer

templates/next-template/components/site-header.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Link from "next/link"
2-
import { siteConfig } from "@/config/site"
32

3+
import { siteConfig } from "@/config/site"
44
import { Icons } from "@/components/icons"
55
import { MainNav } from "@/components/main-nav"
66
import { ThemeToggle } from "@/components/theme-toggle"

templates/next-template/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
"build": "next build",
88
"start": "next start",
99
"lint": "next lint",
10-
"preview": "next build && next start"
10+
"preview": "next build && next start",
11+
"typecheck": "tsc --noEmit",
12+
"format:write": "prettier --write \"**/*.{ts,tsx,mdx}\" --cache",
13+
"format:check": "prettier --check \"**/*.{ts,tsx,mdx}\" --cache"
1114
},
1215
"dependencies": {
1316
"@next/font": "^13.1.6",

templates/next-template/pages/_app.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import "@/styles/globals.css"
77
const fontSans = FontSans({
88
subsets: ["latin"],
99
variable: "--font-sans",
10-
display: 'swap',
10+
display: "swap",
1111
})
1212

1313
export default function App({ Component, pageProps }: AppProps) {

turbo.json

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
"lint": {
2020
"outputs": []
2121
},
22+
"format:check": {
23+
"outputs": []
24+
},
25+
"typecheck": {},
2226
"dev": {
2327
"cache": false
2428
}

0 commit comments

Comments
 (0)