SkillByAIOpen interactive version →

Lesson 16 / 27

CI/CD Pipeline Integration

Fail pull requests that break lint or format checks by running ESLint and Prettier in GitHub Actions.

Pipeline enforcement

Running checks in CI prevents bad code from merging. GitHub Actions, GitLab CI, and Jenkins all support ESLint. Fail the build if linting fails.

GitHub Actions workflow

Add a workflow file to lint and format-check on pull requests.

# .github/workflows/lint.yml
name: Lint & Format Check
on: [pull_request, push]
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: npm
      - run: npm ci
      - run: npm run lint
      - run: npx prettier --check .

Output:

Linting and format checks pass on CI

Separate checks for clarity

Run lint and format checks separately in CI (different job steps). This makes it clear which check failed and helps team debug issues faster.

Quick check

Quick check: Why run linting in CI?

  • To speed up development.
  • To prevent bad code from merging into main.
  • To reduce file size.
  • To shorten file names
Answer

To prevent bad code from merging into main. — CI linting is a safety net that catches issues automated tools might miss and enforces standards.