Skip to content

Split linting and formatting of javascript into separate actions #1

Split linting and formatting of javascript into separate actions

Split linting and formatting of javascript into separate actions #1

name: JavaScript Linter and Formatter
on: push
jobs:
format-lint:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout Code
uses: actions/checkout@v3
# Step 2: Set up Node.js environment
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '14' # Specify your Node.js version
# Step 3: Install Prettier and ESLint globally
- name: Install Prettier
run: |
npm install -g prettier
# Step 4: Run Prettier to format code
- name: Run prettier
run: prettier "**/*.js" --write
# Step 5: Run Prettier to format code
- name: Run git diff to see the changes that would be made
run: git diff
# Step 6: Run Prettier to format code
- name: Reset git files
run: git reset --hard
# Step 7: Run Prettier to format code
- name: Run Check should fail if formatting is not up to spec
run: prettier --check "**/*.js"
# Step 9: Report status
- name: Complete
run: echo "Formatting completed successfully!"