Skip to content

Commit 16fe2be

Browse files
Merge pull request #393 from tarunsinghofficial/feat-lint-ci
Added Linting as a part of CI
2 parents f15ab25 + 1956e6e commit 16fe2be

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

.github/workflows/ci.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI and Lint
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
jobs:
8+
lint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: 18
20+
21+
- name: Install dependencies
22+
run: npm ci
23+
24+
- name: Lint changed files
25+
if: github.event_name == 'pull_request'
26+
run: |
27+
git fetch origin ${{ github.base_ref }}
28+
FILES=$(git diff --name-only origin/${{ github.base_ref }} ${{ github.sha }} | grep -E '\.(js|jsx|ts|tsx|html|css)$' || true)
29+
if [ -n "$FILES" ]; then
30+
echo "Linting changed files:"
31+
echo "$FILES"
32+
echo "$FILES" | xargs npx prettier --check
33+
echo "$FILES" | grep -E '\.(js|jsx|ts|tsx)$' | xargs npx eslint || true
34+
else
35+
echo "No relevant files changed."
36+
fi
37+
env:
38+
CI: true

.prettierrc.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
{
2-
"parser": "html"
2+
"semi": true,
3+
"singleQuote": true,
4+
"tabWidth": 2,
5+
"useTabs": false,
6+
"trailingComma": "es5",
7+
"bracketSpacing": true,
8+
"arrowParens": "always",
9+
"printWidth": 80
310
}

0 commit comments

Comments
 (0)