Skip to content

chore: cursor utilities [CSS-1222] #5505

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
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .cursor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Cursor rules documentation

This directory contains rules that Cursor uses to enforce consistent formatting and structure in our codebase.

## Rule structure

Rules defined in the `config.json` follow this structure:

```json
{
"version": 1,
"rules": {
"category": {
"rule_name": {
"enabled": true,
"pattern": "regex_pattern",
"message": "Error message"
}
}
}
}
```

Additional, more specific rules can be found in the `rules` directory in either a `json` or `mdc` format.

## Available rules

### Text formatting

- **heading_case**: Enforces sentence case in headings with specific exceptions
- Applies to: `.md`, `.txt`, `.mdx` files
- Exceptions: Technical terms and acronyms

### Jira tickets

- **ticket_title**: Validates Jira ticket title format
- Optional component in brackets
- Max length: 80 characters
- **required_sections**: Ensures required sections are present
- **templates**: Enforces template structure for different ticket types
- **labels**: Validates that only allowed labels are used
- **issue_types**: Ensures correct issue type selection

## Usage

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.
2. Rules can be toggled using the `enabled` flag
3. Custom error messages will be shown when rules are violated
4. Exceptions are handled through the `exceptions` field in relevant rules

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we like to say anything about @ mentioning the rules in a chat? I made changes to a file, and then put this into the chat: @text-formatting.mdc double check the changes i made in the new jira ticket file. so that cursor would basically lint my changes based on the text-formatting rules.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to @ mention the jira ticket MDC file as well. This definitely could be something I'm doing in the wrong order or something.

## Updating rules

To modify these rules:

1. Edit the `config.json` or the appropriate file in the `rules` directory
2. Try to follow the existing structure and format where possible
3. Ensure valid regex patterns, where applicable
4. Include clear error messages
5. Test changes before committing
148 changes: 148 additions & 0 deletions .cursor/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"text_formatting": {
"headings": {
"case": "sentence",
"files": ["**/*.md", "**/*.txt", "**/*.mdx"],
"message": "Use sentence case (capitalize only the first word and proper nouns/acronyms)",
"inline": true
},
"patterns": ["**/*.md", "**/*.txt", "**/*.mdx"]
},
"jira_tickets": {
"title_format": {
"pattern": "^\\[?[A-Za-z0-9-]+\\]?\\s.+$",
"max_length": 80
},
"required_sections": ["Acceptance case", "Overview"],
"labels": {
"a11y": "Accessibility issues",
"API": "Component API changes",
"docs": "Documentation updates",
"engineering-processes": "Engineering workflow improvements",
"feature": "New features",
"hold": "Suspended tickets",
"i18n": "Internationalization work",
"iOS": "iOS-specific issues",
"mobile": "Mobile platform issues",
"necromancy": "Old backlog tickets (>2 years)",
"product-processes": "Product team process improvements",
"refactor": "Code restructuring",
"research": "Investigation tasks",
"RFC": "Request for Comments",
"s2foundations": "S2 Foundations work",
"spectrum2": "Spectrum 2 tasks",
"team-processes": "Team workflow improvements",
"testing": "Test implementation",
"triage": "Needs assessment",
"VoiceOver": "VoiceOver specific issues"
},
"issue_types": ["Bug", "Epic", "Story", "Task"],
"templates": {
"bug": {
"required_fields": [
"Expected behaviour",
"Actual behaviour",
"Reproduction steps",
"Severity"
]
},
"feature": {
"required_fields": ["Overview", "Acceptance criteria"],
"optional_fields": [
"Estimated internal impact",
"Estimated external impact",
"Anticipated reviewing audience",
"Proposed solutions",
"Supplementary documentation"
]
}
}
},
"git": {
"branchNameTemplate": "{username}/{type}-{description}{?-{issue}}",
"types": [
"feat",
"fix",
"docs",
"style",
"refactor",
"perf",
"test",
"build",
"ci",
"chore",
"revert"
],
"promptForIssueNumber": true,
"allowEmptyIssueNumber": true,
"transformDescription": "lowercase-dashed",
"validationPattern": "^[a-z0-9]+\\/(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)-[a-z0-9-]+(-swc-[0-9]+)?$",
"validationMessage": "Branch name should follow format: username/type-description[-swc-issue]"
},
"editor": {
"formatOnSave": true,
"defaultFormatter": "prettier",
"tabSize": 4,
"insertSpaces": true,
"endOfLine": "auto",
"charset": "utf-8"
},
"language": {
"typescript": {
"formatOnSave": true,
"organizeImportsOnSave": true,
"addMissingImports": "prompt",
"defaultFormatter": "eslint"
},
"javascript": {
"formatOnSave": true,
"organizeImportsOnSave": true,
"addMissingImports": "prompt",
"moduleResolution": "auto",
"snippets": {
"newScript": {
"detectModuleFormat": true,
"preferESM": true
}
}
},
"css": {
"formatOnSave": true,
"defaultFormatter": "stylelint"
}
},
"terminal": {
"defaultProfile": "${os.shell}",
"integrated": {
"fontFamily": "${os.monospace}",
"fontSize": 12,
"shell": {
"windows": "powershell.exe",
"linux": "bash",
"osx": "bash"
}
}
},
"search": {
"exclude": {
"**/node_modules": true,
"**/dist": true,
"**/.git": true,
"**/.vs": true,
"**/.idea": true,
"**/*.css.js": true,
"**/*.css.ts": true,
"**/*.d.ts": true,
"**/coverage": true,
"**/.wireit": true,
"**/*.tsbuildinfo": true,
"**/custom-elements.json": true,
"**/test/benchmark/results": true,
"**/storybook-static": true,
"**/*.min.*": true,
"**/*.map": true
},
"useGitIgnore": true,
"followSymlinks": false
}
}
53 changes: 53 additions & 0 deletions .cursor/rules/branch-naming.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
description:
globs:
alwaysApply: true
---
# Branch naming format

Suggests the ideal branch naming format for Spectrum Web Components contributions.

## Pattern
```
^[a-z0-9]+\/(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)-[a-z0-9-]+(-swc-[0-9]+)?$
```

## Message
Consider following the preferred branch naming format: `<username>/<type>-<description>[-swc-<issue>]`

Username will be automatically pulled from your git config settings.

### Guidelines
- Use lowercase letters and numbers only
- Separate words with dashes (not camelCase)
- Use conventional commit types:
• **feat**: New feature
• **fix**: Bug fix
• **docs**: Documentation only
• **style**: Code style/formatting
• **refactor**: Code change that neither fixes a bug nor adds a feature
• **perf**: Code change that improves performance
• **test**: Adding missing tests or correcting existing tests
• **build**: Changes that affect the build system or external dependencies
• **ci**: Changes to CI configuration files and scripts
• **chore**: Other changes that don't modify src or test files
• **revert**: Reverts a previous commit
- Optional issue number format: `-swc-XXX`

### Good examples
- `johndoe/feat-add-new-button-swc-123`
- `janedoe/fix-dropdown-alignment`
- `alice/refactor-component-structure`
- `bob/perf-optimize-rendering`

### Avoid
- `johnDoe/feat-addNewButton` (no camelCase)
- `jane/fix-Dropdown-Bug` (no uppercase)

This is a recommended format to maintain consistency, but not required.

## Severity
warning

## Scope
git_branch
Loading
Loading