-
Notifications
You must be signed in to change notification settings - Fork 212
@W-18737391 Add development guidelines and page creation rules for generated project #2786
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
Changes from 10 commits
2124053
9b336fb
2ab0829
3fd3078
6e6f9b1
086381f
3bf0c83
cce224d
57c29ec
90faabc
3e0d98a
88b6f9b
61fe5c4
d4c545f
ae0fe8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| description: Check and verify accessibility on local project | ||
| globs: | ||
| alwaysApply: false | ||
| --- | ||
| To check accessibility of a project, use the accessibility rules defined in ./cursor-accessibility-mdc/ directory. | ||
| Run an automated scan for the entire codebase within the project and check for any violations. | ||
| Show the scanned results in summary and detailed violations if any. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| --- | ||
| description: When accessibility is checked. Check if Buttons must have a discernible name using text or aria attributes | ||
| globs: | ||
| alwaysApply: false | ||
| --- | ||
|
|
||
| # Rule: accessibility-button-name | ||
|
|
||
| Buttons must have a discernible name using text or aria attributes | ||
|
|
||
| ## 🔍 Pattern | ||
|
|
||
| ```regex | ||
| <button(?![^>]*\b(aria-label|aria-labelledby|title|name)=) | ||
| ``` | ||
|
|
||
| ## 📍 Examples | ||
|
|
||
| ```tsx | ||
| // ❌ Bad | ||
| <button></button> | ||
| // ✅ Good | ||
| <button>Submit</button> | ||
| // ✅ Good | ||
| <button aria-label="Close dialog"><XIcon /></button> | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| --- | ||
| description: When accessibility is checked. Check if heading levels should increase sequentially for semantic structure | ||
| globs: | ||
| alwaysApply: false | ||
| --- | ||
|
|
||
| # Rule: accessibility-heading-order | ||
|
|
||
| Heading levels should increase sequentially for semantic structure | ||
|
|
||
| ## 🔍 Pattern | ||
|
|
||
| ```regex | ||
| <h([3-6])> | ||
| ``` | ||
|
|
||
| ## 📍 Examples | ||
|
|
||
| ```tsx | ||
| // ❌ Bad | ||
| <h1>Main Title</h1> | ||
| <h4>Subsection</h4> | ||
| // ✅ Good | ||
| <h1>Main Title</h1> | ||
| <h2>Subsection</h2> | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| --- | ||
| description: When accessibility is checked. Ensure all <img> tags include descriptive alt attributes | ||
| globs: | ||
| alwaysApply: false | ||
| --- | ||
|
|
||
| # Rule: accessibility-image-alt | ||
|
|
||
| Ensure all <img> tags include descriptive alt attributes | ||
|
|
||
| ## 🔍 Pattern | ||
|
|
||
| ```regex | ||
| <img(?![^>]*\balt=) | ||
| ``` | ||
|
|
||
| ## 📍 Examples | ||
|
|
||
| ```tsx | ||
| // ❌ Bad | ||
| <img src="photo.jpg" /> | ||
| // ✅ Good | ||
| <img src="photo.jpg" alt="Company logo" /> | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| --- | ||
| description: When accessibility is checked. Check if Input fields must have a label or aria-label for screen readers | ||
| globs: | ||
| alwaysApply: false | ||
| --- | ||
|
|
||
| # Rule: accessibility-input-label | ||
|
|
||
| Input fields must have a label or aria-label for screen readers | ||
|
|
||
| ## 🔍 Pattern | ||
|
|
||
| ```regex | ||
| <input(?![^>]*(aria-label|aria-labelledby|id=)) | ||
| ``` | ||
|
|
||
| ## 📍 Examples | ||
|
|
||
| ```tsx | ||
| // ❌ Bad | ||
| <input type="text" /> | ||
| // ✅ Good | ||
| <input aria-label="Search" /> | ||
| // ✅ Good with label | ||
| <label htmlFor="email">Email</label> | ||
| <input id="email" type="text" /> | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| --- | ||
| description: When accessibility is checked. Check if Anchor tags must have accessible names | ||
| globs: | ||
| alwaysApply: false | ||
| --- | ||
|
|
||
| # Rule: accessibility-link-name | ||
|
|
||
| Anchor tags must have accessible names | ||
|
|
||
| ## 🔍 Pattern | ||
|
|
||
| ```regex | ||
| <a(?![^>]*\b(aria-label|aria-labelledby|title)=)(?![^>]*>\s*\w+\s*</a>) | ||
| ``` | ||
|
|
||
| ## 📍 Examples | ||
|
|
||
| ```tsx | ||
| // ❌ Bad | ||
| <a href="/profile"></a> | ||
| // ✅ Good | ||
| <a href="/profile">Your Profile</a> | ||
| // ✅ Good | ||
| <a href="/profile" aria-label="Profile page"><UserIcon /></a> | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| --- | ||
| description: Salesforce Commerce Composable Storefront Development Guidelines | ||
| globs: | ||
| alwaysApply: false | ||
| --- | ||
|
|
||
| # Commerce Composable Storefront Development Guidelines | ||
|
|
||
| ## Overview | ||
| Guidelines for Salesforce Commerce Composable Storefront development using PWA Kit, Retail React App, and Chakra UI. | ||
|
|
||
| ## Core Principles | ||
| - Analyze requirements and existing codebase thoroughly | ||
| - Use existing components and hooks when possible | ||
| - Plan before implementing | ||
| - Test comprehensively with Jest | ||
|
|
||
| ## PWA Kit Essentials | ||
|
|
||
| ### Architecture | ||
| - Server-side rendering (SSR) for initial loads | ||
| - Client-side rendering (CSR) for interactions | ||
| - Isomorphic code (works on server and client) | ||
| - Proxy requests via `/mobify/proxy/<PROXY_PATH>` | ||
|
|
||
| ### Special Components | ||
| - Components starting with `_` are special PWA Kit components | ||
| - `_app-config`: Top-level app configuration | ||
| - `_app`: Persistent layout (header, footer, sidebar) | ||
| - `_error`: 404 and error pages | ||
|
|
||
| ## Development Rules | ||
| - Use kebab-case for file names (except special components with `_`) | ||
| - Use Chakra UI and existing components | ||
| - Create modular, reusable components | ||
| - Use React Hooks for state management | ||
| - Access data via commerce-sdk-react hooks | ||
| - Ensure mobile-friendly and accessible components | ||
| - Maintain consistent code formatting using project standards | ||
| - Write comprehensive test coverage |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --- | ||
| description: Page Creation Rule - automatically apply when user asks to create new page, add page, make page, build page, generate page | ||
| globs: | ||
| alwaysApply: false | ||
| --- | ||
| USE WHEN create a new page, add a new page, make a new page, build a new page, generate a new page, create page, add page, make page, build page, generate page | ||
|
|
||
| **Mandatory** | ||
| - DO ask user to clarify page name and page route before proceed | ||
| - ONLY Create a bare minimum page component | ||
| - Do NOT include other project components or hooks unless specifically requested | ||
| - Do NOT add extra styling, layout, or features unless explicitly asked | ||
|
|
||
| ## Implementation Steps | ||
| 1. Create simple component in `app/pages/[page-name]/index.jsx` | ||
| 2. Add route to `app/routes.jsx` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| --- | ||
| description: Salesforce Commerce Composable Storefront Development Guidelines | ||
| globs: | ||
| alwaysApply: false | ||
| --- | ||
|
|
||
| # Commerce Composable Storefront Development Guidelines | ||
|
|
||
| ## Overview | ||
| Guidelines for Salesforce Commerce Composable Storefront development using PWA Kit, Retail React App, and Chakra UI. | ||
|
|
||
| ## Core Principles | ||
| - Analyze requirements and existing codebase thoroughly | ||
| - Use existing components and hooks when possible | ||
| - Plan before implementing | ||
| - Test comprehensively with Jest | ||
|
|
||
| ## PWA Kit Essentials | ||
|
|
||
| ### Architecture | ||
| - Server-side rendering (SSR) for initial loads | ||
| - Client-side rendering (CSR) for interactions | ||
| - Isomorphic code (works on server and client) | ||
| - Proxy requests via `/mobify/proxy/<PROXY_PATH>` | ||
|
|
||
| ### Special Components | ||
| - Components starting with `_` are special PWA Kit components | ||
| - `_app-config`: Top-level app configuration | ||
| - `_app`: Persistent layout (header, footer, sidebar) | ||
| - `_error`: 404 and error pages | ||
|
|
||
| ## Development Rules | ||
| - Use kebab-case for file names (except special components with `_`) | ||
| - Use Chakra UI and existing components | ||
| - Create modular, reusable components | ||
| - Use React Hooks for state management | ||
| - Access data via commerce-sdk-react hooks | ||
| - Ensure mobile-friendly and accessible components | ||
| - Maintain consistent code formatting using project standards | ||
| - Write comprehensive test coverage |
|
Contributor
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. How does this model-definition configuration file get discovered?
Contributor
Author
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. Cursor only fetch this guidelines rule if it think it needs it. On top of that, Cursor will not look into nodes_module even rules say so. We need other mechanism to expose model-definition files. By the way, I do not know where it is as well. Could you share more information about it?
Contributor
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. Moreover mdc files are a cursor's convention in determining rules |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --- | ||
| description: Page Creation Rule - automatically apply when user asks to create new page, add page, make page, build page, generate page | ||
yhsieh1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| globs: | ||
yhsieh1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| alwaysApply: false | ||
| --- | ||
| USE WHEN create a new page, add a new page, make a new page, build a new page, generate a new page, create page, add page, make page, build page, generate page | ||
|
|
||
| **Mandatory** | ||
| - DO ask user to clarify page name and page route before proceed | ||
| - ONLY Create a bare minimum page component | ||
| - Do NOT include other project components or hooks unless specifically requested | ||
| - Do NOT add extra styling, layout, or features unless explicitly asked | ||
|
|
||
| ## Implementation Steps | ||
| 1. Create simple component in `app/pages/[page-name]/index.jsx` | ||
| 2. Add route to `app/routes.jsx` | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy over rules to
storefront-developmentname space frompwa-kit-create-app/assets/cursor-rulesso that it also benefits pwa kit template development.