diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..1167ad9 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,5 @@ +build +coverage +# 忽略了 markdown 文件 +# *.md + diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..86f82d1 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,13 @@ +{ + "trailingComma": "es5", + "tabWidth": 2, + "useTabs": false, + "semi": true, + "singleQuote": false, + "jsxSingleQuote": true, + "jsxBracketSameLine": false, + "arrowParens": "always", + "endOfLine": "lf", + "bracketSpacing": true, + "htmlWhitespaceSensitivity": "strict" +} diff --git a/babel.config.js b/babel.config.js index e955840..162a3ea 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,5 +1,3 @@ module.exports = { - presets: [ - '@vue/cli-plugin-babel/preset' - ] -} + presets: ["@vue/cli-plugin-babel/preset"], +}; diff --git a/package.json b/package.json index ad45210..2a6b6cb 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,13 @@ "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", - "lint": "vue-cli-service lint" + "lint": "vue-cli-service lint", + "prettier": "npx prettier --write ./src" + }, + "husky": { + "hooks": { + "pre-commit": "npm run prettier" + } }, "dependencies": { "@sentry/browser": "^5.27.0", @@ -19,6 +25,7 @@ "js-cookie": "^2.2.1", "nprogress": "^0.2.0", "plyr": "^3.6.2", + "prettier": "2.1.2", "register-service-worker": "^1.7.1", "svg-sprite-loader": "^5.0.0", "vue": "^2.6.11", @@ -38,6 +45,7 @@ "babel-eslint": "^10.1.0", "eslint": "^6.7.2", "eslint-plugin-vue": "^6.2.2", + "husky": "^4.3.0", "sass": "^1.26.11", "sass-loader": "^10.0.2", "vue-template-compiler": "^2.6.11" diff --git a/public/index.html b/public/index.html index 91e96b7..193d42c 100644 --- a/public/index.html +++ b/public/index.html @@ -1,22 +1,23 @@ +
+ + + + + +