-
Notifications
You must be signed in to change notification settings - Fork 69
chore(Copilot) Adds copilot instructions #3042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TheSonOfThomp
wants to merge
2
commits into
main
Choose a base branch
from
a/copilot-instructions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,205 @@ | ||||||
# LeafyGreen UI - Copilot Instructions | ||||||
|
||||||
This document provides comprehensive guidance for coding agents working on the LeafyGreen UI design system repository. Following these instructions will minimize build failures, validation errors, and rejected pull requests. | ||||||
|
||||||
## Repository Overview | ||||||
|
||||||
LeafyGreen UI is MongoDB's React component library and design system consisting of: | ||||||
|
||||||
- **100+ workspace packages** across 4 scopes: `@leafygreen-ui`, `@lg-charts`, `@lg-chat`, and `@lg-tools` | ||||||
- **Languages/Frameworks**: TypeScript, React 18, Emotion (CSS-in-JS), Storybook | ||||||
- **Build System**: Turbo monorepo with pnpm workspaces | ||||||
|
||||||
### Project Structure | ||||||
|
||||||
``` | ||||||
leafygreen-ui/ | ||||||
├── packages/ # @leafygreen-ui core components (button, modal, etc.) | ||||||
├── charts/ # @lg-charts data visualization components | ||||||
├── chat/ # @lg-chat conversational UI components | ||||||
├── tools/ # @lg-tools build system, CLI, linting, etc. | ||||||
├── stories/ # Storybook files unrelated to a specific component | ||||||
└── scripts/ # Repository maintenance scripts | ||||||
``` | ||||||
|
||||||
## Build System & Development Commands | ||||||
|
||||||
### Required Environment | ||||||
|
||||||
Refer to `package.json` for the required Node and pnpm versions. | ||||||
|
||||||
MUST use pnpm, not npm or yarn | ||||||
|
||||||
### Development Workflow & Commands | ||||||
|
||||||
Follow this workflow for all development tasks: | ||||||
|
||||||
1. **Initial Setup** (required after clone or when switching branches): | ||||||
|
||||||
```bash | ||||||
pnpm run init # Installs dependencies and builds all packages | ||||||
``` | ||||||
|
||||||
- ALWAYS run this before any development work | ||||||
|
||||||
2. **Making Changes**: | ||||||
|
||||||
- Edit component files in `src/` | ||||||
- Add/update tests in `.spec.tsx` files | ||||||
- Update stories in `.stories.tsx` files | ||||||
|
||||||
3. **Development Commands**: | ||||||
|
||||||
```bash | ||||||
# Build all packages (uses Turbo, typically 6-10 seconds with cache) | ||||||
pnpm build | ||||||
|
||||||
# Start Storybook for development | ||||||
pnpm start # Starts on port 9001 | ||||||
|
||||||
# Run tests | ||||||
pnpm test # All tests | ||||||
pnpm test --filter="@leafygreen-ui/*" # Specific scope | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops just noticed this
Suggested change
|
||||||
|
||||||
# Linting | ||||||
pnpm lint # Check only | ||||||
pnpm run fix # Auto-fix issues | ||||||
``` | ||||||
|
||||||
4. **Before Committing**: | ||||||
|
||||||
```bash | ||||||
pnpm build # Ensure builds pass | ||||||
pnpm lint # Check for issues | ||||||
pnpm test # Run test suite | ||||||
pnpm changeset # Document changes for release | ||||||
``` | ||||||
|
||||||
- **CRITICAL**: Always use `pnpm run fix` instead of manual formatting fixes | ||||||
- Runs ESLint, Prettier, and npmPkgJsonLint | ||||||
|
||||||
5. **PR Submission**: | ||||||
- All checks must pass in CI | ||||||
- Include meaningful test coverage | ||||||
- Update documentation as needed | ||||||
|
||||||
### Package-Level Commands | ||||||
|
||||||
Each package supports these scripts (defined in individual `package.json`): | ||||||
|
||||||
```json | ||||||
{ | ||||||
"scripts": { | ||||||
"build": "lg-build bundle", | ||||||
"tsc": "lg-build tsc", | ||||||
"docs": "lg-build docs" | ||||||
} | ||||||
} | ||||||
``` | ||||||
|
||||||
## Validation Pipeline | ||||||
|
||||||
The CI/CD system runs validations on every PR | ||||||
|
||||||
For regular PRs, refer to `.github/workflows/pr.yml` | ||||||
|
||||||
### PR Requirements | ||||||
|
||||||
Refer to `.github/pull_request_template.md` for PR requirements | ||||||
|
||||||
## Package Development Guidelines | ||||||
|
||||||
### Creating New Components | ||||||
|
||||||
```bash | ||||||
pnpm create-package my-new-component | ||||||
``` | ||||||
|
||||||
This scaffolds: | ||||||
|
||||||
- Package structure with TypeScript configs | ||||||
- Test setup with Jest/React Testing Library | ||||||
- Storybook stories | ||||||
- Build configuration | ||||||
|
||||||
### Package Structure | ||||||
|
||||||
Each package follows this structure: | ||||||
|
||||||
``` | ||||||
packages/component-name/ | ||||||
├── src/ | ||||||
│ ├── Component/ | ||||||
│ │ ├── Component.tsx | ||||||
│ │ ├── Component.styles.ts | ||||||
│ │ ├── Component.spec.tsx | ||||||
│ │ └── index.ts | ||||||
│ ├── Component.stories.tsx | ||||||
│ ├── index.ts | ||||||
│ └── types.ts | ||||||
├── package.json | ||||||
├── README.md | ||||||
└── CHANGELOG.md | ||||||
``` | ||||||
|
||||||
### Workspace Dependencies | ||||||
|
||||||
- Use `workspace:^` for internal dependencies (Example: `"@leafygreen-ui/palette": "workspace:^"`) | ||||||
- External dependencies use specific versions with caret `^` version notation. | ||||||
- External dependencies in `@lg-tools/*` packages use explicit dependency versions (with no caret `^` or tilde `~`) | ||||||
|
||||||
### TypeScript Configuration | ||||||
|
||||||
- Extends `@lg-tools/build/config/package.tsconfig.json` | ||||||
- Path mapping configured in root `tsconfig.json`: | ||||||
```json | ||||||
{ | ||||||
"paths": { | ||||||
"@leafygreen-ui/*": ["packages/*/src"], | ||||||
"@lg-charts/*": ["charts/*/src"], | ||||||
"@lg-chat/*": ["chat/*/src"], | ||||||
"@lg-tools/*": ["tools/*/src"] | ||||||
} | ||||||
} | ||||||
``` | ||||||
|
||||||
## File Locations & Configurations | ||||||
|
||||||
### Key Configuration Files | ||||||
|
||||||
- `eslint.config.mjs` - Linting rules (extends `@lg-tools/lint`) | ||||||
- `prettier.config.js` - Code formatting (extends `@lg-tools/lint`) | ||||||
- `turbo.json` - Build orchestration | ||||||
- `tsconfig.json` - TypeScript path mapping and compilation | ||||||
- `.github/workflows/` - CI/CD pipeline definitions | ||||||
|
||||||
### Build Tools | ||||||
|
||||||
- **Main CLI**: `@lg-tools/cli` provides `lg` command | ||||||
- **Build System**: `@lg-tools/build` provides `lg-build` commands | ||||||
- **Validation**: `@lg-tools/validate` checks dependencies and structure | ||||||
- **Testing**: `@lg-tools/test` provides Jest configuration | ||||||
|
||||||
## Performance Notes | ||||||
|
||||||
- **Build caching**: Turbo extensively caches builds - clean cache if issues arise | ||||||
- **Icon package**: Has special build caching due to SVG generation complexity | ||||||
- **Storybook**: Large application - expect 30+ second build times | ||||||
|
||||||
## Code Style guide | ||||||
|
||||||
Refer to `STYLEGUIDE.md` for code style guidelines | ||||||
|
||||||
## Additional instructions | ||||||
|
||||||
- For Storybook files `**/*.stories.ts`, do not comment on the inclusion of `console` logs. | ||||||
|
||||||
## Trust These Instructions | ||||||
|
||||||
These instructions are based on comprehensive exploration and testing of the actual codebase. Only search for additional information if: | ||||||
|
||||||
- These instructions are incomplete for your specific task | ||||||
- You encounter errors not covered in the troubleshooting section | ||||||
- The codebase has changed since these instructions were created | ||||||
|
||||||
**Always prefer following these established patterns over creating new approaches.** |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.