From 0ca848e26b6693a3ddf86c05b7f4c5a3c5c0e3ea Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Tue, 29 Nov 2022 08:15:59 -0800 Subject: [PATCH 1/2] add prettier to devDependencies, add lint-prettier and fix-prettier commands --- .prettierrc.json | 5 +++++ package.json | 47 +++++++++++++++++++++++++---------------------- 2 files changed, 30 insertions(+), 22 deletions(-) create mode 100644 .prettierrc.json diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..3a2e4ee --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,5 @@ +{ + "printWidth": 160, + "tabWidth": 4, + "useTabs": true +} diff --git a/package.json b/package.json index be9a691..66b994d 100644 --- a/package.json +++ b/package.json @@ -1,24 +1,27 @@ { - "name": "food-journal", - "version": "1.0.0", - "type": "module", - "scripts": { - "test": "mocha --recursive --require mock-local-storage './{,!(node_modules)/**}/*.test.js'", - "lint-js": "eslint **/*.js", - "fix-js": "eslint --fix **/*.js", - "lint-html": "htmlhint **/*.html", - "lint-css": "stylelint **/*.css", - "fix-css": "stylelint --fix **/*.css", - "http-server": "http-server source" - }, - "devDependencies": { - "eslint": "^8.27.0", - "htmlhint": "1.1.4", - "http-server": "", - "mocha": "10", - "mock-local-storage": "^1.1.23", - "puppeteer": "^18.2.1", - "stylelint": "14.14.1", - "stylelint-config-standard": "^29.0.0" - } + "name": "food-journal", + "version": "1.0.0", + "type": "module", + "scripts": { + "test": "mocha --recursive --require mock-local-storage './{,!(node_modules)/**}/*.test.js'", + "lint-js": "eslint **/*.js", + "fix-js": "eslint --fix **/*.js", + "lint-html": "htmlhint **/*.html", + "lint-css": "stylelint **/*.css", + "fix-css": "stylelint --fix **/*.css", + "http-server": "http-server source", + "lint-prettier": "prettier --check .", + "fix-prettier": "prettier --write ." + }, + "devDependencies": { + "eslint": "^8.27.0", + "htmlhint": "1.1.4", + "http-server": "", + "mocha": "10", + "mock-local-storage": "^1.1.23", + "prettier": "2.8.0", + "puppeteer": "^18.2.1", + "stylelint": "14.14.1", + "stylelint-config-standard": "^29.0.0" + } } From 5c4e4c38f49751b3ddb6396e60ddda587c44c700 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Tue, 29 Nov 2022 08:32:45 -0800 Subject: [PATCH 2/2] add prettier lint action --- .github/workflows/prettier-linting.yml | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/prettier-linting.yml diff --git a/.github/workflows/prettier-linting.yml b/.github/workflows/prettier-linting.yml new file mode 100644 index 0000000..1fd3626 --- /dev/null +++ b/.github/workflows/prettier-linting.yml @@ -0,0 +1,29 @@ +name: JS Unit Test + +on: + pull_request: + branches: + - main + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + # Single deploy job since we're just deploying + test: + runs-on: ubuntu-latest + steps: + - name: Install apt updates + run: sudo apt -y update; sudo apt -y upgrade; + - name: Install prerequisites + uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Checkout + uses: actions/checkout@v3 + - name: Install dependencies + run: sudo npm install + - name: Start local http server + run: sudo npm run http-server & + - name: Run tests + run: sudo npm lint-prettier \ No newline at end of file