From 176ea3bc91c0b4ccc36324da05b84f434af1d57f Mon Sep 17 00:00:00 2001 From: Matt Weiden <538456+mweiden@users.noreply.github.com> Date: Wed, 18 Dec 2019 17:47:32 -0800 Subject: [PATCH] Add auto-formatting to client and server modules One thing that can make linting faster is auto-formatting. This commit adds the yapf auto-formatting tool to the server module and uses eslint's "fix" functionality to speed up the linting/formatting process. --- Makefile | 7 +++++++ client/Makefile | 4 ++++ client/package.json | 1 + server/.style.yapf | 2 ++ server/Makefile | 4 ++++ 5 files changed, 18 insertions(+) create mode 100644 server/.style.yapf diff --git a/Makefile b/Makefile index 31a9ff7e..de95fffe 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,13 @@ build-for-server-dev: clean-server build-client cp client/build/service-worker.js server/app/web/static/js/ +# FORMATTING CODE + +.PHOHY: fmt +fmt: fmt-client fmt-server + +fmt-%: + cd $(*) && $(MAKE) fmt # CREATING DISTRIBUTION RELEASE diff --git a/client/Makefile b/client/Makefile index 25171e7d..ed6ae93e 100644 --- a/client/Makefile +++ b/client/Makefile @@ -6,6 +6,10 @@ install: build: install npm run build +.PHONY: fmt +fmt: + npm run fmt + .PHONY: clean clean: rm -rf node_modules diff --git a/client/package.json b/client/package.json index bb1e4f71..b6f60d7b 100644 --- a/client/package.json +++ b/client/package.json @@ -11,6 +11,7 @@ "clean": "rimraf build", "dev": "npm run clean && webpack --config configuration/webpack/webpack.config.dev.js", "e2e": "node node_modules/jest/bin/jest.js --verbose false --config __tests__/e2e/e2eJestConfig.json e2e/e2e.test.js", + "fmt": "eslint --fix src", "lint": "eslint src", "smoke-test": "start-server-and-test start-server-for-test :5000 e2e", "start": "node server/development.js", diff --git a/server/.style.yapf b/server/.style.yapf new file mode 100644 index 00000000..0e9640c2 --- /dev/null +++ b/server/.style.yapf @@ -0,0 +1,2 @@ +[style] +based_on_style = google diff --git a/server/Makefile b/server/Makefile index fef80f96..71c5b56c 100644 --- a/server/Makefile +++ b/server/Makefile @@ -1,3 +1,7 @@ +.PHONY: fmt +fmt: + yapf -ir . + .PHONY: clean clean: rm -f app/web/templates/index.html