From 3a3ed7b6e6ffef907b1e1cb8b42264eab527b53f Mon Sep 17 00:00:00 2001 From: Cody Olsen Date: Wed, 20 Nov 2024 22:09:10 +0100 Subject: [PATCH] add prettier action --- .github/workflows/prettier.yml | 39 +++++++++++++++++ package.json | 6 ++- pnpm-lock.yaml | 78 +++++++++++++++++++++++++++++++--- prettier.config.cjs | 12 ++++++ 4 files changed, 128 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/prettier.yml create mode 100644 prettier.config.cjs diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml new file mode 100644 index 0000000..be4c029 --- /dev/null +++ b/.github/workflows/prettier.yml @@ -0,0 +1,39 @@ +name: Prettier + +on: + push: + branches: [main] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true + +jobs: + run: + name: Can the code be prettier? 🤔 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + cache: pnpm + node-version: lts/* + - run: pnpm install + - run: pnpm format + - run: git restore .github/workflows + - uses: actions/create-github-app-token@v1 + id: generate-token + with: + app-id: ${{ secrets.ECOSPARK_APP_ID }} + private-key: ${{ secrets.ECOSPARK_APP_PRIVATE_KEY }} + - uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7 + with: + body: I ran `pnpm format` 🧑‍💻 + branch: actions/prettier + commit-message: "chore(prettier): 🤖 ✨" + labels: 🤖 bot + sign-commits: true + title: "chore(prettier): 🤖 ✨" + token: ${{ steps.generate-token.outputs.token }} diff --git a/package.json b/package.json index 1fa509e..ce29351 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,12 @@ }, "prettier": "@sanity/prettier-config", "dependencies": { + "@ianvs/prettier-plugin-sort-imports": "^4.4.0", "@sanity/prettier-config": "^1.0.3", - "prettier": "^3.3.3" + "prettier": "^3.3.3", + "prettier-plugin-astro": "^0.14.1", + "prettier-plugin-svelte": "^3.2.8", + "prettier-plugin-tailwindcss": "^0.6.9" }, "packageManager": "pnpm@9.14.2" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3abb49c..8d7632d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,12 +8,24 @@ importers: .: dependencies: + '@ianvs/prettier-plugin-sort-imports': + specifier: ^4.4.0 + version: 4.4.0(@vue/compiler-sfc@3.5.13)(prettier@3.3.3) '@sanity/prettier-config': specifier: ^1.0.3 version: 1.0.3(prettier@3.3.3) prettier: specifier: ^3.3.3 version: 3.3.3 + prettier-plugin-astro: + specifier: ^0.14.1 + version: 0.14.1 + prettier-plugin-svelte: + specifier: ^3.2.8 + version: 3.2.8(prettier@3.3.3)(svelte@5.2.6) + prettier-plugin-tailwindcss: + specifier: ^0.6.9 + version: 0.6.9(@ianvs/prettier-plugin-sort-imports@4.4.0(@vue/compiler-sfc@3.5.13)(prettier@3.3.3))(prettier-plugin-astro@0.14.1)(prettier-plugin-svelte@3.2.8(prettier@3.3.3)(svelte@5.2.6))(prettier@3.3.3) api: dependencies: @@ -38,7 +50,7 @@ importers: dependencies: '@astrojs/check': specifier: ^0.9.4 - version: 0.9.4(prettier@3.3.3)(typescript@5.6.3) + version: 0.9.4(prettier-plugin-astro@0.14.1)(prettier@3.3.3)(typescript@5.6.3) astro: specifier: ^5.0.0-beta.8 version: 5.0.0-beta.8(@types/node@22.9.1)(jiti@2.4.0)(rollup@4.27.3)(terser@5.36.0)(tsx@4.19.2)(typescript@5.6.3)(yaml@2.6.1) @@ -286,7 +298,7 @@ importers: version: 3.2.8(prettier@3.3.3)(svelte@5.2.6) prettier-plugin-tailwindcss: specifier: ^0.6.9 - version: 0.6.9(prettier-plugin-svelte@3.2.8(prettier@3.3.3)(svelte@5.2.6))(prettier@3.3.3) + version: 0.6.9(@ianvs/prettier-plugin-sort-imports@4.4.0(@vue/compiler-sfc@3.5.13)(prettier@3.3.3))(prettier-plugin-astro@0.14.1)(prettier-plugin-svelte@3.2.8(prettier@3.3.3)(svelte@5.2.6))(prettier@3.3.3) svelte: specifier: ^5.2.6 version: 5.2.6 @@ -1895,6 +1907,15 @@ packages: resolution: {integrity: sha512-c7hNEllBlenFTHBky65mhq8WD2kbN9Q6gk0bTk8lSBvc554jpXSkST1iePudpt7+A/AQvuHs9EMqjHDXMY1lrA==} engines: {node: '>=18.18'} + '@ianvs/prettier-plugin-sort-imports@4.4.0': + resolution: {integrity: sha512-f4/e+/ANGk3tHuwRW0uh2YuBR50I4h1ZjGQ+5uD8sWfinHTivQsnieR5cz24t8M6Vx4rYvZ5v/IEKZhYpzQm9Q==} + peerDependencies: + '@vue/compiler-sfc': 2.7.x || 3.x + prettier: 2 || 3 + peerDependenciesMeta: + '@vue/compiler-sfc': + optional: true + '@img/sharp-darwin-arm64@0.33.5': resolution: {integrity: sha512-UT4p+iz/2H4twwAoLCqfA9UH5pI6DggwKEGuaPy7nCVQ8ZsiY5PIcrRvD1DzuY3qYL07NtIQcWnBSY/heikIFQ==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} @@ -7184,6 +7205,10 @@ packages: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} + prettier-plugin-astro@0.14.1: + resolution: {integrity: sha512-RiBETaaP9veVstE4vUwSIcdATj6dKmXljouXc/DDNwBSPTp8FRkLGDSGFClKsAFeeg+13SB0Z1JZvbD76bigJw==} + engines: {node: ^14.15.0 || >=16.0.0} + prettier-plugin-packagejson@2.5.3: resolution: {integrity: sha512-ATMEEXr+ywls1kgrZEWl4SBPEm0uDdyDAjyNzUC0/Z8WZTD3RqbJcQDR+Dau+wYkW9KHK6zqQIsFyfn+9aduWg==} peerDependencies: @@ -7676,6 +7701,9 @@ packages: rxjs@7.8.1: resolution: {integrity: sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==} + s.color@0.0.15: + resolution: {integrity: sha512-AUNrbEUHeKY8XsYr/DYpl+qk5+aM+DChopnWOPEzn8YKzOhv4l2zH6LzZms3tOZP3wwdOyc0RmTciyi46HLIuA==} + sade@1.8.1: resolution: {integrity: sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==} engines: {node: '>=6'} @@ -7710,6 +7738,9 @@ packages: react-dom: ^18 styled-components: ^6.1 + sass-formatter@0.7.9: + resolution: {integrity: sha512-CWZ8XiSim+fJVG0cFLStwDvft1VI7uvXdCNJYXhDvowiv+DsbD1nXLiQ4zrE5UBvj5DWZJ93cwN0NX5PMsr1Pw==} + saxes@6.0.0: resolution: {integrity: sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==} engines: {node: '>=v12.22.7'} @@ -8074,6 +8105,9 @@ packages: engines: {node: '>=16 || 14 >=14.17'} hasBin: true + suf-log@2.5.3: + resolution: {integrity: sha512-KvC8OPjzdNOe+xQ4XWJV2whQA0aM1kGVczMQ8+dStAO6KfEB140JEVQ9dE76ONZ0/Ylf67ni4tILPJB41U0eow==} + superjson@2.2.1: resolution: {integrity: sha512-8iGv75BYOa0xRJHK5vRLEjE2H/i4lulTjzpUXic3Eg8akftYjkmQDa8JARQ42rlczXyFR3IeRoeFCc7RxHsYZA==} engines: {node: '>=16'} @@ -9232,9 +9266,9 @@ snapshots: css-tree: 2.3.1 is-potential-custom-element-name: 1.0.1 - '@astrojs/check@0.9.4(prettier@3.3.3)(typescript@5.6.3)': + '@astrojs/check@0.9.4(prettier-plugin-astro@0.14.1)(prettier@3.3.3)(typescript@5.6.3)': dependencies: - '@astrojs/language-server': 2.15.4(prettier@3.3.3)(typescript@5.6.3) + '@astrojs/language-server': 2.15.4(prettier-plugin-astro@0.14.1)(prettier@3.3.3)(typescript@5.6.3) chokidar: 4.0.1 kleur: 4.1.5 typescript: 5.6.3 @@ -9247,7 +9281,7 @@ snapshots: '@astrojs/internal-helpers@0.4.1': {} - '@astrojs/language-server@2.15.4(prettier@3.3.3)(typescript@5.6.3)': + '@astrojs/language-server@2.15.4(prettier-plugin-astro@0.14.1)(prettier@3.3.3)(typescript@5.6.3)': dependencies: '@astrojs/compiler': 2.10.3 '@astrojs/yaml2ts': 0.2.2 @@ -9269,6 +9303,7 @@ snapshots: vscode-uri: 3.0.8 optionalDependencies: prettier: 3.3.3 + prettier-plugin-astro: 0.14.1 transitivePeerDependencies: - typescript @@ -10712,6 +10747,19 @@ snapshots: '@humanwhocodes/retry@0.4.1': {} + '@ianvs/prettier-plugin-sort-imports@4.4.0(@vue/compiler-sfc@3.5.13)(prettier@3.3.3)': + dependencies: + '@babel/generator': 7.26.2 + '@babel/parser': 7.26.2 + '@babel/traverse': 7.25.9 + '@babel/types': 7.26.0 + prettier: 3.3.3 + semver: 7.6.3 + optionalDependencies: + '@vue/compiler-sfc': 3.5.13 + transitivePeerDependencies: + - supports-color + '@img/sharp-darwin-arm64@0.33.5': optionalDependencies: '@img/sharp-libvips-darwin-arm64': 1.0.4 @@ -17630,6 +17678,12 @@ snapshots: prelude-ls@1.2.1: {} + prettier-plugin-astro@0.14.1: + dependencies: + '@astrojs/compiler': 2.10.3 + prettier: 3.3.3 + sass-formatter: 0.7.9 + prettier-plugin-packagejson@2.5.3(prettier@3.3.3): dependencies: sort-package-json: 2.10.1 @@ -17642,10 +17696,12 @@ snapshots: prettier: 3.3.3 svelte: 5.2.6 - prettier-plugin-tailwindcss@0.6.9(prettier-plugin-svelte@3.2.8(prettier@3.3.3)(svelte@5.2.6))(prettier@3.3.3): + prettier-plugin-tailwindcss@0.6.9(@ianvs/prettier-plugin-sort-imports@4.4.0(@vue/compiler-sfc@3.5.13)(prettier@3.3.3))(prettier-plugin-astro@0.14.1)(prettier-plugin-svelte@3.2.8(prettier@3.3.3)(svelte@5.2.6))(prettier@3.3.3): dependencies: prettier: 3.3.3 optionalDependencies: + '@ianvs/prettier-plugin-sort-imports': 4.4.0(@vue/compiler-sfc@3.5.13)(prettier@3.3.3) + prettier-plugin-astro: 0.14.1 prettier-plugin-svelte: 3.2.8(prettier@3.3.3)(svelte@5.2.6) prettier@2.8.7: @@ -18152,6 +18208,8 @@ snapshots: dependencies: tslib: 2.8.1 + s.color@0.0.15: {} + sade@1.8.1: dependencies: mri: 1.2.0 @@ -18315,6 +18373,10 @@ snapshots: - terser - utf-8-validate + sass-formatter@0.7.9: + dependencies: + suf-log: 2.5.3 + saxes@6.0.0: dependencies: xmlchars: 2.2.0 @@ -18754,6 +18816,10 @@ snapshots: pirates: 4.0.6 ts-interface-checker: 0.1.13 + suf-log@2.5.3: + dependencies: + s.color: 0.0.15 + superjson@2.2.1: dependencies: copy-anything: 3.0.5 diff --git a/prettier.config.cjs b/prettier.config.cjs new file mode 100644 index 0000000..8d42638 --- /dev/null +++ b/prettier.config.cjs @@ -0,0 +1,12 @@ +const preset = require('@sanity/prettier-config') + +module.exports = { + ...preset, + plugins: [ + ...preset.plugins, + '@ianvs/prettier-plugin-sort-imports', + 'prettier-plugin-astro', + 'prettier-plugin-svelte', + 'prettier-plugin-tailwindcss', + ], +}