# Contributing to Konflux UI Thanks for your interest in contributing to **Konflux UI**! πŸŽ‰ This document will help you get started with contributing code, documentation, or ideas. --- ## How to Contribute We welcome contributions of all kinds! Follow these steps to get started: 1. Fork the repository and create your branch from `main`. 2. Enable Corepack and install dependencies: ```bash # Enable Corepack (required for Yarn Berry) corepack enable # Install dependencies in the root directory yarn install # Install e2e-tests dependencies cd e2e-tests && yarn install && cd .. ``` > **Note:** This project uses [Yarn Berry (v4.x)](https://yarnpkg.com/). The correct version is automatically managed via Corepack. 3. Make sure your code builds and passes all checks: - Lint (`yarn lint`) - Type check (`yarn tsc`) - Tests (`yarn test`) > Tip: By default, ESLint errors from `.eslintrc.restrict-imports.cjs` won’t show up in the VSCode UI. To see them in the editor, you can add the following to your local .vscode/settings.json: > > ```json > "eslint.options": { > "overrideConfigFile": ".eslintrc.restrict-imports.cjs" > } > ``` 4. Write or update tests: - Use [Jest](https://jestjs.io/) for unit tests. - Add tests for new components, utility functions, or any logic added/changed. - When fixing bugs or refactoring code, consider whether a new test would help prevent regressions. - We use [Codecov](https://app.codecov.io/gh/konflux-ci/konflux-ui) to track test coverage and aim to maintain at least **80% coverage**. - Pull Requests that significantly reduce coverage may be asked to add more tests. - If your changes impact end-to-end behavior or UI flows, consider updating or adding to the e2e tests located in the `e2e-tests/` folder. For guidance on contributing to e2e tests, please refer to the [e2e-tests/README.md](e2e-tests/README.md) documentation. 5. Use feature flags when needed: - If you're contributing a feature that is not yet fully implemented or will be completed in follow-up PRs, please wrap it with a feature flag. - Refer to our [feature flags guide](./docs/feature-flags.md) for more information. 6. For new features or changes that affect the UI/UX, open a GitHub Issue first to discuss the approach. This avoids wasted effort - significant changes made without prior discussion may be rejected during review. 7. Submit a Pull Request following our [PR template](.github/PULL_REQUEST_TEMPLATE.md). The template includes required fields such as: - **Fixes**: include references to related issues, if applicable - **Description**: clear overview of what was changed and **why** β€” demonstrate understanding of the problem, not just what the diff contains - **Screenshots**: required for any UI changes - **How to test or reproduce**: how to verify the change > Tip: If your PR is still a work in progress and not ready for review, mark it as a draft to let others know that it's not ready for approval yet. 8. Tag reviewers in your Pull Request: - Please tag at least one or two active maintainers who are responsible for reviewing PRs. - You can also tag the [konflux-ui team](https://github.com/orgs/konflux-ci/teams/konflux-ui) for broader visibility if needed. - If you’re unsure who to tag, check recent contributors. - The reviewer reviews the code. If the code is safe to run, reviewer may add `ok-to-test` label to enable the E2E tests on this PR. 9. Once your PR is ready: - βœ… Ensure tests pass and all required checks are green. > Tip: You or someone with the write permissions to the repository can re-run failing GitHub Action "PR Check Test" in the job's web page. Others have to update their branch to trigger the job. - βœ… Get at least **2 approvals** from reviewers. - βœ… Make sure there are no pending **requested changes**. After that, you (or someone with write access) can add the PR to the **merge queue** for merging. Please ensure your PR is complete and clear β€” this helps reviewers respond faster. --- ## Git hooks and local checks Commits are enforced by **Husky** (installed via `yarn install` β†’ `prepare` script): - **pre-commit:** auto-format staged files via `lint-staged` (Prettier, ESLint restricted imports, Stylelint); block deletion or rename of protected repo files - **pre-push:** block force push and branch deletion on `main` / `master` ### Protected repo files The pre-commit hook refuses to commit **deletions or renames** (source or destination) of infrastructure files that are easy for agents or bulk edits to remove by mistake. Content edits are not blocked. | Path | Rationale | | ----------------------------------------------------------- | ------------------------------------------------------------------------ | | `.husky/pre-commit`, `.husky/commit-msg`, `.husky/pre-push` | Git hooks; deletion disables local checks | | `package.json`, `yarn.lock` | Dependency and script definitions; deletion breaks installs and CI | | `.gitignore` | Prevents accidental commits of build artifacts, secrets, or local config | | `AGENTS.md` | Canonical AI agent instructions (`CLAUDE.md` is a symlink to this file) | | `setup.sh` | Documented onboarding entry point (also invoked by `yarn setup`) | **Legitimate deletion or rename:** set `SKIP_PROTECTED_PATH_CHECK=1` for that commit only, after maintainer agreement: ```bash SKIP_PROTECTED_PATH_CHECK=1 git commit -m "chore: remove setup.sh" ``` Do not use `--no-verify`; that skips lint-staged and other pre-commit checks too. **Maintenance:** when adding a new repo-critical file that should never be deleted casually, add a pattern to `is_protected_path` in `.husky/pre-commit` and add a row to the table above in the same PR. --- ## Development Environment - For detailed instructions on how to build and run the project, refer to the [README](./README.md). - We support [Dev Containers](https://containers.dev/) for a simplified setup process. If you're using VS Code, the project will automatically configure your environment using the files in [`.devcontainer`](./.devcontainer/). Please, refer to our [Dev Containers README](.devcontainer/README.md) for more information. ### Package Manager This project uses **Yarn Berry (v4.x)** as the package manager. Key points: - βœ… Use `yarn` commands (e.g., `yarn lint`, `yarn test`, `yarn tsc`) - ❌ Don't use `npm` commands - The correct Yarn version is specified in `package.json` via the `packageManager` field - [Corepack](https://nodejs.org/api/corepack.html) (included with Node.js 20+) automatically manages the Yarn version **Common Yarn Berry commands:** | Command | Description | | -------------------------- | --------------------------------------------------------- | | `yarn install` | Install dependencies | | `yarn install --immutable` | Install dependencies (CI mode, fails if lockfile changes) | | `yarn add ` | Add a dependency | | `yarn add -D ` | Add a dev dependency | | `yarn remove ` | Remove a dependency | --- ## Project Structure and Conventions To keep the codebase maintainable and consistent, please follow the conventions below when contributing. ### File Structure Overview | Folder | Purpose | | ---------------------- | ------------------------------------------------------------------------------------------------- | | `src/components/` | Feature-specific components, typically tied to a page or domain logic. | | `src/shared/` | Generic, reusable code such as components, hooks, and utilities with little to no business logic. | | `src/hooks/` | Custom React hooks for logic reuse (e.g. API calls). | | `src/utils/` | Utility functions | | `src/consts/` | Shared constants, enums. | | `src/feature-flags/` | Logic for managing and checking feature flags. | | `src/routes/` | Route definitions and related layout/wrapper logic. | | `src/types/` | Shared TypeScript types and interfaces used across the app. | | `src/unit-test-utils/` | Testing utilities and helper functions for unit tests. | | `src/kubearchive/` | Specific integrations and logic related to KubeArchive. | ### Styling Guidelines - Use [PatternFly](https://www.patternfly.org/) components and utility classes whenever possible. - βœ… Example (good): ```tsx ``` - ❌ Avoid custom-styled buttons like: ```tsx ``` - Avoid adding custom CSS unless strictly necessary. - If custom styles are required: - βœ… **Prefer class-based styling** over inline styles: ```tsx
Content
``` ```css .action-menu-container { display: flex; justify-content: flex-end; } ``` - ❌ Avoid: ```tsx
Content
``` - βœ… **Scope styles locally and place them alongside the component**: - Place styles in a local SCSS module file (e.g. `MyComponent.scss`) in the same folder as the component. - Use clear, prefixed class names following the [BEM naming convention](https://getbem.com/naming/) to avoid conflicts and maintain modularity. ### Import Guidelines Use absolute imports for paths under src/ whenever possible to improve readability and avoid relative paths. - ❌ Instead of: ```tsx import { FilterContext } from '../../../components/Filter/generic/FilterContext'; ``` - βœ… Prefer: ```tsx import { FilterContext } from '~/components/Filter/generic/FilterContext'; ``` Commonly used aliases: ```txt ~/components ~/types ~/k8s ~/utils ``` --- ## Commit Guidelines - Use descriptive commit messages (e.g., `fix: resolve alignment issue in table header`). - Follow [Conventional Commits](https://www.conventionalcommits.org/) if possible (e.g., `feat: add dark mode support`). ### AI-Assisted Contributions We welcome the use of AI tools to speed up development, but contributors are fully responsible for the quality of their PRs. AI-generated code is held to the same standard as human-written code. **Expectations:** - You **must review and understand** any AI-generated code before submitting. "The AI wrote it" is not an acceptable explanation during review. - **Tests are mandatory** β€” submitting AI-generated code without tests signals that the contributor did not verify behavior. - **Commit messages must be meaningful** - no verbose, auto-generated descriptions. Follow Conventional Commits as described above. - **No AI-generated text** in PR comments, issue discussions, or review responses. - **No bulk AI refactors** (mass renames, restructures, style changes) without prior discussion via a GitHub Issue. - Low-effort or un-reviewed AI-generated PRs **will be closed**. **Attribution:** Add an `Assisted-by: ` trailer to commits that used AI assistance. For example: _Assisted-by: Cursor_ **Loading project rules into AI tools:** Project-wide agent instructions live in [`AGENTS.md`](AGENTS.md); `CLAUDE.md` points to the same file. Shared repository skills live in [`.agents/skills/`](.agents/skills/). Create new skills and edit existing ones there. The `.claude/skills/` and `.cursor/skills/` paths are symlinks for tool discovery; do not edit skills through those paths. Some configuration remains tool-specific, including [`.cursor/rules/`](.cursor/rules/) and `.claude/commands/`. Keep shared skill instructions provider-neutral, and label setup steps that apply only to a particular tool. Check the active tool's documentation for any additional setup needed to load project instructions and skills. --- ## Reporting Issues If you find a bug or have a feature request: - Check if it’s already reported. - If not, [open a new issue](https://github.com/konflux-ci/konflux-ui/issues/new). - Please include steps to reproduce, screenshots (if UI-related), and relevant logs. --- ## Questions? Feel free to reach out via [GitHub Issues](https://github.com/konflux-ci/konflux-ui/issues). Happy coding! πŸ’™