mirror of
https://github.com/horsicq/Detect-It-Easy.git
synced 2026-06-24 01:54:08 +00:00
chore: update prettier config and formatting workflow
This commit is contained in:
parent
16ae70012b
commit
485346bbd1
2 changed files with 26 additions and 17 deletions
30
.github/workflows/format-js.yml
vendored
30
.github/workflows/format-js.yml
vendored
|
|
@ -16,42 +16,48 @@ jobs:
|
|||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets. RELEASE_TOKEN }}
|
||||
token: ${{ secrets. GITHUB_TOKEN }}
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
- name: Setup Node. js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Install Prettier
|
||||
run: npm install -g prettier
|
||||
|
||||
- name: Format JavaScript files in db directories
|
||||
run: |
|
||||
# Find all files (excluding . vscode, _icons, and binary files)
|
||||
# Find all files (excluding .vscode, _icons, and binary files)
|
||||
# Format files that contain JavaScript-like syntax
|
||||
|
||||
find db db_custom db_extra -type f \
|
||||
! -path '*/.vscode/*' \
|
||||
! -path '*/_icons/*' \
|
||||
! -name '*.txt' \
|
||||
! -name '*.txt' \
|
||||
! -name '*.md' \
|
||||
! -name '*.png' \
|
||||
! -name '*.ico' \
|
||||
! -name '*.svg' \
|
||||
-print0 2>/dev/null | while IFS= read -r -d '' file; do
|
||||
# Skip files with beautify ignore comment
|
||||
if grep -q 'beautify ignore: start' "$file" 2>/dev/null; then
|
||||
echo "Skipping (beautify ignore): $file"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Check if file contains JavaScript-like syntax
|
||||
if head -c 1000 "$file" 2>/dev/null | grep -qE '(function|var |if\s*\(|for\s*\(|return |includeScript)'; then
|
||||
echo "Formatting: $file"
|
||||
prettier --write "$file" --parser babel --tab-width 4 --print-width 120 || true
|
||||
echo "Formatting: $file"
|
||||
prettier --write "$file" --parser babel --tab-width 4 --print-width 80 || true
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Check for changes
|
||||
- name: Check for changes
|
||||
id: check_changes
|
||||
run: |
|
||||
if git diff --quiet; then
|
||||
|
|
@ -63,7 +69,7 @@ jobs:
|
|||
- name: Commit and push changes
|
||||
if: steps.check_changes.outputs.has_changes == 'true'
|
||||
run: |
|
||||
git config --local user.email "github-actions[bot]@users. noreply.github.com"
|
||||
git config --local user.email "github-actions[bot]@users.noreply. github.com"
|
||||
git config --local user.name "github-actions[bot]"
|
||||
git add -A
|
||||
git commit -m "style: auto-format JavaScript files in db directories"
|
||||
|
|
|
|||
13
.prettierrc
13
.prettierrc
|
|
@ -1,8 +1,11 @@
|
|||
{
|
||||
"tabWidth": 4,
|
||||
"useTabs": false,
|
||||
"semi": true,
|
||||
"singleQuote": false,
|
||||
"printWidth": 120,
|
||||
"trailingComma": "none"
|
||||
}
|
||||
"semi": true,
|
||||
"singleQuote": false,
|
||||
"printWidth": 80,
|
||||
"trailingComma": "es5",
|
||||
"bracketSpacing": true,
|
||||
"arrowParens": "always",
|
||||
"endOfLine": "auto"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue