Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add Husky and lint-staged for code formatting #4982

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions frontend/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cd frontend
npx lint-staged
4 changes: 4 additions & 0 deletions frontend/.lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"**/src/**/*.{js,jsx,ts,tsx}": ["prettier --write", "eslint --fix", "eslint"],
"**/src/**/*.{json,css,scss,md}": ["prettier --write"]
}
7 changes: 0 additions & 7 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# sealos frontend

## prepare auto script

```bash
cd /sealos # Make sure you are in the sealos root directory
sh frontend/scripts/initFormat.sh
```

## prepare dev host

```bash
Expand Down
8 changes: 5 additions & 3 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"private": true,
"version": "0.1.0",
"scripts": {
"format": "prettier --config .prettierrc.js --write **/src/**/*.ts **/src/**/*.tsx **/src/**/*.scss **/tsconfig.*json **/*config.js **/*config.json",
"preinstall": "npx only-allow pnpm",
"dev-desktop": "pnpm -r --filter ./desktop run dev",
"dev-app": "pnpm -r --filter ./providers/applaunchpad run dev",
Expand All @@ -16,7 +15,8 @@
"dev-invite": "pnpm -r --filter ./providers/invite run dev",
"dev-workorder": "pnpm -r --filter ./providers/workorder run dev",
"gen:theme-typings": "pnpm chakra-cli tokens packages/ui/src/theme/theme.ts --out node_modules/.pnpm/node_modules/@chakra-ui/styled-system/dist/theming.types.d.ts",
"postinstall": "pnpm run gen:theme-typings"
"postinstall": "pnpm run gen:theme-typings",
"prepare": "cd .. && husky frontend/.husky"
},
"workspaces": [
"./packages/*",
Expand All @@ -25,6 +25,8 @@
],
"devDependencies": {
"@chakra-ui/cli": "^2.4.1",
"husky": "^9.1.4",
"lint-staged": "^15.2.9",
"prettier": "^2.8.8"
},
"dependencies": {
Expand Down Expand Up @@ -63,4 +65,4 @@
"node": "20.4.0",
"pnpm": "8.9.0"
}
}
}
Loading
Loading