|
| 1 | +# Copilot Instructions |
| 2 | + |
| 3 | +Digma UI is a React-based frontend for the Digma continuous feedback platform, designed to help developers analyze and improve code quality and runtime behavior. The project is a monorepo for multiple React applications and provides the distributions for different platforms: Web and IDEs (JetBrains, Visual Studio and VS Code) |
| 4 | + |
| 5 | +Tech stack: TypeScript, React, React Router, Tanstack Table, React Hook Form, Recharts, styled-components, RTK Query, zustand (deprecated), axios, Storybook, Jest, Webpack, ESLint. |
| 6 | + |
| 7 | +## Project Structure |
| 8 | + |
| 9 | +- **.github/** |
| 10 | + GitHub-specific files such as workflows |
| 11 | + |
| 12 | +- **scripts/** |
| 13 | + Utility scripts for development, build, and CI/CD automation. |
| 14 | + |
| 15 | +- **.husky/** |
| 16 | + Git hooks managed by Husky for enforcing code quality and workflow automation. |
| 17 | + |
| 18 | +- **.storybook/** |
| 19 | + Storybook configuration files for UI component development and documentation. |
| 20 | + |
| 21 | +- **.vscode/** |
| 22 | + Visual Studio Code workspace settings and recommended extensions. |
| 23 | + |
| 24 | +- **src/** |
| 25 | + Main source code for the Digma UI applications, including all React components, features, hooks, utilities, and configuration. |
| 26 | + |
| 27 | +- **src/components/** |
| 28 | + Shared, reusable React components used across features and apps. |
| 29 | + |
| 30 | +- **src/api/** |
| 31 | + Contains custom message API-related code, including service definitions, types, and API clients for communicating with backend services. |
| 32 | + |
| 33 | +- **src/containers/** |
| 34 | + Entry points for React applications. |
| 35 | + |
| 36 | +- **src/history/** |
| 37 | + Custom container for application history state management. |
| 38 | + |
| 39 | +- **src/hooks/** |
| 40 | + Custom React hooks for shared logic across the applications. |
| 41 | + |
| 42 | +- **src/logging/** |
| 43 | + Logger for application events and errors. |
| 44 | + |
| 45 | +- **src/redux/** |
| 46 | + Redux store configuration, slices, and RTK Query services. |
| 47 | + |
| 48 | +- **src/store/** |
| 49 | + Zustand stores and state management logic (deprecated). |
| 50 | + |
| 51 | +- **src/stories/** |
| 52 | + Storybook stories for UI components. |
| 53 | + |
| 54 | +- **src/typeGuards/** |
| 55 | + TypeScript type guard functions for runtime type checking. |
| 56 | + |
| 57 | +- **src/utils/** |
| 58 | + General utility functions and helpers used throughout the project. |
| 59 | + |
| 60 | +- **public/** |
| 61 | + Static assets served by the app (e.g., images, fonts). |
| 62 | + |
| 63 | +- **apps.ts** |
| 64 | + Entry points and configuration for each distributive. |
| 65 | + |
| 66 | +## Code Style |
| 67 | + |
| 68 | +### JavaScript/TypeScript |
| 69 | + |
| 70 | +- Use Boolean() constructor instead of !! operator for boolean casting. |
| 71 | +- Follow the ESLint rules from `eslint.config.mjs`. |
| 72 | + |
| 73 | +### TypeScript |
| 74 | + |
| 75 | +- Use `import type` for all type-only imports. |
| 76 | +- Define all type definitions and props in a `types.ts` file. |
| 77 | + |
| 78 | +### React |
| 79 | + |
| 80 | +- Each React component should reside in its own folder under the relevant feature/component directory. |
| 81 | +- The main component file must be named `[Component]/index.tsx`. |
| 82 | +- Do not import React at the top of files for JSX usage (React 18+). |
| 83 | +- Do not import the React namespace unless it is actually needed (e.g., for types or APIs not available via direct import). |
| 84 | +- Use implicit return for functional components when possible. |
| 85 | +- Destructure component props in the function signature. |
| 86 | + |
| 87 | +### Styles |
| 88 | + |
| 89 | +- Import styles as: `import * as s from "./styles"`. |
| 90 | +- Use a `styles.ts` file for styled-components definitions. |
| 91 | +- The top-level styled component should be named `Container`. |
| 92 | +- Do not use inline styles; use props with semantic names instead. |
| 93 | +- Do not use the `font-family` CSS rule for `SF Pro Text` (treat as the default OS font). Only specify `font-family` if a non-default font is required. |
| 94 | +- Use semantic color tokens from the theme (e.g., `theme.colors.v3.surface.primary`) instead of hardcoded color values or direct palette imports. |
| 95 | +- Use typography mixins from `typographies.ts` wherever Figma specifies a typography variable. Do not hardcode font-size, font-weight, or line-height if a corresponding typography token exists. |
| 96 | +- Avoid hardcoded colors, font sizes, and font weights if a semantic or design token exists. |
| 97 | +- All styled-components should use theme values via the `theme` prop for colors and typography, ensuring support for both dark and light themes. |
| 98 | +- Do not use inline types for styled-components. Always create and import interfaces for props used in styled-components from the component's `types.ts` file. |
| 99 | +- Do not use className prop without the need |
| 100 | +- Follow Stylelint rules for all CSS/styled-components code from `stylelint.config.js`. |
| 101 | + |
| 102 | +### Images |
| 103 | + |
| 104 | +- Use standard `<img>` tags for images, styled via styled-components if needed. |
| 105 | + |
| 106 | +### Storybook & Tests |
| 107 | + |
| 108 | +- Create a Storybook file named `[Component].stories.tsx` for stories. |
| 109 | +- Create a test file named `[Component].test.tsx` for tests. |
0 commit comments