From c8ea44eecca8ec644104b9c3fda0ae0f765549c3 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 28 Aug 2019 15:33:50 +0200 Subject: [PATCH] Client - add prettier --- .eslintrc.json | 5 +++-- .prettierrc | 9 +++++++++ Makefile | 5 +++++ package.json | 6 +++++- yarn.lock | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 .prettierrc diff --git a/.eslintrc.json b/.eslintrc.json index 48b39fbf..74b2989d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -16,6 +16,7 @@ "es6": true, "jest": true }, + "extends": ["plugin:prettier/recommended"], "rules": { "no-alert": "warn", "no-array-constructor": "off", @@ -411,7 +412,7 @@ "import/no-named-default": "warn", "import/no-anonymous-default-export": "off" }, - "plugins": ["react", "import"], + "plugins": ["react", "import", "prettier"], "settings": { "import/resolver": { "node": { @@ -421,7 +422,7 @@ "react": { "createClass": "createReactClass", "pragma": "React", - "version": "16.6" + "version": "16.8" }, "propWrapperFunctions": [ "forbidExtraProps", diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..52589678 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,9 @@ +{ + "tabWidth": 2, + "useTabs": false, + "semi": false, + "singleQuote": true, + "trailingComma": "es5", + "bracketSpacing": true, + "jsxBracketSameLine": false +} diff --git a/Makefile b/Makefile index 3a0a211e..872a51de 100644 --- a/Makefile +++ b/Makefile @@ -52,6 +52,8 @@ install-python-dev: lint-all: lint-python lint-react +lint-all-fix: lint-python-fix lint-react-fix + lint-python: $(PYTEST) --flake8 --isort --black -m "flake8 or isort or black" fittrackee_api --ignore=fittrackee_api/migrations @@ -61,6 +63,9 @@ lint-python-fix: lint-react: $(NPM) lint +lint-react-fix: + $(NPM) lint-fix + migrate-db: $(FLASK) db migrate --directory $(MIGRATIONS) diff --git a/package.json b/package.json index 87e1a942..0ffb9b00 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "build": "cd fittrackee_client && react-scripts build", "test": "cd fittrackee_client && testcafe firefox e2e", "eject": "cd fittrackee_client && react-scripts eject", - "lint": "eslint --cache --ext .jsx --ext .js fittrackee_client/src" + "lint": "eslint --cache --ext .jsx --ext .js fittrackee_client/src", + "lint-fix": "eslint --cache --ext .jsx --ext .js fittrackee_client/src --fix" }, "eslintConfig": { "extends": "react-app" @@ -39,7 +40,10 @@ "not op_mini all" ], "devDependencies": { + "eslint-config-prettier": "^6.1.0", + "eslint-plugin-prettier": "^3.1.0", "eslint-plugin-testcafe": "^0.2.1", + "prettier": "^1.18.2", "randomstring": "^1.1.5", "testcafe": "^1.1.3" } diff --git a/yarn.lock b/yarn.lock index 83353128..ac471e37 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4452,6 +4452,13 @@ escodegen@^1.11.0, escodegen@^1.9.1: optionalDependencies: source-map "~0.6.1" +eslint-config-prettier@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.1.0.tgz#e6f678ba367fbd1273998d5510f76f004e9dce7b" + integrity sha512-k9fny9sPjIBQ2ftFTesJV21Rg4R/7a7t7LCtZVrYQiHEp8Nnuk3EGaDmsKSAnsPj0BYcgB2zxzHa2NTkIxcOLg== + dependencies: + get-stdin "^6.0.0" + eslint-config-react-app@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/eslint-config-react-app/-/eslint-config-react-app-5.0.1.tgz#5f3d666ba3ee3cb384eb943e260e868f6c72251b" @@ -4525,6 +4532,13 @@ eslint-plugin-jsx-a11y@6.2.3: has "^1.0.3" jsx-ast-utils "^2.2.1" +eslint-plugin-prettier@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.0.tgz#8695188f95daa93b0dc54b249347ca3b79c4686d" + integrity sha512-XWX2yVuwVNLOUhQijAkXz+rMPPoCr7WFiAl8ig6I7Xn+pPVhDhzg4DxHpmbeb0iqjO9UronEA3Tb09ChnFVHHA== + dependencies: + prettier-linter-helpers "^1.0.0" + eslint-plugin-react-hooks@^1.6.1: version "1.7.0" resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-1.7.0.tgz#6210b6d5a37205f0b92858f895a4e827020a7d04" @@ -4856,6 +4870,11 @@ fast-deep-equal@^2.0.1: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" integrity sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk= +fast-diff@^1.1.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03" + integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w== + fast-glob@^2.0.2, fast-glob@^2.2.6: version "2.2.7" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-2.2.7.tgz#6953857c3afa475fff92ee6015d52da70a4cd39d" @@ -5200,6 +5219,11 @@ get-stdin@^4.0.1: resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" integrity sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4= +get-stdin@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b" + integrity sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g== + get-stream@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" @@ -8980,6 +9004,18 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= +prettier-linter-helpers@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" + integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== + dependencies: + fast-diff "^1.1.2" + +prettier@^1.18.2: + version "1.18.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea" + integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw== + pretty-bytes@^5.1.0: version "5.3.0" resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-5.3.0.tgz#f2849e27db79fb4d6cfe24764fc4134f165989f2"