diff --git a/.eslintrc b/.eslintrc index b50213f01..66b480dc3 100644 --- a/.eslintrc +++ b/.eslintrc @@ -9,7 +9,8 @@ "google", "plugin:react/recommended", "plugin:flowtype/recommended", - "plugin:jest/recommended" + "plugin:jest/recommended", + "plugin:prettier/recommended" ], "parser": "babel-eslint", "parserOptions": { @@ -30,6 +31,7 @@ "__APP_VERSION__": true }, "rules": { + "prettier/prettier": ["error", null, "@prettier"], "no-useless-escape": 2, "react/no-deprecated": 1, "react/jsx-no-target-blank": 1, diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..a29f3cdd6 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,12 @@ +{ + "useTabs": false, + "printWidth": 160, + "tabWidth": 2, + "singleQuote": true, + "requirePragma": true, + "bracketSpacing": false, + "jsxBracketSameLine": false, + "trailingComma": "es5", + "semi": true, + "parser": "flow" +} diff --git a/package.json b/package.json index 0d08fabcf..7b0842f1a 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "js-string-escape": "1.0.1", "js-yaml": "3.12.0", "jsonwebtoken": "8.3.0", + "lint-staged": "7.2.0", "lockfile": "1.0.4", "lodash": "4.17.10", "lunr": "0.7.0", @@ -77,8 +78,8 @@ "babel-register": "6.26.0", "babel-runtime": "6.26.0", "bundlesize": "0.17.0", - "cross-env": "5.1.4", "codecov": "3.0.4", + "cross-env": "5.1.4", "css-loader": "0.28.10", "element-react": "1.4.8", "element-theme-default": "1.4.13", @@ -86,11 +87,13 @@ "enzyme-adapter-react-16": "1.1.1", "eslint": "5.2.0", "eslint-config-google": "0.9.1", - "eslint-loader": "2.1.0", - "eslint-plugin-babel": "5.1.0", - "eslint-plugin-flowtype": "2.50.0", + "eslint-config-prettier": "2.9.0", + "eslint-loader": "2.0.0", + "eslint-plugin-babel": "4.1.2", + "eslint-plugin-flowtype": "2.49.3", "eslint-plugin-import": "2.13.0", "eslint-plugin-jest": "21.18.0", + "eslint-plugin-prettier": "2.6.2", "eslint-plugin-react": "7.10.0", "file-loader": "1.1.11", "flow-bin": "0.77.0", @@ -112,6 +115,7 @@ "normalize.css": "8.0.0", "optimize-css-assets-webpack-plugin": "5.0.0", "ora": "1.4.0", + "prettier": "1.13.7", "prop-types": "15.6.1", "puppeteer": "1.1.1", "react": "16.2.0", @@ -185,9 +189,16 @@ }, "husky": { "hooks": { - "pre-commit": "npm run lint" + "pre-commit": "lint-staged" } }, + "lint-staged": { + "*.js": [ + "eslint .", + "prettier --write", + "git add" + ] + }, "bundlesize": [ { "path": "./static/vendor*.js", diff --git a/src/webui/.eslintrc b/src/webui/.eslintrc index 0869e876d..eb219c736 100644 --- a/src/webui/.eslintrc +++ b/src/webui/.eslintrc @@ -10,7 +10,14 @@ }, "rules": { "require-jsdoc": 0, - "no-console": 2, + "no-console": [ + 1, + { + "allow": [ + "log" + ] + } + ], "no-unused-vars": [ 2, { diff --git a/yarn.lock b/yarn.lock index 4d61bfa78..fdda21f14 100644 Binary files a/yarn.lock and b/yarn.lock differ