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
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI and Lint

on:
push:
branches: [ main, master ]
tarunsinghofficial marked this conversation as resolved.
Show resolved Hide resolved
pull_request:
branches: [ main, master ]
mjwilson-google marked this conversation as resolved.
Show resolved Hide resolved

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: Run ESLint
run: npm run lint:eslint

- 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
29 changes: 28 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
{
"parser": "html"
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"useTabs": true,
mjwilson-google marked this conversation as resolved.
Show resolved Hide resolved
"trailingComma": "es5",
"bracketSpacing": true,
"arrowParens": "always",
"printWidth": 80,
"overrides": [
mjwilson-google marked this conversation as resolved.
Show resolved Hide resolved
{
"files": "*.html",
"options": {
"parser": "html"
}
},
{
"files": "*.js",
"options": {
"parser": "babel"
}
},
{
"files": "*.njk",
mjwilson-google marked this conversation as resolved.
Show resolved Hide resolved
"options": {
"parser": "html"
}
}
]
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,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
2 changes: 1 addition & 1 deletion src/_data/build_info.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"3.2.0","revision":"e45e5d0","lastUpdated":"2024-08-07","copyrightYear":2024}
{"version":"3.2.0","revision":"15af0c2","lastUpdated":"2024-08-20","copyrightYear":2024}