Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@

"env": {
"test": {
"presets": [
[
"@babel/preset-env"
]
],
"presets": [["@babel/preset-env"]],
"plugins": []
},
},
}
}
}
66 changes: 66 additions & 0 deletions .github/workflows/format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Format Code with Prettier

on:
pull_request:
branches:
- main
push:
branches:
- main

permissions:
contents: write

jobs:
prettier:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref }}
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Check Prettier formatting
id: prettier-check
run: |
if prettier --check .; then
echo "needs_formatting=false" >> $GITHUB_OUTPUT
echo "✅ Code is already formatted"
exit 0
else
echo "needs_formatting=true" >> $GITHUB_OUTPUT
echo "❌ Code needs formatting"
exit 1
fi
continue-on-error: true

- name: Run Prettier
if: steps.prettier-check.outputs.needs_formatting == 'true'
run: npx prettier --write .

- name: Commit and push formatted code
if: steps.prettier-check.outputs.needs_formatting == 'true' && github.event_name == 'push'
run: |
# Configure git user
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

# Stage changes
git add .

# Only commit if there are changes
if [ -n "$(git diff --cached)" ]; then
git commit -m "chore: format code with Prettier [skip ci]"
git push
else
echo "🎉 No formatting changes to commit."
fi
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install dependencies
run: npm ci --no-audit
- name: Test
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"semi": true,
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"bracketSpacing": true,
"arrowParens": "avoid"
}
Loading