Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/lint-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI - Lint and Build

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint-and-build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
run: npm ci

- name: Run Linting
run: npm run lint

- name: Run Tests
run: npm test

- name: Run Tests with Coverage
run: npm run test:coverage

- name: Build the Project
run: npm run build
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This is a thin frontend UI for [Kaapi backend](https://github.com/ProjectTech4De
- [Installation](#installation)
- [Start frontend server](#start-frontend-server)
- [Available Scripts](#available-scripts)
- [Pre-commit Hooks](#pre-commit-hooks)
- [Deploying Release on EC2 with CD](#deploying-release-on-ec2-with-cd)
- [Learn More](#learn-more)

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

```bash
npm install # Install dependencies
npm install # Install dependencies (also sets up pre-commit hooks via husky)
npm run dev # Run app in development mode
npm run build # Create optimized production build
npm run start # Start the production server
npm run lint # Run ESLint
npm run lint # Run ESLint on the entire project
npm test # Run tests
npm run test:coverage # Run tests with coverage report
```

---

## Pre-commit Hooks

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.

### What runs on commit

- **ESLint** is executed on all staged `*.ts`, `*.tsx`, `*.js`, and `*.jsx` files. Any lint errors must be fixed before the commit is accepted.

### Setup

Hooks are installed automatically when you run:

```bash
npm install
```

This works because the `prepare` script in `package.json` runs `husky` after every install.

### Skipping the hook (not recommended)

If you need to bypass the hook in exceptional cases:

```bash
git commit --no-verify -m "your message"
```

---
Expand Down
2 changes: 1 addition & 1 deletion app/components/prompt-editor/DiffView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react';
import { useMemo } from 'react';
import { colors } from '@/app/lib/colors';
import PromptDiffPane from './PromptDiffPane';
import ConfigDiffPane from './ConfigDiffPane';
Expand Down
2 changes: 1 addition & 1 deletion app/knowledge-base/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default function KnowledgeBasePage() {
jobStatusMap: Map<string, { status: string | null; collectionId: string | null }>
): Promise<Collection> => {
// First try to look up cached data by collection_id
let cached = getCollectionDataByCollectionId(collection.id);
const cached = getCollectionDataByCollectionId(collection.id);

let jobId = cached.job_id;
let collectionJobStatus = null;
Expand Down
14 changes: 14 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,21 @@ const eslintConfig = defineConfig([
"out/**",
"build/**",
"next-env.d.ts",
// Generated files:
"coverage/**",
]),
{
rules: {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"no-unused-vars": "off", // use @typescript-eslint/no-unused-vars instead
"react/no-unescaped-entities": "error",
"no-duplicate-imports": "error",
"prefer-const": "error",
"no-var": "error",
"no-console": ["warn", { allow: ["warn", "error"] }],
},
},
]);

export default eslintConfig;
11 changes: 0 additions & 11 deletions eslint.config.mts

This file was deleted.

201 changes: 201 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
/**
* For a detailed explanation regarding each configuration property, visit:
* https://jestjs.io/docs/configuration
*/

import type {Config} from 'jest';

const config: Config = {
// All imported modules in your tests should be mocked automatically
// automock: false,

// Stop running tests after `n` failures
// bail: 0,

// The directory where Jest should store its cached dependency information
// cacheDirectory: "/private/var/folders/cc/8388wf8n00l9fvmjq8b2z5h00000gn/T/jest_dx",

// Automatically clear mock calls, instances, contexts and results before every test
clearMocks: true,

// Indicates whether the coverage information should be collected while executing the test
collectCoverage: true,

// An array of glob patterns indicating a set of files for which coverage information should be collected
// collectCoverageFrom: undefined,

// The directory where Jest should output its coverage files
coverageDirectory: "coverage",

// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "/node_modules/"
// ],

// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8",

// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
// "json",
// "text",
// "lcov",
// "clover"
// ],

// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: undefined,

// A path to a custom dependency extractor
// dependencyExtractor: undefined,

// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,

// The default configuration for fake timers
// fakeTimers: {
// "enableGlobally": false
// },

// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],

// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: undefined,

// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: undefined,

// A set of global variables that need to be available in all test environments
// globals: {},

// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
// maxWorkers: "50%",

// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],

// An array of file extensions your modules use
// moduleFileExtensions: [
// "js",
// "mjs",
// "cjs",
// "jsx",
// "ts",
// "mts",
// "cts",
// "tsx",
// "json",
// "node"
// ],

// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
// moduleNameMapper: {},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],

// Activates notifications for test results
// notify: false,

// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",

// A preset that is used as a base for Jest's configuration
// preset: undefined,

// Run tests from one or more projects
// projects: undefined,

// Use this configuration option to add custom reporters to Jest
// reporters: undefined,

// Automatically reset mock state before every test
// resetMocks: false,

// Reset the module registry before running each individual test
// resetModules: false,

// A path to a custom resolver
// resolver: undefined,

// Automatically restore mock state and implementation before every test
// restoreMocks: false,

// The root directory that Jest should scan for tests and modules within
// rootDir: undefined,

// A list of paths to directories that Jest should use to search for files in
// roots: [
// "<rootDir>"
// ],

// Allows you to use a custom runner instead of Jest's default test runner
// runner: "jest-runner",

// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],

// The number of seconds after which a test is considered as slow and reported as such in the results.
// slowTestThreshold: 5,

// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],

// The test environment that will be used for testing
// testEnvironment: "jest-environment-node",

// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},

// Adds a location field to test results
// testLocationInResults: false,

// The glob patterns Jest uses to detect test files
// testMatch: [
// "**/__tests__/**/*.?([mc])[jt]s?(x)",
// "**/?(*.)+(spec|test).?([mc])[jt]s?(x)"
// ],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],

// This option allows the use of a custom results processor
// testResultsProcessor: undefined,

// This option allows use of a custom test runner
// testRunner: "jest-circus/runner",

// A map from regular expressions to paths to transformers
// transform: undefined,

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/",
// "\\.pnp\\.[^\\/]+$"
// ],

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,

// Indicates whether each individual test should be reported during the run
// verbose: undefined,

// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],

// Whether to use watchman for file crawling
// watchman: true,
};

export default config;
Loading
Loading