Skip to content

Commit 28576b6

Browse files
committed
chore: cursor utilities
1 parent f1d2c7c commit 28576b6

File tree

6 files changed

+500
-0
lines changed

6 files changed

+500
-0
lines changed

.cursor/README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Cursor rules documentation
2+
3+
This directory contains rules that Cursor uses to enforce consistent formatting and structure in our codebase.
4+
5+
## Rule structure
6+
7+
Rules defined in the `config.json` follow this structure:
8+
9+
```json
10+
{
11+
"version": 1,
12+
"rules": {
13+
"category": {
14+
"rule_name": {
15+
"enabled": true,
16+
"pattern": "regex_pattern",
17+
"message": "Error message"
18+
}
19+
}
20+
}
21+
}
22+
```
23+
24+
Additional, more specific rules can be found in the `rules` directory in either a `json` or `mdc` format.
25+
26+
## Available rules
27+
28+
### Text formatting
29+
30+
- **heading_case**: Enforces sentence case in headings with specific exceptions
31+
- Applies to: `.md`, `.txt`, `.mdx` files
32+
- Exceptions: Technical terms and acronyms
33+
34+
### Jira tickets
35+
36+
- **ticket_title**: Validates Jira ticket title format
37+
- Optional component in brackets
38+
- Max length: 80 characters
39+
- **required_sections**: Ensures required sections are present
40+
- **templates**: Enforces template structure for different ticket types
41+
- **labels**: Validates that only allowed labels are used
42+
- **issue_types**: Ensures correct issue type selection
43+
44+
## Usage
45+
46+
1. Cursor will automatically enforce these rules while editing relevant files; however, if you wish to enable a rule that is not triggered by default, you can do so by `@` mentioning it in the chat.
47+
2. Rules can be toggled using the `enabled` flag
48+
3. Custom error messages will be shown when rules are violated
49+
4. Exceptions are handled through the `exceptions` field in relevant rules
50+
51+
## Updating rules
52+
53+
To modify these rules:
54+
55+
1. Edit the `config.json` or the appropriate file in the `rules` directory
56+
2. Try to follow the existing structure and format where possible
57+
3. Ensure valid regex patterns, where applicable
58+
4. Include clear error messages
59+
5. Test changes before committing

.cursor/config.json

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
{
2+
"text_formatting": {
3+
"headings": {
4+
"case": "sentence",
5+
"files": ["**/*.md", "**/*.txt", "**/*.mdx"],
6+
"message": "Use sentence case (capitalize only the first word and proper nouns/acronyms)",
7+
"inline": true
8+
},
9+
"patterns": ["**/*.md", "**/*.txt", "**/*.mdx"]
10+
},
11+
"jira_tickets": {
12+
"title_format": {
13+
"pattern": "^\\[?[A-Za-z0-9-]+\\]?\\s.+$",
14+
"max_length": 80
15+
},
16+
"required_sections": ["Acceptance case", "Overview"],
17+
"labels": {
18+
"a11y": "Accessibility issues",
19+
"API": "Component API changes",
20+
"docs": "Documentation updates",
21+
"engineering-processes": "Engineering workflow improvements",
22+
"feature": "New features",
23+
"hold": "Suspended tickets",
24+
"i18n": "Internationalization work",
25+
"iOS": "iOS-specific issues",
26+
"mobile": "Mobile platform issues",
27+
"necromancy": "Old backlog tickets (>2 years)",
28+
"product-processes": "Product team process improvements",
29+
"refactor": "Code restructuring",
30+
"research": "Investigation tasks",
31+
"RFC": "Request for Comments",
32+
"s2foundations": "S2 Foundations work",
33+
"spectrum2": "Spectrum 2 tasks",
34+
"team-processes": "Team workflow improvements",
35+
"testing": "Test implementation",
36+
"triage": "Needs assessment",
37+
"VoiceOver": "VoiceOver specific issues"
38+
},
39+
"issue_types": ["Bug", "Epic", "Story", "Task"],
40+
"templates": {
41+
"bug": {
42+
"required_fields": [
43+
"Expected behaviour",
44+
"Actual behaviour",
45+
"Reproduction steps",
46+
"Severity"
47+
]
48+
},
49+
"feature": {
50+
"required_fields": ["Overview", "Acceptance criteria"],
51+
"optional_fields": [
52+
"Estimated internal impact",
53+
"Estimated external impact",
54+
"Anticipated reviewing audience",
55+
"Proposed solutions",
56+
"Supplementary documentation"
57+
]
58+
}
59+
}
60+
},
61+
"git": {
62+
"branchNameTemplate": "{username}/{type}-{description}{?-{issue}}",
63+
"types": [
64+
"feat",
65+
"fix",
66+
"docs",
67+
"style",
68+
"refactor",
69+
"perf",
70+
"test",
71+
"build",
72+
"ci",
73+
"chore",
74+
"revert"
75+
],
76+
"promptForIssueNumber": true,
77+
"allowEmptyIssueNumber": true,
78+
"transformDescription": "lowercase-dashed",
79+
"validationPattern": "^[a-z0-9]+\\/(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)-[a-z0-9-]+(-swc-[0-9]+)?$",
80+
"validationMessage": "Branch name should follow format: username/type-description[-swc-issue]"
81+
},
82+
"editor": {
83+
"formatOnSave": true,
84+
"defaultFormatter": "prettier",
85+
"tabSize": 4,
86+
"insertSpaces": true,
87+
"endOfLine": "auto",
88+
"charset": "utf-8"
89+
},
90+
"language": {
91+
"typescript": {
92+
"formatOnSave": true,
93+
"organizeImportsOnSave": true,
94+
"addMissingImports": "prompt",
95+
"defaultFormatter": "eslint"
96+
},
97+
"javascript": {
98+
"formatOnSave": true,
99+
"organizeImportsOnSave": true,
100+
"addMissingImports": "prompt",
101+
"moduleResolution": "auto",
102+
"snippets": {
103+
"newScript": {
104+
"detectModuleFormat": true,
105+
"preferESM": true
106+
}
107+
}
108+
},
109+
"css": {
110+
"formatOnSave": true,
111+
"defaultFormatter": "stylelint"
112+
}
113+
},
114+
"terminal": {
115+
"defaultProfile": "${os.shell}",
116+
"integrated": {
117+
"fontFamily": "${os.monospace}",
118+
"fontSize": 12,
119+
"shell": {
120+
"windows": "powershell.exe",
121+
"linux": "bash",
122+
"osx": "bash"
123+
}
124+
}
125+
},
126+
"search": {
127+
"exclude": {
128+
"**/node_modules": true,
129+
"**/dist": true,
130+
"**/.git": true,
131+
"**/.vs": true,
132+
"**/.idea": true,
133+
"**/*.css.js": true,
134+
"**/*.css.ts": true,
135+
"**/*.d.ts": true,
136+
"**/coverage": true,
137+
"**/.wireit": true,
138+
"**/*.tsbuildinfo": true,
139+
"**/custom-elements.json": true,
140+
"**/test/benchmark/results": true,
141+
"**/storybook-static": true,
142+
"**/*.min.*": true,
143+
"**/*.map": true
144+
},
145+
"useGitIgnore": true,
146+
"followSymlinks": false
147+
}
148+
}

.cursor/rules/branch-naming.mdc

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
description:
3+
globs:
4+
alwaysApply: true
5+
---
6+
# Branch naming format
7+
8+
Suggests the ideal branch naming format for Spectrum Web Components contributions.
9+
10+
## Pattern
11+
```
12+
^[a-z0-9]+\/(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)-[a-z0-9-]+(-swc-[0-9]+)?$
13+
```
14+
15+
## Message
16+
Consider following the preferred branch naming format: `<username>/<type>-<description>[-swc-<issue>]`
17+
18+
Username will be automatically pulled from your git config settings.
19+
20+
### Guidelines
21+
- Use lowercase letters and numbers only
22+
- Separate words with dashes (not camelCase)
23+
- Use conventional commit types:
24+
• **feat**: New feature
25+
• **fix**: Bug fix
26+
• **docs**: Documentation only
27+
• **style**: Code style/formatting
28+
• **refactor**: Code change that neither fixes a bug nor adds a feature
29+
• **perf**: Code change that improves performance
30+
• **test**: Adding missing tests or correcting existing tests
31+
• **build**: Changes that affect the build system or external dependencies
32+
• **ci**: Changes to CI configuration files and scripts
33+
• **chore**: Other changes that don't modify src or test files
34+
• **revert**: Reverts a previous commit
35+
- Optional issue number format: `-swc-XXX`
36+
37+
### Good examples
38+
- `johndoe/feat-add-new-button-swc-123`
39+
- `janedoe/fix-dropdown-alignment`
40+
- `alice/refactor-component-structure`
41+
- `bob/perf-optimize-rendering`
42+
43+
### Avoid
44+
- `johnDoe/feat-addNewButton` (no camelCase)
45+
- `jane/fix-Dropdown-Bug` (no uppercase)
46+
47+
This is a recommended format to maintain consistency, but not required.
48+
49+
## Severity
50+
warning
51+
52+
## Scope
53+
git_branch

0 commit comments

Comments
 (0)