Skip to content

Commit 4abd0b9

Browse files
authored
Merge pull request #137 from code-soubhik/feat/test
Integrate ESLint with Husky for Pre-commit Hook, Add Vitest for UI & API Test Cases
2 parents 9b8adc7 + e9d0dd1 commit 4abd0b9

30 files changed

Lines changed: 3745 additions & 1409 deletions

.husky/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
npm run lint-fix
2+
npm run test

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ npm run start
6262

6363
```bash
6464
git add .
65+
npm run prepare
6566
git commit -m "✨ Added new feature: description (fixes #issue_number)"
6667
git push origin feature/your-feature-name
6768
```

TAILWIND_SETUP.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Your project now has **Tailwind CSS v3** fully configured and production-ready!
2020

2121
```bash
2222
npm install
23+
npm run prepare
2324
```
2425

2526
### 2. Development

api/getGeminiResponse.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,23 @@
22
import { GoogleGenerativeAI } from "@google/generative-ai";
33

44
export default async function handler(req, res) {
5-
if(req.method !== "GET") {
5+
if (req.method !== "GET") {
66
return res.status(405).json({ error: "Method not allowed. Use GET." });
77
}
88
try {
99
const { qcount, category, difficulty } = req.query;
10-
if(!qcount || !category || !difficulty) {
11-
return res.status(400).json({ error: "Missing required query parameters: qcount, category, difficulty" });
10+
if (!qcount || !category || !difficulty) {
11+
return res.status(400).json({
12+
error:
13+
"Missing required query parameters: qcount, category, difficulty",
14+
});
1215
}
1316
const numQuestions = parseInt(qcount, 10);
1417
const selectedCategory = category;
1518
const selectedDifficulty = difficulty;
1619

1720
const apiKey = process.env.GEMINI_API_KEY || null;
1821
if (!apiKey) {
19-
console.error("GEMINI API key not found in process.env");
2022
return res.status(500).json({
2123
error:
2224
"Missing Gemini API key on server. Please set GEMINI_API_KEY in the server environment.",
@@ -63,4 +65,4 @@ export default async function handler(req, res) {
6365
details: error.message,
6466
});
6567
}
66-
};
68+
}

eslint.config.js

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,36 @@
1-
import js from '@eslint/js'
2-
import globals from 'globals'
3-
import reactHooks from 'eslint-plugin-react-hooks'
4-
import reactRefresh from 'eslint-plugin-react-refresh'
5-
import { defineConfig, globalIgnores } from 'eslint/config'
1+
import js from "@eslint/js";
2+
import globals from "globals";
3+
import { defineConfig, globalIgnores } from "eslint/config";
4+
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
5+
// Future scope for additional plugins
6+
// import reactHooks from "eslint-plugin-react-hooks";
7+
// import reactRefresh from "eslint-plugin-react-refresh";
68

79
export default defineConfig([
8-
globalIgnores(['dist']),
10+
globalIgnores(["dist"]),
911
{
10-
files: ['**/*.{js,jsx}'],
12+
files: ["**/*.{js,jsx}"],
1113
extends: [
1214
js.configs.recommended,
13-
reactHooks.configs['recommended-latest'],
14-
reactRefresh.configs.vite,
15+
eslintPluginPrettierRecommended,
16+
// reactHooks.configs["recommended-latest"],
17+
// reactRefresh.configs.vite,
1518
],
1619
languageOptions: {
1720
ecmaVersion: 2020,
18-
globals: globals.browser,
21+
globals: {
22+
...globals.browser,
23+
...globals.node,
24+
myCustomGlobal: "readonly",
25+
},
1926
parserOptions: {
20-
ecmaVersion: 'latest',
27+
ecmaVersion: "latest",
2128
ecmaFeatures: { jsx: true },
22-
sourceType: 'module',
29+
sourceType: "module",
2330
},
2431
},
2532
rules: {
26-
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
33+
"no-unused-vars": ["error", { varsIgnorePattern: "^[A-Z_]" }],
2734
},
2835
},
29-
])
36+
]);

0 commit comments

Comments
 (0)