diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e336802d5..ddb94a351 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -87,4 +87,34 @@ jobs: if [ -e "server/firebase-secret.json" ] || [ -e ".env" ]; then echo "Error: Found .env or firebase-secret.json in the pull request. Please remove them before merging." exit 1 - fi \ No newline at end of file + + prettier-check: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [21.x] + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies + run: npm ci + working-directory: server/ + + - name: Check Prettier Formatting in Server + run: npm run format:check + working-directory: server/ + + - name: Install dependencies + run: npm ci + working-directory: client/ + + - name: Check Prettier Formatting in Client + run: npm run format:check + working-directory: client/ \ No newline at end of file diff --git a/client/package-lock.json b/client/package-lock.json index e66df0b94..e7d960874 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -48,6 +48,7 @@ "eslint-config-expo": "^7.0.0", "jest": "^29.2.1", "jest-expo": "~51.0.1", + "prettier": "^3.3.3", "react-test-renderer": "18.2.0", "typescript": "~5.3.3" } @@ -18096,6 +18097,21 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/pretty-bytes": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz", diff --git a/client/package.json b/client/package.json index e98a5f52c..5f89650b5 100644 --- a/client/package.json +++ b/client/package.json @@ -9,7 +9,9 @@ "ios": "expo start --ios", "web": "expo start --web", "test": "jest --watchAll", - "lint": "expo lint" + "lint": "expo lint", + "format": "prettier --write .", + "format:check": "prettier --check ." }, "jest": { "preset": "jest-expo" @@ -51,12 +53,13 @@ "@types/jest": "^29.5.12", "@types/react": "~18.2.45", "@types/react-test-renderer": "^18.0.7", + "eslint": "^8.57.0", + "eslint-config-expo": "^7.0.0", "jest": "^29.2.1", "jest-expo": "~51.0.1", + "prettier": "^3.3.3", "react-test-renderer": "18.2.0", - "typescript": "~5.3.3", - "eslint": "^8.57.0", - "eslint-config-expo": "^7.0.0" + "typescript": "~5.3.3" }, "private": true } diff --git a/server/.prettierrc b/server/.prettierrc new file mode 100644 index 000000000..4030e75ff --- /dev/null +++ b/server/.prettierrc @@ -0,0 +1,11 @@ +{ + "bracketSpacing": true, + "jsxBracketSameLine": true, + "singleQuote": false, + "endofline": "lf", + "semi": true, + "tabWidth": 2, + "useTabs": false, + "printWidth": 80, + "trailingComma": "all" +} diff --git a/server/package-lock.json b/server/package-lock.json index 81ce346a5..a8841ff06 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -27,6 +27,7 @@ "@types/jest": "^29.5.11", "jest": "^29.7.0", "nodemon": "^3.0.3", + "prettier": "^3.3.3", "socket.io-client": "^4.7.4", "ts-node": "^10.9.1", "typescript": "^5.2.2" @@ -7875,6 +7876,21 @@ "node": ">=8" } }, + "node_modules/prettier": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/pretty-format": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", diff --git a/server/package.json b/server/package.json index 463b48ee5..32f8fe40b 100644 --- a/server/package.json +++ b/server/package.json @@ -8,7 +8,9 @@ "start": "node build/index.js", "build": "npx tsc", "build:watch": "npx tsc -w", - "start:watch": "nodemon build/index.js" + "start:watch": "nodemon build/index.js", + "format": "prettier --write .", + "format:check": "prettier --check ." }, "author": "", "license": "ISC", @@ -19,6 +21,7 @@ "@types/jest": "^29.5.11", "jest": "^29.7.0", "nodemon": "^3.0.3", + "prettier": "^3.3.3", "socket.io-client": "^4.7.4", "ts-node": "^10.9.1", "typescript": "^5.2.2"