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

on:
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: 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
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
}
Loading