Skip to content

Commit b438f9c

Browse files
authored
Merge pull request #16 from ivangrynenko/refactor/restructure-cursor-rule-files
Restructured cursor rule files for improved readability and consistency
2 parents 2c5b288 + 1dccc46 commit b438f9c

22 files changed

Lines changed: 1506 additions & 2051 deletions

.cursor/rules/accessibility-standards.mdc

Lines changed: 36 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,39 @@ globs: *.vue, *.jsx, *.tsx, *.html, *.php
66

77
Ensures WCAG compliance and accessibility best practices.
88

9-
<rule>
10-
name: accessibility_standards
11-
description: Enforce accessibility standards and WCAG compliance
12-
filters:
13-
- type: file_extension
14-
pattern: "\\.(vue|jsx|tsx|html|php|css|scss|sass)$" # Expanded to include CSS files
15-
16-
actions:
17-
- type: enforce
18-
conditions:
19-
- pattern: "<img[^>]+(?!alt=)[^>]*>"
20-
message: "Images must have alt attributes for screen readers."
21-
22-
- pattern: "aria-[a-z]+=\"\""
23-
message: "ARIA attributes should not be empty; provide meaningful values."
24-
25-
- pattern: "<button[^>]*>(?![^<]*[^\\s])[^<]*</button>"
26-
message: "Buttons should have meaningful, descriptive content."
27-
28-
- pattern: "<a[^>]*href=\"#[^\"]*\"[^>]*>(?![^<]*<svg)[^<]*</a>"
29-
message: "Links with href='#' should either be removed or have an aria-label for context."
30-
31-
- pattern: "<input[^>]+type=\"(text|email|password|search|tel|url)\"[^>]*>"
32-
pattern_negate: "aria-label|aria-labelledby|title"
33-
message: "Form inputs should include an aria-label or aria-labelledby attribute for better screen reader support."
34-
35-
- pattern: "<video[^>]*>(?!<track)[^<]*</video>"
36-
message: "Videos should include captions for accessibility."
37-
38-
- type: suggest
39-
message: |
40-
**Accessibility Best Practices:**
41-
- **Heading Hierarchy:** Use headings (h1 to h6) in a logical order to structure content.
42-
- **Keyboard Navigation:** Ensure all interactive elements are accessible via keyboard.
43-
- **Semantic HTML:** Favor semantic elements like <nav>, <article>, <section>, and <aside> for better structure comprehension.
44-
- **Color Contrast:** Check color contrast ratios meet WCAG guidelines (4.5:1 for normal text, 7:1 for large text).
45-
- **Skip Navigation Links:** Provide 'skip to main content' links for keyboard users to bypass repetitive navigation.
46-
- **Focus Management:** Ensure focus indicators are visible and manage focus for modal dialogs or dynamic content changes.
47-
- **Form Labels:** Associate labels with form controls using the 'for' attribute or wrap controls with <label>.
48-
- **Descriptive Links:** Use descriptive text for links, avoiding generic phrases like "click here."
49-
- **Touch Targets:** Ensure touch target sizes are large enough (at least 44x44 pixels) for mobile users.
50-
- **Timeouts:** Avoid or provide options to extend time limits where possible, or warn users before session expiry.
51-
- **Language Attribute:** Set the lang attribute on the <html> element to indicate the primary language of the page.
52-
53-
metadata:
54-
priority: high
55-
version: 1.1
56-
</rule>
9+
## Rule Details
10+
11+
- **Name:** accessibility_standards
12+
13+
- **Description:** Enforce accessibility standards and WCAG compliance
14+
15+
## Filters
16+
- file extension pattern: `"\\.(vue|jsx|tsx|html|php|css|scss|sass)$" # Expanded to include CSS files`
17+
18+
## Enforcement Checks
19+
- Conditions:
20+
- pattern `<img[^>]+(?!alt=)[^>]*>` – Images must have alt attributes for screen readers.
21+
- pattern `aria-[a-z]+=\"\"` – ARIA attributes should not be empty; provide meaningful values.
22+
- pattern `<button[^>]*>(?![^<]*[^\\s])[^<]*</button>` – Buttons should have meaningful, descriptive content.
23+
- pattern `<a[^>]*href=\"#[^\"]*\"[^>]*>(?![^<]*<svg)[^<]*</a>` – Links with href='#' should either be removed or have an aria-label for context.
24+
- pattern `<input[^>]+type=\"(text|email|password|search|tel|url)\"[^>]*>` – negated `aria-label|aria-labelledby|title` – Form inputs should include an aria-label or aria-labelledby attribute for better screen reader support.
25+
- pattern `<video[^>]*>(?!<track)[^<]*</video>` – Videos should include captions for accessibility.
26+
27+
## Suggestions
28+
- Guidance:
29+
**Accessibility Best Practices:**
30+
- **Heading Hierarchy:** Use headings (h1 to h6) in a logical order to structure content.
31+
- **Keyboard Navigation:** Ensure all interactive elements are accessible via keyboard.
32+
- **Semantic HTML:** Favor semantic elements like <nav>, <article>, <section>, and <aside> for better structure comprehension.
33+
- **Color Contrast:** Check color contrast ratios meet WCAG guidelines (4.5:1 for normal text, 7:1 for large text).
34+
- **Skip Navigation Links:** Provide 'skip to main content' links for keyboard users to bypass repetitive navigation.
35+
- **Focus Management:** Ensure focus indicators are visible and manage focus for modal dialogs or dynamic content changes.
36+
- **Form Labels:** Associate labels with form controls using the 'for' attribute or wrap controls with <label>.
37+
- **Descriptive Links:** Use descriptive text for links, avoiding generic phrases like "click here."
38+
- **Touch Targets:** Ensure touch target sizes are large enough (at least 44x44 pixels) for mobile users.
39+
- **Timeouts:** Avoid or provide options to extend time limits where possible, or warn users before session expiry.
40+
- **Language Attribute:** Set the lang attribute on the <html> element to indicate the primary language of the page.
41+
42+
## Metadata
43+
- Priority: high
44+
- Version: 1.2

.cursor/rules/api-standards.mdc

Lines changed: 40 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,43 @@ globs: *.php, *.js, *.ts
66

77
Ensures consistent API design, documentation, and implementation best practices across PHP, JavaScript, and TypeScript files.
88

9-
<rule>
10-
name: enhanced_api_standards
11-
description: Enforce enhanced API design, implementation, and documentation standards
12-
filters:
13-
- type: file_extension
14-
pattern: "\\.(php|js|ts)$"
15-
16-
actions:
17-
- type: enforce
18-
conditions:
19-
- pattern: "@api\\s+(?!GET|POST|PUT|DELETE|PATCH|OPTIONS|HEAD)"
20-
message: "Use standard HTTP methods (GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD) for API endpoints."
21-
22-
- pattern: "function\\s+[a-zA-Z]+Api\\s*\\([^)]*\\)\\s*\\{[^}]*\\}"
23-
pattern_negate: "(?s)(throw new \\w+Exception|return\\s+(?:\\d{3}|4\\d\\d|5\\d\\d))"
24-
message: "Ensure API functions handle or return errors appropriately using exceptions or HTTP status codes."
25-
26-
- pattern: "(?<!@api\\s+)(?<!\\s+returns\\s+)(?<!\\s+throws\\s+)[A-Z]{3,}(?!\\s+)"
27-
message: "HTTP methods should be prefixed with '@api' for documentation purposes."
28-
29-
- pattern: "\\bresponse\\b(?![^;]*\\.json\\()"
30-
message: "Ensure all API responses are properly formatted, preferably as JSON."
31-
32-
- type: suggest
33-
message: |
34-
**API Best Practices:**
35-
- **HTTP Methods:** Use proper HTTP methods for operations (GET for retrieval, POST for creation, etc.).
36-
- **Status Codes:** Use appropriate HTTP status codes to communicate the result of the request.
37-
- **Versioning:** Implement API versioning to manage changes without breaking existing integrations.
38-
- **Documentation:**
39-
- **Swagger/OpenAPI:** Use tools like Swagger for comprehensive API documentation.
40-
- **Endpoint Descriptions:** Clearly document all endpoints including path, methods, parameters, and possible responses.
41-
- **Authentication & Security:**
42-
- Implement OAuth, JWT, or similar secure authentication methods.
43-
- Use HTTPS for all API communications.
44-
- **Rate Limiting:** Implement rate limiting to prevent abuse and ensure fair usage.
45-
- **Error Handling:**
46-
- Provide clear, human-readable error messages with corresponding status codes.
47-
- Implement error logging for debugging purposes.
48-
- **Pagination:** For list endpoints, implement pagination to manage large datasets.
49-
- **Validation:** Validate input data at the API level to ensure data integrity.
50-
- **CORS:** Configure CORS headers if your API is meant to be consumed by web applications from different domains.
51-
- **Monitoring:** Set up monitoring for API performance and usage statistics.
52-
53-
metadata:
54-
priority: high
55-
version: 1.1
56-
</rule>
9+
## Rule Details
10+
11+
- **Name:** enhanced_api_standards
12+
13+
- **Description:** Enforce enhanced API design, implementation, and documentation standards
14+
15+
## Filters
16+
- file extension pattern: `\\.(php|js|ts)$`
17+
18+
## Enforcement Checks
19+
- Conditions:
20+
- pattern `@api\\s+(?!GET|POST|PUT|DELETE|PATCH|OPTIONS|HEAD)` – Use standard HTTP methods (GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD) for API endpoints.
21+
- pattern `function\\s+[a-zA-Z]+Api\\s*\\([^)]*\\)\\s*\\{[^}]*\\}` – negated `(?s)(throw new \\w+Exception|return\\s+(?:\\d{3}|4\\d\\d|5\\d\\d))` – Ensure API functions handle or return errors appropriately using exceptions or HTTP status codes.
22+
- pattern `(?<!@api\\s+)(?<!\\s+returns\\s+)(?<!\\s+throws\\s+)[A-Z]{3,}(?!\\s+)` – HTTP methods should be prefixed with '@api' for documentation purposes.
23+
- pattern `\\bresponse\\b(?![^;]*\\.json\\()` – Ensure all API responses are properly formatted, preferably as JSON.
24+
25+
## Suggestions
26+
- Guidance:
27+
**API Best Practices:**
28+
- **HTTP Methods:** Use proper HTTP methods for operations (GET for retrieval, POST for creation, etc.).
29+
- **Status Codes:** Use appropriate HTTP status codes to communicate the result of the request.
30+
- **Versioning:** Implement API versioning to manage changes without breaking existing integrations.
31+
- **Documentation:**
32+
- **Swagger/OpenAPI:** Use tools like Swagger for comprehensive API documentation.
33+
- **Endpoint Descriptions:** Clearly document all endpoints including path, methods, parameters, and possible responses.
34+
- **Authentication & Security:**
35+
- Implement OAuth, JWT, or similar secure authentication methods.
36+
- Use HTTPS for all API communications.
37+
- **Rate Limiting:** Implement rate limiting to prevent abuse and ensure fair usage.
38+
- **Error Handling:**
39+
- Provide clear, human-readable error messages with corresponding status codes.
40+
- Implement error logging for debugging purposes.
41+
- **Pagination:** For list endpoints, implement pagination to manage large datasets.
42+
- **Validation:** Validate input data at the API level to ensure data integrity.
43+
- **CORS:** Configure CORS headers if your API is meant to be consumed by web applications from different domains.
44+
- **Monitoring:** Set up monitoring for API performance and usage statistics.
45+
46+
## Metadata
47+
- Priority: high
48+
- Version: 1.2

.cursor/rules/build-optimization.mdc

Lines changed: 39 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,42 @@ globs: webpack.config.js, vite.config.js, *.config.js
66

77
Ensures optimal build configuration and process for better performance and maintainability.
88

9-
<rule>
10-
name: enhanced_build_optimization
11-
description: Enforce standards for optimizing build processes
12-
filters:
13-
- type: file_extension
14-
pattern: "\\.(js|ts|json)$" # Expanded to cover more config file types
15-
16-
actions:
17-
- type: enforce
18-
conditions:
19-
- pattern: "mode:\\s*['\"]development['\"]"
20-
pattern_negate: "process\\.env\\.NODE_ENV === 'development'"
21-
message: "Set 'mode' to 'production' for production builds unless dynamically set by NODE_ENV."
22-
23-
- pattern: "devtool:\\s*['\"]eval"
24-
message: "Use 'source-map' or 'hidden-source-map' for production builds to balance performance and debugging."
25-
26-
- pattern: "optimization:\\s*{[^}]*?splitChunks:\\s*{[^}]*?chunks:\\s*(?!'all')"
27-
message: "Enable code splitting for all chunks in optimization settings."
28-
29-
- pattern: "optimization:\\s*{[^}]*?usedExports:\\s*(?!true)"
30-
message: "Enable tree shaking by setting 'usedExports' to true."
31-
32-
- pattern: "output\\s*:\\s*{[^}]*?filename:\\s*['\"][^\\[]+['\"]"
33-
message: "Use content hashing in filenames for better caching (e.g., '[name].[contenthash].js')."
34-
35-
- type: suggest
36-
message: |
37-
**Build Optimization Best Practices:**
38-
- **Code Splitting:** Implement code splitting to load only what's necessary for each page or component.
39-
- **Tree Shaking:** Enable tree shaking to eliminate dead code, which reduces bundle size.
40-
- **Asset Optimization:**
41-
- Compress images and use modern formats like WebP where supported.
42-
- Use lazy loading for images and other media.
43-
- **Caching:**
44-
- Configure proper caching strategies (e.g., HTTP headers, service workers for PWA).
45-
- Use long-term caching for static assets with content hashing in filenames.
46-
- **Modern JavaScript:**
47-
- Use ES6+ features but ensure polyfills for older browsers if needed.
48-
- Consider using features like module/nomodule for graceful degradation.
49-
- **Minification & Compression:** Ensure all JavaScript and CSS are minified and consider enabling gzip compression on the server.
50-
- **Performance Budgets:** Set performance budgets to keep bundle sizes in check.
51-
- **Environment Variables:** Use environment variables for configuration differentiation between development and production.
52-
- **CI/CD:** Integrate with CI/CD pipelines for automated builds and testing, ensuring only optimized code goes to production.
53-
54-
metadata:
55-
priority: high
56-
version: 1.1
57-
</rule>
9+
## Rule Details
10+
11+
- **Name:** enhanced_build_optimization
12+
13+
- **Description:** Enforce standards for optimizing build processes
14+
15+
## Filters
16+
- file extension pattern: `"\\.(js|ts|json)$" # Expanded to cover more config file types`
17+
18+
## Enforcement Checks
19+
- Conditions:
20+
- pattern `mode:\\s*['\"]development['\"]` – negated `process\\.env\\.NODE_ENV === 'development'` – Set 'mode' to 'production' for production builds unless dynamically set by NODE_ENV.
21+
- pattern `devtool:\\s*['\"]eval` – Use 'source-map' or 'hidden-source-map' for production builds to balance performance and debugging.
22+
- pattern `optimization:\\s*{[^}]*?splitChunks:\\s*{[^}]*?chunks:\\s*(?!'all')` – Enable code splitting for all chunks in optimization settings.
23+
- pattern `optimization:\\s*{[^}]*?usedExports:\\s*(?!true)` – Enable tree shaking by setting 'usedExports' to true.
24+
- pattern `output\\s*:\\s*{[^}]*?filename:\\s*['\"][^\\[]+['\"]` – Use content hashing in filenames for better caching (e.g., '[name].[contenthash].js').
25+
26+
## Suggestions
27+
- Guidance:
28+
**Build Optimization Best Practices:**
29+
- **Code Splitting:** Implement code splitting to load only what's necessary for each page or component.
30+
- **Tree Shaking:** Enable tree shaking to eliminate dead code, which reduces bundle size.
31+
- **Asset Optimization:**
32+
- Compress images and use modern formats like WebP where supported.
33+
- Use lazy loading for images and other media.
34+
- **Caching:**
35+
- Configure proper caching strategies (e.g., HTTP headers, service workers for PWA).
36+
- Use long-term caching for static assets with content hashing in filenames.
37+
- **Modern JavaScript:**
38+
- Use ES6+ features but ensure polyfills for older browsers if needed.
39+
- Consider using features like module/nomodule for graceful degradation.
40+
- **Minification & Compression:** Ensure all JavaScript and CSS are minified and consider enabling gzip compression on the server.
41+
- **Performance Budgets:** Set performance budgets to keep bundle sizes in check.
42+
- **Environment Variables:** Use environment variables for configuration differentiation between development and production.
43+
- **CI/CD:** Integrate with CI/CD pipelines for automated builds and testing, ensuring only optimized code goes to production.
44+
45+
## Metadata
46+
- Priority: high
47+
- Version: 1.2

0 commit comments

Comments
 (0)