diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml new file mode 100644 index 0000000..d683ff8 --- /dev/null +++ b/.github/workflows/prettier.yml @@ -0,0 +1,23 @@ +name: Format +on: + pull_request: + branches: [main] +jobs: + format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + - uses: actions/setup-node@v2 + with: + node-version: "20.x" + - run: npm ci + working-directory: ./frontend + - run: npm run prettify + working-directory: ./frontend + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: Apply formatting changes + branch: ${{ github.head_ref }} \ No newline at end of file diff --git a/frontend/.prettierrc.json b/frontend/.prettierrc.json new file mode 100644 index 0000000..26fe5ae --- /dev/null +++ b/frontend/.prettierrc.json @@ -0,0 +1,22 @@ +{ + "printWidth": 80, + "tabWidth": 2, + "useTabs": false, + "semi": true, + "singleQuote": false, + "quoteProps": "as-needed", + "jsxSingleQuote": false, + "trailingComma": "es5", + "bracketSpacing": true, + "bracketSameLine": false, + "jsxBracketSameLine": false, + "arrowParens": "always", + "requirePragma": false, + "insertPragma": false, + "proseWrap": "preserve", + "htmlWhitespaceSensitivity": "css", + "vueIndentScriptAndStyle": false, + "endOfLine": "lf", + "embeddedLanguageFormatting": "auto", + "singleAttributePerLine": false +} \ No newline at end of file diff --git a/frontend/package-lock.json b/frontend/package-lock.json index e91328f..8729a93 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -36,6 +36,7 @@ "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", "jest-transform-stub": "^2.0.0", + "prettier": "^3.3.1", "typescript": "^5.2.2", "vite": "^5.2.0" } @@ -8607,6 +8608,21 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.1.tgz", + "integrity": "sha512-7CAwy5dRsxs8PHXT3twixW9/OEll8MLE0VRPCJyl7CkS6VHGPSlsVaWTiASPTyGyYRyApxlaWTzwUxVNrhcwDg==", + "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/frontend/package.json b/frontend/package.json index cf8b553..1bd57b5 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -8,7 +8,8 @@ "test": "jest", "build": "tsc && vite build", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", - "preview": "vite preview" + "preview": "vite preview", + "prettify": "prettier ./src -w" }, "dependencies": { "axios": "^1.7.2", @@ -19,6 +20,7 @@ "styled-components": "^6.1.11" }, "devDependencies": { + "prettier": "^3.3.1", "@babel/core": "^7.24.6", "@babel/preset-env": "^7.24.6", "@babel/preset-react": "^7.24.6",