पाठ 16 / 27
CI/CD Pipeline Integration
GitHub Actions में ESLint और Prettier चलाकर lint या format checks तोड़ने वाले pull requests को fail करें।
Pipeline enforcement
CI में checks चलाना खराब कोड को merge होने से रोकता है। GitHub Actions, GitLab CI, और Jenkins सभी ESLint को support करते हैं। यदि linting fail हो तो build को fail करें।
GitHub Actions workflow
Pull requests पर lint और format-check करने के लिए एक workflow file जोड़ें।
# .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
Clarity के लिए अलग checks
CI में lint और format checks को अलग से चलाएँ (विभिन्न job steps)। यह स्पष्ट करता है कि कौन सी check fail हुई और टीम को issues को तेजी से debug करने में मदद करता है।
त्वरित जाँच
त्वरित जाँच: CI में लinting क्यों चलाएँ?
- Development को speed up करने के लिए।
- खराब कोड को main में merge होने से रोकने के लिए।
- File size को reduce करने के लिए।
- File नाम छोटे करने के लिए
Answer
खराब कोड को main में merge होने से रोकने के लिए। — CI linting एक safety net है जो automated tools द्वारा miss किए जाने वाले issues को पकड़ता है और standards को लागू करता है।