# CI/CD Pipeline Integration — ESLint + Prettier

Source: https://www.geekswithgeeks.com/en/eslint-prettier/eslint-prettier-16

> Add ESLint and Prettier checks to your CI/CD pipeline.

## 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.

```yaml
# .github/workflows/lint.yml
name: Lint & Format Check
on: [pull_request, push]
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '18'
      - 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

**Quiz:** Why run linting in CI?

- [x] To prevent bad code from merging into main.
- [ ] To speed up development.
- [ ] To reduce file size.

*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.
