From 87c066d1f31a176936af5afc47340ec0c7ab1b83 Mon Sep 17 00:00:00 2001 From: Ashcon Partovi Date: Tue, 24 Sep 2024 22:16:40 -0700 Subject: [PATCH] `bun run prettier` --- .github/workflows/prettier-format.yml | 36 +++++++++++++++++++++++++++ .prettierrc-ci | 31 ----------------------- package.json | 15 ++++++----- 3 files changed, 45 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/prettier-format.yml delete mode 100644 .prettierrc-ci diff --git a/.github/workflows/prettier-format.yml b/.github/workflows/prettier-format.yml new file mode 100644 index 0000000000000..7252ea653c66c --- /dev/null +++ b/.github/workflows/prettier-format.yml @@ -0,0 +1,36 @@ +name: prettier-format + +permissions: + contents: write + +on: + workflow_call: + workflow_dispatch: + pull_request: + paths: + - ".github/workflows/prettier.yml" + - "package.json" + - "scripts/**" + - "**/*.{yml,json,js,ts,tsx,jsx,mjs,cjs,mts,cts}" + +env: + BUN_VERSION: "1.1.27" + +jobs: + prettier-format: + name: prettier-format + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Bun + uses: ./.github/actions/setup-bun + with: + bun-version: ${{ env.BUN_VERSION }} + - name: Zig Format + run: | + bun run prettier:extra + - name: Commit + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "`bun run prettier:extra`" diff --git a/.prettierrc-ci b/.prettierrc-ci deleted file mode 100644 index b9cd5bacb7826..0000000000000 --- a/.prettierrc-ci +++ /dev/null @@ -1,31 +0,0 @@ -{ - "arrowParens": "avoid", - "printWidth": 120, - "trailingComma": "all", - "useTabs": false, - "quoteProps": "preserve", - "plugins": [ - "prettier-plugin-organize-imports" - ], - "overrides": [ - { - "files": [ - ".vscode/*.json" - ], - "options": { - "parser": "jsonc", - "quoteProps": "preserve", - "singleQuote": false, - "trailingComma": "all" - } - }, - { - "files": [ - "*.md" - ], - "options": { - "printWidth": 80 - } - } - ] -} diff --git a/package.json b/package.json index c7292681e6e2a..12022404c5626 100644 --- a/package.json +++ b/package.json @@ -42,16 +42,16 @@ "build:debug-zig-release": "cmake . -DCMAKE_BUILD_TYPE=Release -DZIG_OPTIMIZE=Debug -GNinja -Bbuild-debug-zig-release && ninja -Cbuild-debug-zig-release", "bump": "bun ./scripts/bump.ts", "typecheck": "tsc --noEmit && cd test && bun run typecheck", - "fmt": "prettier --config=.prettierrc-ci --write --cache './{.vscode,src,test,bench,packages/{bun-types,bun-inspector-*,bun-vscode,bun-debug-adapter-protocol}}/**/*.{mjs,ts,tsx,js,jsx}'", + "fmt": "bun run prettier", "fmt:cpp": "bun run clang-format", - "fmt:zig": "bun run zig:fmt", + "fmt:zig": "bun run zig-format", "lint": "eslint './**/*.d.ts' --cache", "lint:fix": "eslint './**/*.d.ts' --cache --fix", - "test": "node scripts/runner.node.mjs ./build/bun-debug", - "test:release": "node scripts/runner.node.mjs ./build-release/bun", + "test": "node scripts/runner.node.mjs --exec-path ./build/debug/bun-debug", + "test:release": "node scripts/runner.node.mjs --exec-path ./build/release/bun", "banned": "bun packages/bun-internal-test/src/linter.ts", "zig": "vendor/zig/zig.exe", - "zig:fmt": "bun run zig fmt src/*.zig src/*/*.zig src/*/*/*.zig src/*/*/*/*.zig", + "zig:fmt": "bun run zig-format", "zig:check": "bun run zig build check --summary new", "zig:check-all": "bun run zig build check-all --summary new", "zig:check-windows": "bun run zig build check-windows --summary new", @@ -59,6 +59,9 @@ "clang-format": "bun run cmake --target clang-format", "clang-format:check": "bun run cmake --target clang-format-check", "zig-format": "bun run cmake --target zig-format", - "zig-format:check": "bun run cmake --target zig-format-check" + "zig-format:check": "bun run cmake --target zig-format-check", + "prettier": "prettier --config=.prettierrc --write --cache './{.vscode,src,test,bench,packages/{bun-types,bun-inspector-*,bun-vscode,bun-debug-adapter-protocol}}/**/*.{mjs,ts,tsx,js,jsx}'", + "prettier:check": "bun run prettier --check", + "prettier:extra": "bun run prettier --plugin=prettier-plugin-organize-imports" } }