Skip to content

Commit 1a46698

Browse files
committed
chore: add initial cursor rules [AR-44781]
1 parent 45ed039 commit 1a46698

File tree

7 files changed

+440
-0
lines changed

7 files changed

+440
-0
lines changed

.cursor/rules/checkers.mdc

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
description: How to run tests, linting, and type checking during development
3+
alwaysApply: true
4+
---
5+
6+
# Code Quality Checkers
7+
8+
Run checkers **only on changed files/directories** to keep feedback fast. Run from **workspace root**.
9+
10+
## File/Directory-Specific Commands
11+
12+
### Linting (eslint)
13+
14+
```bash
15+
# Single file
16+
pnpm eslint packages/design-system/src/components/ds-button/ds-button.tsx
17+
18+
# Directory
19+
pnpm eslint packages/eslint-plugin/src/
20+
21+
# With auto-fix
22+
pnpm eslint --fix packages/design-system/src/components/ds-button/
23+
```
24+
25+
### Type Checking (tsc)
26+
27+
TypeScript checks the whole project config, so scope by package:
28+
29+
```bash
30+
# design-system package
31+
pnpm --filter @drivenets/design-system typecheck
32+
33+
# eslint-plugin package
34+
pnpm --filter @drivenets/eslint-plugin-design-system typecheck
35+
36+
# vite-plugin package
37+
pnpm --filter @drivenets/vite-plugin-design-system typecheck
38+
```
39+
40+
### Tests (vitest)
41+
42+
```bash
43+
# Single test file
44+
pnpm --filter @drivenets/design-system test packages/design-system/tests/exports.test.ts --run
45+
46+
# Directory of tests
47+
pnpm --filter @drivenets/eslint-plugin-design-system test src/__tests__/ --run
48+
49+
# Pattern match
50+
pnpm --filter @drivenets/vite-plugin-design-system test --run -t "snapshot"
51+
```
52+
53+
## When to Run What
54+
55+
| Changed | Run |
56+
| -------------------------- | --------------------------------------- |
57+
| `*.test.ts` file | `pnpm --filter <pkg> test <path> --run` |
58+
| Source file with tests | Lint the file + run related tests |
59+
| Source file, no tests | Lint the file + typecheck the package |
60+
| SCSS file in design-system | Lint the file |
61+
62+
## Notes
63+
64+
- **`--run` flag** prevents vitest watch mode
65+
- **design-system typecheck** auto-generates SCSS type defs
66+
- Prefer file-level lint, package-level typecheck, file-level test

.cursor/rules/code-review.mdc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
description: Use this rule when doing code reviews
3+
alwaysApply: false
4+
---
5+
6+
# Code Review Rules
7+
8+
It is a local code review process done before submitting a PR.
9+
10+
Objectives:
11+
12+
1. Review the current PR diff and flag only clear, high-severity issues
13+
2. Ensure the PR is up to date with the upstream main branch
14+
3. Verify requirements and applicable code standards/cursor rules
15+
4. Add short JS comments with a structure:
16+
17+
```typescript
18+
/**
19+
* REVIEW-[SEVERITY]: [ISSUE DESCRIPTION]
20+
*/
21+
```
22+
23+
- Align with the upstream main branch: ASK USER FOR PERMISSION, ALWAYS
24+
- Get diff: git diff upstream/main
25+
- Max 10 inline comments total; prioritize the most critical issues
26+
- One issue per comment; place on the exact changed line
27+
- Natural tone, specific and actionable; do not mention automated or a high-confidence
28+
- Use emojis: 🚨 Critical 🔒 Security ⚡ Performance ⚠️ Logic ✅ Resolved ✨ Improvement
29+

.cursor/rules/design-system.mdc

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
description: Component scaffolding templates for creating new design system components
3+
globs: packages/design-system/src/components/**/*
4+
---
5+
6+
# Component Scaffolding
7+
8+
## File Structure
9+
10+
New component at `packages/design-system/src/components/ds-{name}/`:
11+
12+
```
13+
ds-{name}/
14+
├── index.ts # Barrel export
15+
├── ds-{name}.tsx # Implementation
16+
├── ds-{name}.types.ts # Props interface
17+
├── ds-{name}.module.scss # Styles
18+
└── ds-{name}.stories.tsx # Stories
19+
```
20+
21+
## Implementation Template
22+
23+
```tsx
24+
import classNames from 'classnames';
25+
import styles from './ds-{name}.module.scss';
26+
import type { Ds{Name}Props } from './ds-{name}.types';
27+
28+
/**
29+
* Design system {Name} component
30+
*/
31+
const Ds{Name} = ({
32+
className,
33+
children,
34+
...props
35+
}: Ds{Name}Props) => {
36+
return (
37+
<div className={classNames(styles.container, className)} {...props}>
38+
{children}
39+
</div>
40+
);
41+
};
42+
43+
export default Ds{Name};
44+
```
45+
46+
## Types Template
47+
48+
```typescript
49+
import type { ComponentPropsWithoutRef, ReactNode } from 'react';
50+
51+
export interface Ds{Name}Props extends ComponentPropsWithoutRef<'div'> {
52+
/**
53+
* JSDoc description
54+
*/
55+
label?: ReactNode;
56+
}
57+
```
58+
59+
## Index Barrel
60+
61+
```typescript
62+
export { default as Ds{Name} } from './ds-{name}';
63+
export type { Ds{Name}Props } from './ds-{name}.types';
64+
```
65+
66+
## Primitive Libraries
67+
68+
1. **Ark UI** (`@ark-ui/react`) - Primary choice for new components
69+
2. **Radix UI** (`@radix-ui/react-*`) - Deprecated, modify existing only
70+
3. **TanStack** - Data-heavy components (table, virtual)
71+
4. **Custom** - Only when no primitive exists

.cursor/rules/monorepo.mdc

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
description: Package boundaries and workspace structure
3+
globs: packages/**/*
4+
---
5+
6+
# Package Boundaries
7+
8+
## Structure
9+
10+
```
11+
packages/
12+
├── design-system/ # @drivenets/design-system
13+
├── eslint-plugin/ # @drivenets/eslint-plugin-design-system
14+
├── vite-plugin/ # @drivenets/vite-plugin-design-system
15+
└── commitlint-plugin/ # @drivenets/commitlint-plugin-design-system
16+
```
17+
18+
## Import Rules
19+
20+
| Package | Can Import | Cannot Import |
21+
|---------|-----------|---------------|
22+
| design-system | React, Ark UI, Radix, TanStack, classnames | Other workspace packages |
23+
| eslint-plugin | ESLint APIs, TypeScript | React, design-system |
24+
| vite-plugin | Vite APIs | React, design-system |
25+
26+
## Workspace Dependencies
27+
28+
```json
29+
{
30+
"devDependencies": {
31+
"@drivenets/vite-plugin-design-system": "workspace:*"
32+
}
33+
}
34+
```
35+
36+
## Adding New Packages
37+
38+
1. Create `packages/{name}/`
39+
2. `package.json` with name `@drivenets/{name}`
40+
3. `tsconfig.json` extends `../../tsconfig.base.json`
41+
4. `eslint.config.ts` imports from `../../eslint.config.base.ts`
42+
43+
## Cross-Package Imports
44+
45+
```typescript
46+
// Good - use package name
47+
import { util } from '@drivenets/design-system';
48+
49+
// Bad - relative path across packages
50+
import { util } from '../../design-system/src/utils';
51+
```

0 commit comments

Comments
 (0)