Skip to content
Merged
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
84 changes: 36 additions & 48 deletions .cursor/rules/accessibility-standards.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,39 @@ globs: *.vue, *.jsx, *.tsx, *.html, *.php

Ensures WCAG compliance and accessibility best practices.

<rule>
name: accessibility_standards
description: Enforce accessibility standards and WCAG compliance
filters:
- type: file_extension
pattern: "\\.(vue|jsx|tsx|html|php|css|scss|sass)$" # Expanded to include CSS files

actions:
- type: enforce
conditions:
- pattern: "<img[^>]+(?!alt=)[^>]*>"
message: "Images must have alt attributes for screen readers."

- pattern: "aria-[a-z]+=\"\""
message: "ARIA attributes should not be empty; provide meaningful values."

- pattern: "<button[^>]*>(?![^<]*[^\\s])[^<]*</button>"
message: "Buttons should have meaningful, descriptive content."

- pattern: "<a[^>]*href=\"#[^\"]*\"[^>]*>(?![^<]*<svg)[^<]*</a>"
message: "Links with href='#' should either be removed or have an aria-label for context."

- pattern: "<input[^>]+type=\"(text|email|password|search|tel|url)\"[^>]*>"
pattern_negate: "aria-label|aria-labelledby|title"
message: "Form inputs should include an aria-label or aria-labelledby attribute for better screen reader support."

- pattern: "<video[^>]*>(?!<track)[^<]*</video>"
message: "Videos should include captions for accessibility."

- type: suggest
message: |
**Accessibility Best Practices:**
- **Heading Hierarchy:** Use headings (h1 to h6) in a logical order to structure content.
- **Keyboard Navigation:** Ensure all interactive elements are accessible via keyboard.
- **Semantic HTML:** Favor semantic elements like <nav>, <article>, <section>, and <aside> for better structure comprehension.
- **Color Contrast:** Check color contrast ratios meet WCAG guidelines (4.5:1 for normal text, 7:1 for large text).
- **Skip Navigation Links:** Provide 'skip to main content' links for keyboard users to bypass repetitive navigation.
- **Focus Management:** Ensure focus indicators are visible and manage focus for modal dialogs or dynamic content changes.
- **Form Labels:** Associate labels with form controls using the 'for' attribute or wrap controls with <label>.
- **Descriptive Links:** Use descriptive text for links, avoiding generic phrases like "click here."
- **Touch Targets:** Ensure touch target sizes are large enough (at least 44x44 pixels) for mobile users.
- **Timeouts:** Avoid or provide options to extend time limits where possible, or warn users before session expiry.
- **Language Attribute:** Set the lang attribute on the <html> element to indicate the primary language of the page.

metadata:
priority: high
version: 1.1
</rule>
## Rule Details

- **Name:** accessibility_standards

- **Description:** Enforce accessibility standards and WCAG compliance

## Filters
- file extension pattern: `"\\.(vue|jsx|tsx|html|php|css|scss|sass)$" # Expanded to include CSS files`

## Enforcement Checks
- Conditions:
- pattern `<img[^>]+(?!alt=)[^>]*>` – Images must have alt attributes for screen readers.
- pattern `aria-[a-z]+=\"\"` – ARIA attributes should not be empty; provide meaningful values.
- pattern `<button[^>]*>(?![^<]*[^\\s])[^<]*</button>` – Buttons should have meaningful, descriptive content.
- pattern `<a[^>]*href=\"#[^\"]*\"[^>]*>(?![^<]*<svg)[^<]*</a>` – Links with href='#' should either be removed or have an aria-label for context.
- 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.
- pattern `<video[^>]*>(?!<track)[^<]*</video>` – Videos should include captions for accessibility.

## Suggestions
- Guidance:
**Accessibility Best Practices:**
- **Heading Hierarchy:** Use headings (h1 to h6) in a logical order to structure content.
- **Keyboard Navigation:** Ensure all interactive elements are accessible via keyboard.
- **Semantic HTML:** Favor semantic elements like <nav>, <article>, <section>, and <aside> for better structure comprehension.
- **Color Contrast:** Check color contrast ratios meet WCAG guidelines (4.5:1 for normal text, 7:1 for large text).
- **Skip Navigation Links:** Provide 'skip to main content' links for keyboard users to bypass repetitive navigation.
- **Focus Management:** Ensure focus indicators are visible and manage focus for modal dialogs or dynamic content changes.
- **Form Labels:** Associate labels with form controls using the 'for' attribute or wrap controls with <label>.
- **Descriptive Links:** Use descriptive text for links, avoiding generic phrases like "click here."
- **Touch Targets:** Ensure touch target sizes are large enough (at least 44x44 pixels) for mobile users.
- **Timeouts:** Avoid or provide options to extend time limits where possible, or warn users before session expiry.
- **Language Attribute:** Set the lang attribute on the <html> element to indicate the primary language of the page.

## Metadata
- Priority: high
- Version: 1.2
88 changes: 40 additions & 48 deletions .cursor/rules/api-standards.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,43 @@ globs: *.php, *.js, *.ts

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

<rule>
name: enhanced_api_standards
description: Enforce enhanced API design, implementation, and documentation standards
filters:
- type: file_extension
pattern: "\\.(php|js|ts)$"

actions:
- type: enforce
conditions:
- pattern: "@api\\s+(?!GET|POST|PUT|DELETE|PATCH|OPTIONS|HEAD)"
message: "Use standard HTTP methods (GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD) for API endpoints."

- pattern: "function\\s+[a-zA-Z]+Api\\s*\\([^)]*\\)\\s*\\{[^}]*\\}"
pattern_negate: "(?s)(throw new \\w+Exception|return\\s+(?:\\d{3}|4\\d\\d|5\\d\\d))"
message: "Ensure API functions handle or return errors appropriately using exceptions or HTTP status codes."

- pattern: "(?<!@api\\s+)(?<!\\s+returns\\s+)(?<!\\s+throws\\s+)[A-Z]{3,}(?!\\s+)"
message: "HTTP methods should be prefixed with '@api' for documentation purposes."

- pattern: "\\bresponse\\b(?![^;]*\\.json\\()"
message: "Ensure all API responses are properly formatted, preferably as JSON."

- type: suggest
message: |
**API Best Practices:**
- **HTTP Methods:** Use proper HTTP methods for operations (GET for retrieval, POST for creation, etc.).
- **Status Codes:** Use appropriate HTTP status codes to communicate the result of the request.
- **Versioning:** Implement API versioning to manage changes without breaking existing integrations.
- **Documentation:**
- **Swagger/OpenAPI:** Use tools like Swagger for comprehensive API documentation.
- **Endpoint Descriptions:** Clearly document all endpoints including path, methods, parameters, and possible responses.
- **Authentication & Security:**
- Implement OAuth, JWT, or similar secure authentication methods.
- Use HTTPS for all API communications.
- **Rate Limiting:** Implement rate limiting to prevent abuse and ensure fair usage.
- **Error Handling:**
- Provide clear, human-readable error messages with corresponding status codes.
- Implement error logging for debugging purposes.
- **Pagination:** For list endpoints, implement pagination to manage large datasets.
- **Validation:** Validate input data at the API level to ensure data integrity.
- **CORS:** Configure CORS headers if your API is meant to be consumed by web applications from different domains.
- **Monitoring:** Set up monitoring for API performance and usage statistics.

metadata:
priority: high
version: 1.1
</rule>
## Rule Details

- **Name:** enhanced_api_standards

- **Description:** Enforce enhanced API design, implementation, and documentation standards

## Filters
- file extension pattern: `\\.(php|js|ts)$`

## Enforcement Checks
- Conditions:
- pattern `@api\\s+(?!GET|POST|PUT|DELETE|PATCH|OPTIONS|HEAD)` – Use standard HTTP methods (GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD) for API endpoints.
- 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.
- pattern `(?<!@api\\s+)(?<!\\s+returns\\s+)(?<!\\s+throws\\s+)[A-Z]{3,}(?!\\s+)` – HTTP methods should be prefixed with '@api' for documentation purposes.
- pattern `\\bresponse\\b(?![^;]*\\.json\\()` – Ensure all API responses are properly formatted, preferably as JSON.

## Suggestions
- Guidance:
**API Best Practices:**
- **HTTP Methods:** Use proper HTTP methods for operations (GET for retrieval, POST for creation, etc.).
- **Status Codes:** Use appropriate HTTP status codes to communicate the result of the request.
- **Versioning:** Implement API versioning to manage changes without breaking existing integrations.
- **Documentation:**
- **Swagger/OpenAPI:** Use tools like Swagger for comprehensive API documentation.
- **Endpoint Descriptions:** Clearly document all endpoints including path, methods, parameters, and possible responses.
- **Authentication & Security:**
- Implement OAuth, JWT, or similar secure authentication methods.
- Use HTTPS for all API communications.
- **Rate Limiting:** Implement rate limiting to prevent abuse and ensure fair usage.
- **Error Handling:**
- Provide clear, human-readable error messages with corresponding status codes.
- Implement error logging for debugging purposes.
- **Pagination:** For list endpoints, implement pagination to manage large datasets.
- **Validation:** Validate input data at the API level to ensure data integrity.
- **CORS:** Configure CORS headers if your API is meant to be consumed by web applications from different domains.
- **Monitoring:** Set up monitoring for API performance and usage statistics.

## Metadata
- Priority: high
- Version: 1.2
88 changes: 39 additions & 49 deletions .cursor/rules/build-optimization.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,42 @@ globs: webpack.config.js, vite.config.js, *.config.js

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

<rule>
name: enhanced_build_optimization
description: Enforce standards for optimizing build processes
filters:
- type: file_extension
pattern: "\\.(js|ts|json)$" # Expanded to cover more config file types

actions:
- type: enforce
conditions:
- pattern: "mode:\\s*['\"]development['\"]"
pattern_negate: "process\\.env\\.NODE_ENV === 'development'"
message: "Set 'mode' to 'production' for production builds unless dynamically set by NODE_ENV."

- pattern: "devtool:\\s*['\"]eval"
message: "Use 'source-map' or 'hidden-source-map' for production builds to balance performance and debugging."

- pattern: "optimization:\\s*{[^}]*?splitChunks:\\s*{[^}]*?chunks:\\s*(?!'all')"
message: "Enable code splitting for all chunks in optimization settings."

- pattern: "optimization:\\s*{[^}]*?usedExports:\\s*(?!true)"
message: "Enable tree shaking by setting 'usedExports' to true."

- pattern: "output\\s*:\\s*{[^}]*?filename:\\s*['\"][^\\[]+['\"]"
message: "Use content hashing in filenames for better caching (e.g., '[name].[contenthash].js')."

- type: suggest
message: |
**Build Optimization Best Practices:**
- **Code Splitting:** Implement code splitting to load only what's necessary for each page or component.
- **Tree Shaking:** Enable tree shaking to eliminate dead code, which reduces bundle size.
- **Asset Optimization:**
- Compress images and use modern formats like WebP where supported.
- Use lazy loading for images and other media.
- **Caching:**
- Configure proper caching strategies (e.g., HTTP headers, service workers for PWA).
- Use long-term caching for static assets with content hashing in filenames.
- **Modern JavaScript:**
- Use ES6+ features but ensure polyfills for older browsers if needed.
- Consider using features like module/nomodule for graceful degradation.
- **Minification & Compression:** Ensure all JavaScript and CSS are minified and consider enabling gzip compression on the server.
- **Performance Budgets:** Set performance budgets to keep bundle sizes in check.
- **Environment Variables:** Use environment variables for configuration differentiation between development and production.
- **CI/CD:** Integrate with CI/CD pipelines for automated builds and testing, ensuring only optimized code goes to production.

metadata:
priority: high
version: 1.1
</rule>
## Rule Details

- **Name:** enhanced_build_optimization

- **Description:** Enforce standards for optimizing build processes

## Filters
- file extension pattern: `"\\.(js|ts|json)$" # Expanded to cover more config file types`

## Enforcement Checks
- Conditions:
- pattern `mode:\\s*['\"]development['\"]` – negated `process\\.env\\.NODE_ENV === 'development'` – Set 'mode' to 'production' for production builds unless dynamically set by NODE_ENV.
- pattern `devtool:\\s*['\"]eval` – Use 'source-map' or 'hidden-source-map' for production builds to balance performance and debugging.
- pattern `optimization:\\s*{[^}]*?splitChunks:\\s*{[^}]*?chunks:\\s*(?!'all')` – Enable code splitting for all chunks in optimization settings.
- pattern `optimization:\\s*{[^}]*?usedExports:\\s*(?!true)` – Enable tree shaking by setting 'usedExports' to true.
- pattern `output\\s*:\\s*{[^}]*?filename:\\s*['\"][^\\[]+['\"]` – Use content hashing in filenames for better caching (e.g., '[name].[contenthash].js').

## Suggestions
- Guidance:
**Build Optimization Best Practices:**
- **Code Splitting:** Implement code splitting to load only what's necessary for each page or component.
- **Tree Shaking:** Enable tree shaking to eliminate dead code, which reduces bundle size.
- **Asset Optimization:**
- Compress images and use modern formats like WebP where supported.
- Use lazy loading for images and other media.
- **Caching:**
- Configure proper caching strategies (e.g., HTTP headers, service workers for PWA).
- Use long-term caching for static assets with content hashing in filenames.
- **Modern JavaScript:**
- Use ES6+ features but ensure polyfills for older browsers if needed.
- Consider using features like module/nomodule for graceful degradation.
- **Minification & Compression:** Ensure all JavaScript and CSS are minified and consider enabling gzip compression on the server.
- **Performance Budgets:** Set performance budgets to keep bundle sizes in check.
- **Environment Variables:** Use environment variables for configuration differentiation between development and production.
- **CI/CD:** Integrate with CI/CD pipelines for automated builds and testing, ensuring only optimized code goes to production.

## Metadata
- Priority: high
- Version: 1.2
Loading