diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..0da96d6 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx pretty-quick --staged diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..d6c92ae --- /dev/null +++ b/.prettierignore @@ -0,0 +1,13 @@ +**/*.md +**/*.svg +**/*.ejs +**/*.html +**/*.yml +package.json +node_modules +dist +build +coverage +lib +esm +test \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..764fbde --- /dev/null +++ b/.prettierrc @@ -0,0 +1,11 @@ +{ + "singleQuote": true, + "trailingComma": "all", + "printWidth": 120, + "overrides": [ + { + "files": ".prettierrc", + "options": { "parser": "json" } + } + ] +} diff --git a/package.json b/package.json index 3cb4b9c..05bee47 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,10 @@ "private": true, "scripts": { "start": "kkt start", - "build": "kkt build" + "build": "kkt build", + "prepare": "husky install", + "prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'", + "pretty-quick": "pretty-quick --staged" }, "license": "MIT", "dependencies": { @@ -52,6 +55,9 @@ "@types/react": "^18.0.17", "@types/react-dom": "^18.0.6", "@types/styled-components": "^5.1.25", + "husky": "^8.0.1", + "prettier": "^2.7.1", + "pretty-quick": "~3.1.3", "kkt": "^7.2.0", "markdown-react-code-preview-loader": "^2.1.2" }, diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx index b8df9fb..b8471d3 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout.tsx @@ -4,8 +4,7 @@ import '@wcj/dark-mode'; import { ReactComponent as LogoIcon } from '../assets/logo.svg'; import { ReactComponent as GithubIcon } from '../assets/github.svg'; -const Warpper = styled.div` -`; +const Warpper = styled.div``; const Header = styled.header` display: flex; @@ -27,7 +26,7 @@ const Logo = styled(LogoIcon)` `; const Title = styled.h1` - font-size: 1.0rem; + font-size: 1rem; margin: 0; display: flex; align-items: center; @@ -77,4 +76,4 @@ export function Layout() { ); -} \ No newline at end of file +} diff --git a/src/pages/home/Preview.tsx b/src/pages/home/Preview.tsx index 524af86..184d045 100644 --- a/src/pages/home/Preview.tsx +++ b/src/pages/home/Preview.tsx @@ -14,4 +14,4 @@ const Warpper = styled.div` export const Preview = (props: MarkdownPreviewProps, visible: boolean) => { const html = markdownToHTML(props.source || '', def); return ; -} \ No newline at end of file +}; diff --git a/src/pages/home/copy.tsx b/src/pages/home/copy.tsx index 20abd45..21de72c 100644 --- a/src/pages/home/copy.tsx +++ b/src/pages/home/copy.tsx @@ -24,7 +24,7 @@ const CopyView: React.FC<{ command: ICommand; editorProps: IMarkdownEditor & Too document.execCommand(`copy`); window.getSelection()?.removeAllRanges(); toast.success(
复制成功!去公众号编辑器复制吧!
); - } + }; return (