Skip to content

Commit 73bc3ce

Browse files
committed
fix(*): adding the eslint rules and ci pipeline
1 parent 4842903 commit 73bc3ce

File tree

8 files changed

+549
-16
lines changed

8 files changed

+549
-16
lines changed

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

README.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ This is a thin frontend UI for [Kaapi backend](https://github.com/ProjectTech4De
1919
- [Installation](#installation)
2020
- [Start frontend server](#start-frontend-server)
2121
- [Available Scripts](#available-scripts)
22+
- [Pre-commit Hooks](#pre-commit-hooks)
2223
- [Deploying Release on EC2 with CD](#deploying-release-on-ec2-with-cd)
2324
- [Learn More](#learn-more)
2425

@@ -91,11 +92,41 @@ Visit `http://localhost:3000` to open the app.
9192
## Available Scripts
9293

9394
```bash
94-
npm install # Install dependencies
95+
npm install # Install dependencies (also sets up pre-commit hooks via husky)
9596
npm run dev # Run app in development mode
9697
npm run build # Create optimized production build
9798
npm run start # Start the production server
98-
npm run lint # Run ESLint
99+
npm run lint # Run ESLint on the entire project
100+
npm test # Run tests
101+
npm run test:coverage # Run tests with coverage report
102+
```
103+
104+
---
105+
106+
## Pre-commit Hooks
107+
108+
This project uses [Husky](https://typicode.github.io/husky/) and [lint-staged](https://github.com/lint-staged/lint-staged) to enforce code quality before every commit.
109+
110+
### What runs on commit
111+
112+
- **ESLint** is executed on all staged `*.ts`, `*.tsx`, `*.js`, and `*.jsx` files. Any lint errors must be fixed before the commit is accepted.
113+
114+
### Setup
115+
116+
Hooks are installed automatically when you run:
117+
118+
```bash
119+
npm install
120+
```
121+
122+
This works because the `prepare` script in `package.json` runs `husky` after every install.
123+
124+
### Skipping the hook (not recommended)
125+
126+
If you need to bypass the hook in exceptional cases:
127+
128+
```bash
129+
git commit --no-verify -m "your message"
99130
```
100131

101132
---

app/components/prompt-editor/DiffView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useMemo, useEffect } from 'react';
1+
import { useMemo } from 'react';
22
import { colors } from '@/app/lib/colors';
33
import PromptDiffPane from './PromptDiffPane';
44
import ConfigDiffPane from './ConfigDiffPane';

app/knowledge-base/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export default function KnowledgeBasePage() {
124124
jobStatusMap: Map<string, { status: string | null; collectionId: string | null }>
125125
): Promise<Collection> => {
126126
// First try to look up cached data by collection_id
127-
let cached = getCollectionDataByCollectionId(collection.id);
127+
const cached = getCollectionDataByCollectionId(collection.id);
128128

129129
let jobId = cached.job_id;
130130
let collectionJobStatus = null;

eslint.config.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,21 @@ const eslintConfig = defineConfig([
1212
"out/**",
1313
"build/**",
1414
"next-env.d.ts",
15+
// Generated files:
16+
"coverage/**",
1517
]),
18+
{
19+
rules: {
20+
"no-unused-vars": "off",
21+
"@typescript-eslint/no-unused-vars": "error",
22+
"no-unused-vars": "off", // use @typescript-eslint/no-unused-vars instead
23+
"react/no-unescaped-entities": "error",
24+
"no-duplicate-imports": "error",
25+
"prefer-const": "error",
26+
"no-var": "error",
27+
"no-console": ["warn", { allow: ["warn", "error"] }],
28+
},
29+
},
1630
]);
1731

1832
export default eslintConfig;

eslint.config.mts

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)