From b931d7f62935812f8c78a79b99ae9af576a70d7d Mon Sep 17 00:00:00 2001 From: Dustin Do Date: Sun, 22 Sep 2024 04:53:45 +0700 Subject: [PATCH] feat: add biome commit hook --- .vscode/settings.json | 2 +- apps/mobile/components/ui/dropdown-menu.tsx | 2 +- apps/mobile/components/ui/input.tsx | 2 +- apps/mobile/components/ui/tabs.tsx | 2 +- biome.json | 8 +- lefthook.yml | 8 ++ package.json | 14 ++- pnpm-lock.yaml | 100 ++++++++++++++++++++ 8 files changed, 129 insertions(+), 9 deletions(-) create mode 100644 lefthook.yml diff --git a/.vscode/settings.json b/.vscode/settings.json index c17efeff..c584a2f7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -25,7 +25,7 @@ "commands": [ { "match": "\\.(ts|tsx|js|jsx|html)$", - "cmd": "pnpm biome lint ${file} --apply-unsafe" + "cmd": "pnpm biome lint ${file} --unsafe" } ] } diff --git a/apps/mobile/components/ui/dropdown-menu.tsx b/apps/mobile/components/ui/dropdown-menu.tsx index 519eb615..81916bd4 100644 --- a/apps/mobile/components/ui/dropdown-menu.tsx +++ b/apps/mobile/components/ui/dropdown-menu.tsx @@ -40,7 +40,7 @@ const DropdownMenuSubTrigger = React.forwardRef< return ( diff --git a/apps/mobile/components/ui/input.tsx b/apps/mobile/components/ui/input.tsx index 56a4b554..e6e82272 100644 --- a/apps/mobile/components/ui/input.tsx +++ b/apps/mobile/components/ui/input.tsx @@ -15,7 +15,7 @@ const Input = React.forwardRef< className, )} placeholderClassName={cn( - 'text-muted-foreground font-regular', + 'font-regular text-muted-foreground', placeholderClassName, )} {...props} diff --git a/apps/mobile/components/ui/tabs.tsx b/apps/mobile/components/ui/tabs.tsx index 4b605108..c1d9303a 100644 --- a/apps/mobile/components/ui/tabs.tsx +++ b/apps/mobile/components/ui/tabs.tsx @@ -28,7 +28,7 @@ const TabsTrigger = React.forwardRef< return ( diff --git a/biome.json b/biome.json index 5249b8b3..6d0fa4e0 100644 --- a/biome.json +++ b/biome.json @@ -1,5 +1,9 @@ { "$schema": "https://biomejs.dev/schemas/1.8.0/schema.json", + "files": { + "ignoreUnknown": true, + "ignore": ["apps/mobile/scripts/*"] + }, "formatter": { "enabled": true, "formatWithErrors": false, @@ -20,7 +24,7 @@ "fix": "safe", "options": { "attributes": ["className"], - "functions": ["clsx", "cva", "tw"] + "functions": ["clsx", "cva", "tw", "cn"] } } }, @@ -236,7 +240,7 @@ "noCommentText": "error", "noCompareNegZero": "error", "noConfusingLabels": "error", - "noConsoleLog": "warn", + "noConsoleLog": { "fix": "none", "level": "warn" }, "noControlCharactersInRegex": "error", "noDebugger": "error", "noDoubleEquals": "error", diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 00000000..045c188d --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,8 @@ +# Refer for explanation to following link: +# https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md + +pre-commit: + commands: + check: + glob: "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}" + run: pnpm run -r "check" --write --no-errors-on-unmatched --files-ignore-unknown=true --colors=off --unsafe {staged_files} diff --git a/package.json b/package.json index 8ff52c19..f0fc65a3 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,10 @@ "name": "6pm", "version": "1.0.2", "license": "GPL-3.0", - "workspaces": ["apps/*", "packages/*"], + "workspaces": [ + "apps/*", + "packages/*" + ], "scripts": { "api:dev": "pnpm --filter @6pm/api run dev", "api:build": "pnpm --filter @6pm/api run build", @@ -20,11 +23,16 @@ "@lingui/cli": "^4.11.1", "@lingui/macro": "^4.11.1", "babel-plugin-macros": "^3.1.0", - "conventional-changelog-cli": "^5.0.0" + "conventional-changelog-cli": "^5.0.0", + "lefthook": "^1.7.15" }, "pnpm": { "peerDependencyRules": { - "ignoreMissing": ["@babel/*", "expo-modules-*", "typescript"] + "ignoreMissing": [ + "@babel/*", + "expo-modules-*", + "typescript" + ] }, "overrides": { "react": "18.3.1" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7edc761d..30c272b9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -29,6 +29,9 @@ importers: conventional-changelog-cli: specifier: ^5.0.0 version: 5.0.0(conventional-commits-filter@5.0.0) + lefthook: + specifier: ^1.7.15 + version: 1.7.15 apps/api: dependencies: @@ -5399,6 +5402,60 @@ packages: resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==} engines: {node: '>=6'} + lefthook-darwin-arm64@1.7.15: + resolution: {integrity: sha512-o8JgCnLM7UgF9g0MwarHJFoj6aVSSkUInHpsQZegV1c7CVQY/LIXgSeAWRb9XBvuUjByJ/HiHFMp9/hAALTwxQ==} + cpu: [arm64] + os: [darwin] + + lefthook-darwin-x64@1.7.15: + resolution: {integrity: sha512-nrdoex0icmXYl7AAvG7WtfEzjQtX/kWvM88jPu/gijH6VhAjp110Y8VScB7rWOcApb5kNNeqd1nKMAFgZ8KhAg==} + cpu: [x64] + os: [darwin] + + lefthook-freebsd-arm64@1.7.15: + resolution: {integrity: sha512-zl1TPynklJZZ/YsWb2H0gfErQbey318i2W85wIKGEk8kC2UzOgYTuPffnfi7kANei9ntZnhvGgilc6tqYOPuGQ==} + cpu: [arm64] + os: [freebsd] + + lefthook-freebsd-x64@1.7.15: + resolution: {integrity: sha512-/gKPwhWhZ3Q/efGs73/qw6nyR4WCT74oSTgn8wabAJO5+T/2FXTKzo7IiKkQmScmY5OcnD/0teJbJZ17VWSSOg==} + cpu: [x64] + os: [freebsd] + + lefthook-linux-arm64@1.7.15: + resolution: {integrity: sha512-re2f8WmYw19n8ojit0rnKbERAzD1/iCpU/Y8anXOjD/ROw/cpSfO88uKQrUCNY9Rp4XLtkkp9oDJs3Eg7JS7vA==} + cpu: [arm64] + os: [linux] + + lefthook-linux-x64@1.7.15: + resolution: {integrity: sha512-Kj6ieTlhFGlbPDyVFeOb296MS9x/Jj5y/xTPLBM+EKbdsTJSvUYu5FdtEWfhpLyWmPfkZtULHcTQE1hoo9Q4Cg==} + cpu: [x64] + os: [linux] + + lefthook-openbsd-arm64@1.7.15: + resolution: {integrity: sha512-85amE23mJ4BC9OThLkt+QCeVwue2Cr0ezN9LSwP0h8+royyj7YRcSu0VM/Et3B9LO50T2bpdI9norOqTcPZ9yA==} + cpu: [arm64] + os: [openbsd] + + lefthook-openbsd-x64@1.7.15: + resolution: {integrity: sha512-vXx/PpcalFgdvqkoHLI4KTGZp0ti+VCCL7RqDTA6n+GZpxPTWEXSOz3GuwNALX93Dn6MOYQYktKtXADwy24fcA==} + cpu: [x64] + os: [openbsd] + + lefthook-windows-arm64@1.7.15: + resolution: {integrity: sha512-jPKdQOLWQLRPO3VfI3ptpmdQBBsXTwaCLKXMo/gcSyU0xE/ltPD4QqvHzTAFJo00VcKRHjv9QeH69qhENjJtjw==} + cpu: [arm64] + os: [win32] + + lefthook-windows-x64@1.7.15: + resolution: {integrity: sha512-tlkSU669+b64AsqytGy1W3au7h8kFjt5ejLhTkErJpylTqThZIHm/GI0wUmpX+ud8kekM+9j407dweAHYOQ1XA==} + cpu: [x64] + os: [win32] + + lefthook@1.7.15: + resolution: {integrity: sha512-HW2mYkhg0a3RH2t57+ZJwacJiSIuDEhsXQAaCw6iGeN7zowdUV7g5QtnRdFdPkaK2eaNFpG6Rp0GsTrl/v0gNg==} + hasBin: true + leven@3.1.0: resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==} engines: {node: '>=6'} @@ -14048,6 +14105,49 @@ snapshots: kleur@3.0.3: {} + lefthook-darwin-arm64@1.7.15: + optional: true + + lefthook-darwin-x64@1.7.15: + optional: true + + lefthook-freebsd-arm64@1.7.15: + optional: true + + lefthook-freebsd-x64@1.7.15: + optional: true + + lefthook-linux-arm64@1.7.15: + optional: true + + lefthook-linux-x64@1.7.15: + optional: true + + lefthook-openbsd-arm64@1.7.15: + optional: true + + lefthook-openbsd-x64@1.7.15: + optional: true + + lefthook-windows-arm64@1.7.15: + optional: true + + lefthook-windows-x64@1.7.15: + optional: true + + lefthook@1.7.15: + optionalDependencies: + lefthook-darwin-arm64: 1.7.15 + lefthook-darwin-x64: 1.7.15 + lefthook-freebsd-arm64: 1.7.15 + lefthook-freebsd-x64: 1.7.15 + lefthook-linux-arm64: 1.7.15 + lefthook-linux-x64: 1.7.15 + lefthook-openbsd-arm64: 1.7.15 + lefthook-openbsd-x64: 1.7.15 + lefthook-windows-arm64: 1.7.15 + lefthook-windows-x64: 1.7.15 + leven@3.1.0: {} lie@3.1.1: