| name: ESLint Code Quality Checks |
|
|
| on: |
| pull_request: |
| branches: |
| - main |
| - dev |
| - release/* |
| paths: |
| - 'api/**' |
| - 'client/**' |
|
|
| jobs: |
| eslint_checks: |
| name: Run ESLint Linting |
| runs-on: ubuntu-latest |
| permissions: |
| contents: read |
| security-events: write |
| actions: read |
| steps: |
| - name: Checkout repository |
| uses: actions/checkout@v4 |
| with: |
| fetch-depth: 0 |
|
|
| - name: Set up Node.js 20.x |
| uses: actions/setup-node@v4 |
| with: |
| node-version: 20 |
| cache: npm |
|
|
| - name: Install dependencies |
| run: npm ci |
|
|
| |
| - name: Run ESLint on changed files |
| run: | |
| # Extract the base commit SHA from the pull_request event payload. |
| BASE_SHA=$(jq --raw-output .pull_request.base.sha "$GITHUB_EVENT_PATH") |
| echo "Base commit SHA: $BASE_SHA" |
| |
| |
| CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB "$BASE_SHA" HEAD | grep -E '^(api|client)/.*\.(js|jsx|ts|tsx)$' || true) |
|
|
| |
| echo "Changed files:" |
| echo "$CHANGED_FILES" |
|
|
| |
| if [[ -z "$CHANGED_FILES" ]]; then |
| echo "No matching files changed. Skipping ESLint." |
| exit 0 |
| fi |
|
|
| |
| npx eslint --no-error-on-unmatched-pattern \ |
| --config eslint.config.mjs \ |
| $CHANGED_FILES |