Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Linting as a part of CI #393

Merged
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI and Lint

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18

- name: Install dependencies
run: npm ci

- name: Run Prettier
run: npm run lint:prettier

- name: Lint changed files
mjwilson-google marked this conversation as resolved.
Show resolved Hide resolved
if: github.event_name == 'pull_request'
mjwilson-google marked this conversation as resolved.
Show resolved Hide resolved
run: |
git fetch origin ${{ github.base_ref }}
FILES=$(git diff --name-only origin/${{ github.base_ref }} ${{ github.sha }} | grep -E '\.(js|jsx|ts|tsx|html|css)$' || true)
if [ -n "$FILES" ]; then
echo "Linting changed files:"
echo "$FILES"
echo "$FILES" | xargs npx prettier --check
echo "$FILES" | grep -E '\.(js|jsx|ts|tsx)$' | xargs npx eslint || true
else
echo "No relevant files changed."
fi
env:
CI: true
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Package Managers
mjwilson-google marked this conversation as resolved.
Show resolved Hide resolved
# package-lock.json
# pnpm-lock.yaml
# yarn.lock
9 changes: 8 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{
"parser": "html"
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"useTabs": false,
"trailingComma": "es5",
"bracketSpacing": true,
"arrowParens": "always",
"printWidth": 80
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"start:eleventy": "eleventy --serve",
"start:postcss": "postcss src/styles/*.css --dir _site --watch",
"format": "npx eslint --fix _site/audio-worklet/**/*.js && npx prettier --write --loglevel silent _site/audio-worklet/**/*.html",
"lint:prettier": "prettier --check src/**/*.js src/**/*.html",
mjwilson-google marked this conversation as resolved.
Show resolved Hide resolved
"lint:eslint": "eslint src/**/*.js",
"test": "npx playwright test",
"test-server": "npx http-server",
"test-live": "npx http-server ./src/tests/playwright/pages/"
Expand Down