From a9819939bc3b1b6e0b5fd2185f0513273a4964e7 Mon Sep 17 00:00:00 2001 From: syy11cn Date: Fri, 29 Oct 2021 15:09:26 +0800 Subject: [PATCH] feat: add prettier for code formatting --- .prettierignore | 15 +++++++++++++++ .prettierrc | 12 ++++++++++++ package.json | 5 ++++- yarn.lock | 5 +++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .prettierignore create mode 100644 .prettierrc diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..15cfc91 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,15 @@ +*.svg +package.json +.DS_Store +.eslintignore +*.png +*.toml +.editorconfig +.gitignore +.prettierignore +LICENSE +.eslintcache +*.lock +yarn-error.log +/build +/public diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..f147403 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,12 @@ +{ + "printWidth": 100, + "semi": true, + "singleQuote": true, + "tabWidth": 2, + "trailingComma": "all", + "bracketSpacing": true, + "jsxBracketSameLine": false, + "arrowParens": "always", + "requirePragma": false, + "proseWrap": "preserve" +} diff --git a/package.json b/package.json index a670118..fa916b1 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,9 @@ "serve": "vite preview", "lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx", "lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx ./src", - "lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx" + "lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx", + "lint:prettier": "prettier --check \"src/**/*\" --end-of-line auto", + "prettier": "prettier -c --write \"src/**/*\"" }, "dependencies": { "react": "^17.0.0", @@ -21,6 +23,7 @@ "eslint-plugin-react": "^7.26.1", "eslint-plugin-react-hooks": "^4.2.0", "esprima": "^4.0.1", + "prettier": "^2.4.1", "vite": "^2.6.4" } } diff --git a/yarn.lock b/yarn.lock index c33688e..c26e8b5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1536,6 +1536,11 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== +prettier@^2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.4.1.tgz#671e11c89c14a4cfc876ce564106c4a6726c9f5c" + integrity sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA== + progress@^2.0.0: version "2.0.3" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8"