From 091beffae79b6187349a92bb825a5e350fa557d4 Mon Sep 17 00:00:00 2001 From: Joel Date: Mon, 29 May 2023 17:49:01 +0800 Subject: [PATCH] feat: add code style (#242) --- .gitignore | 1 - web/.eslintignore | 7 ++++++ web/.eslintrc.json | 4 ++-- web/.husky/pre-commit | 4 ++++ web/.vscode/settings.json | 23 +++++++++++++++++++ .../app/(appDetailLayout)/layout.tsx | 6 ++--- web/package.json | 16 +++++++++++-- 7 files changed, 53 insertions(+), 8 deletions(-) create mode 100644 web/.eslintignore create mode 100755 web/.husky/pre-commit create mode 100644 web/.vscode/settings.json diff --git a/.gitignore b/.gitignore index 50f682499e..6324233829 100644 --- a/.gitignore +++ b/.gitignore @@ -130,7 +130,6 @@ dmypy.json .idea/' .DS_Store -.vscode # Intellij IDEA Files .idea/ diff --git a/web/.eslintignore b/web/.eslintignore new file mode 100644 index 0000000000..8a8bc38d80 --- /dev/null +++ b/web/.eslintignore @@ -0,0 +1,7 @@ +/**/node_modules/* +node_modules/ + +dist/ +build/ +out/ +.next/ \ No newline at end of file diff --git a/web/.eslintrc.json b/web/.eslintrc.json index db813b0b25..9d8ea2cc8d 100644 --- a/web/.eslintrc.json +++ b/web/.eslintrc.json @@ -23,6 +23,6 @@ ] } ], - "react-hooks/exhaustive-deps": "warning" + "react-hooks/exhaustive-deps": "warn" } -} +} \ No newline at end of file diff --git a/web/.husky/pre-commit b/web/.husky/pre-commit new file mode 100755 index 0000000000..7a8fabf9e8 --- /dev/null +++ b/web/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +cd ./web && npx lint-staged diff --git a/web/.vscode/settings.json b/web/.vscode/settings.json new file mode 100644 index 0000000000..0b5ecc7e77 --- /dev/null +++ b/web/.vscode/settings.json @@ -0,0 +1,23 @@ +{ + "prettier.enable": false, + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + }, + "eslint.format.enable": true, + "[python]": { + "editor.formatOnType": true + }, + "[html]": { + "editor.defaultFormatter": "vscode.html-language-features" + }, + "[typescriptreact]": { + "editor.defaultFormatter": "vscode.typescript-language-features" + }, + "[javascriptreact]": { + "editor.defaultFormatter": "vscode.typescript-language-features" + }, + "[jsonc]": { + "editor.defaultFormatter": "vscode.json-language-features" + } +} \ No newline at end of file diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/layout.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/layout.tsx index b70959ea79..7164a00be0 100644 --- a/web/app/(commonLayout)/app/(appDetailLayout)/layout.tsx +++ b/web/app/(commonLayout)/app/(appDetailLayout)/layout.tsx @@ -7,9 +7,9 @@ export type IAppDetail = { const AppDetail: FC = ({ children }) => { return ( - <> - {children} - + <> + {children} + ) } diff --git a/web/package.json b/web/package.json index 76158c7730..89d44ed2b6 100644 --- a/web/package.json +++ b/web/package.json @@ -7,7 +7,9 @@ "build": "next build", "start": "next start", "lint": "next lint", - "fix": "next lint --fix" + "fix": "next lint --fix", + "eslint-fix": "eslint --fix", + "prepare": "cd ../ && husky install ./web/.husky" }, "dependencies": { "@emoji-mart/data": "^1.1.2", @@ -78,8 +80,18 @@ "@types/qs": "^6.9.7", "autoprefixer": "^10.4.14", "eslint-plugin-react-hooks": "^4.6.0", + "husky": "^8.0.3", + "lint-staged": "^13.2.2", "miragejs": "^0.1.47", "postcss": "^8.4.21", "tailwindcss": "^3.2.7" + }, + "lint-staged": { + "**/*.js?(x)": [ + "eslint --fix" + ], + "**/*.ts?(x)": [ + "eslint --fix" + ] } -} +} \ No newline at end of file