diff --git a/rules-mdc/backend_frameworks/rust/actix-web.mdc b/rules-mdc/actix-web.mdc similarity index 100% rename from rules-mdc/backend_frameworks/rust/actix-web.mdc rename to rules-mdc/actix-web.mdc diff --git a/rules-mdc/ai_ml/cloud_inference/modal.mdc b/rules-mdc/ai_ml/cloud_inference/modal.mdc deleted file mode 100644 index fbf976f..0000000 --- a/rules-mdc/ai_ml/cloud_inference/modal.mdc +++ /dev/null @@ -1,174 +0,0 @@ ---- -description: This rule provides comprehensive best practices for developing with the modal library, covering code organization, performance, security, testing, and common pitfalls. It aims to guide developers towards writing maintainable, efficient, and secure modal applications. -globs: **/*.py ---- -- **Purpose and Clarity:** Ensure the modal's title clearly states its purpose and use concise headers. Use power words to grab attention (e.g., 'New,' 'Exclusive,' 'You'). -- **User Control:** Modals should only be used for critical information and should not disrupt the user experience. Provide visible options for users to close the modal easily. Use a dark overlay to guide attention. -- **Accessibility:** Test modals with assistive technologies to ensure they are accessible to all users. Limit the use of system-initiated modals to avoid user frustration. Adhere to WAI-ARIA guidelines for modal implementation. - -## 1. Code Organization and Structure - -- **Directory Structure:** - - `modal.py`: Core module containing the `modal` class and related functions. - - `modal/`: A directory containing submodules: - - `modal/config.py`: Configuration settings for modal deployment and runtime. - - `modal/stub.py`: Definition and handling of modal stubs for local development. - - `modal/secret.py`: Secure handling of secrets required by modal applications. - - `modal/image.py`: Image definition and building processes. - - `modal/volume.py`: Management of persistent volumes for data storage. -- **File Naming Conventions:** Use descriptive names (e.g., `modal_api.py`, `modal_utils.py`). Follow PEP 8 guidelines for Python file names. -- **Module Organization:** Group related functionality into modules (e.g., `modal.network`, `modal.security`). -- **Component Architecture:** - - Decouple components for reusability and testability. - - Use dependency injection to manage dependencies between components. -- **Code Splitting Strategies:** Break down large files into smaller, more manageable modules. Consider lazy-loading modules that are not immediately needed. - -## 2. Common Patterns and Anti-patterns - -- **Design Patterns:** - - **Singleton:** Use sparingly, typically for global configuration objects. - - **Factory:** For creating modal objects with complex initialization logic. - - **Observer:** For handling events triggered by modal state changes. -- **Recommended Approaches:** - - Use context managers (`with` statement) for resource management. - - Employ decorators for adding functionality (e.g., caching, logging). -- **Anti-patterns:** - - Avoid global state, as it can lead to unpredictable behavior. - - Avoid deeply nested code, which is hard to read and maintain. - - Avoid hardcoding configuration values. -- **State Management:** - - Use immutable data structures for state to prevent unintended modifications. - - Implement clear state transition logic. - - Consider using a state management library like `modal.aio_libs.AioState` for complex scenarios. -- **Error Handling:** - - Use try-except blocks to handle potential exceptions. - - Log errors with sufficient context for debugging. - - Raise custom exceptions for specific error conditions. - -## 3. Performance Considerations - -- **Optimization Techniques:** - - Use caching to avoid redundant computations. - - Profile code to identify performance bottlenecks. - - Optimize database queries. -- **Memory Management:** - - Use generators to process large datasets in chunks. - - Explicitly release resources when they are no longer needed. - - Be mindful of memory leaks. -- **Rendering Optimization:** (If applicable for UI elements within modal). - - Minimize DOM manipulations. - - Use efficient rendering algorithms. -- **Bundle Size Optimization:** - - Remove unused code. - - Use code minification and compression. - - Leverage tree shaking to eliminate dead code. -- **Lazy Loading:** Defer loading non-critical resources until they are needed. - -## 4. Security Best Practices - -- **Common Vulnerabilities:** - - Input validation vulnerabilities (e.g., SQL injection, cross-site scripting). - - Authentication and authorization vulnerabilities. - - Data breaches due to insecure storage. -- **Input Validation:** - - Validate all user inputs before processing them. - - Use input sanitization techniques to prevent injection attacks. -- **Authentication and Authorization:** - - Use strong authentication mechanisms (e.g., multi-factor authentication). - - Implement role-based access control. - - Securely store and manage user credentials using `modal.Secret`. -- **Data Protection:** - - Encrypt sensitive data at rest and in transit. - - Use secure communication protocols (e.g., HTTPS). - - Comply with relevant data privacy regulations (e.g., GDPR, CCPA). -- **Secure API Communication:** - - Use API keys or tokens for authentication. - - Rate limit API requests to prevent abuse. - - Implement proper error handling to avoid leaking sensitive information. - -## 5. Testing Approaches - -- **Unit Testing:** - - Test individual functions and classes in isolation. - - Use mocking to isolate dependencies. - - Write test cases for different scenarios, including edge cases. -- **Integration Testing:** - - Test the interaction between different components. - - Verify that data flows correctly between modules. -- **End-to-end Testing:** - - Test the entire application workflow. - - Simulate user interactions to verify functionality. -- **Test Organization:** - - Organize tests into separate directories based on the module being tested. - - Use descriptive test names. -- **Mocking and Stubbing:** - - Use mocking to replace external dependencies with controlled substitutes. - - Use stubs to provide predefined responses for external calls. - -## 6. Common Pitfalls and Gotchas - -- **Frequent Mistakes:** - - Incorrectly handling asynchronous operations. - - Not properly closing resources (e.g., files, network connections). - - Ignoring error conditions. -- **Edge Cases:** - - Handling empty or invalid input data. - - Dealing with network timeouts and failures. - - Ensuring compatibility with different operating systems and environments. -- **Version-Specific Issues:** - - Be aware of breaking changes in newer versions of the library. - - Check the release notes for known issues and workarounds. -- **Compatibility Concerns:** - - Ensure compatibility with different Python versions. - - Consider cross-platform compatibility. -- **Debugging Strategies:** - - Use debuggers to step through code and inspect variables. - - Use logging to track program execution and identify errors. - - Use assertions to verify expected conditions. - -## 7. Tooling and Environment - -- **Recommended Development Tools:** - - IDE: VS Code, PyCharm. - - Debugger: pdb, ipdb. - - Profiler: cProfile. -- **Build Configuration:** - - Use a build system like `setuptools` or `poetry` to manage dependencies and create distributable packages. -- **Linting and Formatting:** - - Use linters (e.g., pylint, flake8) to enforce coding style guidelines. - - Use formatters (e.g., black, autopep8) to automatically format code. -- **Deployment Best Practices:** - - Use containerization (e.g., Docker) to create consistent and reproducible environments. - - Use infrastructure-as-code (e.g., Terraform, CloudFormation) to automate infrastructure provisioning. -- **CI/CD Integration:** - - Use CI/CD pipelines to automatically build, test, and deploy code changes. - - Integrate linters and formatters into the CI/CD pipeline. - -## 8. modal Specific Best Practices - -- **Efficient Use of Images:** - - Use pre-built base images whenever possible to reduce build times. - - Leverage caching mechanisms in `modal.Image` to avoid rebuilding unchanged images. -- **Data Serialization:** - - Be aware of the data serialization overhead when passing data between modal functions. - - Use efficient serialization formats like `pickle` or `protobuf` for large datasets. -- **Secret Management:** - - Use `modal.Secret` to securely manage sensitive information like API keys and passwords. - - Avoid hardcoding secrets in your code. -- **Concurrency and Parallelism:** - - Utilize `modal.method.call` and `modal.Queue` for concurrent and parallel processing. - - Understand the limitations of Python's Global Interpreter Lock (GIL) when writing multi-threaded code. -- **Resource Limits:** - - Be aware of resource limits (CPU, memory, disk space) imposed by the modal platform. - - Optimize your code to stay within these limits. -- **Monitoring and Logging:** - - Implement monitoring and logging to track the performance of your modal applications. - - Use tools like Prometheus and Grafana for visualization. -- **Cold Starts:** - - Be aware of cold start times when invoking modal functions for the first time. - - Optimize your code to reduce cold start times. -- **Version Control and Rollbacks:** - - Always use version control (e.g., Git) to track changes to your code. - - Implement rollback mechanisms to quickly revert to previous versions in case of errors. - -By following these best practices, developers can build robust, scalable, and secure modal applications. \ No newline at end of file diff --git a/rules-mdc/frontend_frameworks/angular/angular.mdc b/rules-mdc/angular.mdc similarity index 100% rename from rules-mdc/frontend_frameworks/angular/angular.mdc rename to rules-mdc/angular.mdc diff --git a/rules-mdc/web_technologies/api/apollo-client.mdc b/rules-mdc/apollo-client.mdc similarity index 100% rename from rules-mdc/web_technologies/api/apollo-client.mdc rename to rules-mdc/apollo-client.mdc diff --git a/rules-mdc/cloud_platforms/serverless/aws-lambda.mdc b/rules-mdc/aws-lambda.mdc similarity index 100% rename from rules-mdc/cloud_platforms/serverless/aws-lambda.mdc rename to rules-mdc/aws-lambda.mdc diff --git a/rules-mdc/cloud_platforms/major_platforms/aws.mdc b/rules-mdc/aws.mdc similarity index 100% rename from rules-mdc/cloud_platforms/major_platforms/aws.mdc rename to rules-mdc/aws.mdc diff --git a/rules-mdc/web_technologies/http_client/axios.mdc b/rules-mdc/axios.mdc similarity index 100% rename from rules-mdc/web_technologies/http_client/axios.mdc rename to rules-mdc/axios.mdc diff --git a/rules-mdc/cloud_platforms/major_platforms/azure.mdc b/rules-mdc/azure.mdc similarity index 100% rename from rules-mdc/cloud_platforms/major_platforms/azure.mdc rename to rules-mdc/azure.mdc diff --git a/rules-mdc/backend_frameworks/nodejs/bun.mdc b/rules-mdc/bun.mdc similarity index 100% rename from rules-mdc/backend_frameworks/nodejs/bun.mdc rename to rules-mdc/bun.mdc diff --git a/rules-mdc/ui_libraries/component_libraries/chakra-ui.mdc b/rules-mdc/chakra-ui.mdc similarity index 100% rename from rules-mdc/ui_libraries/component_libraries/chakra-ui.mdc rename to rules-mdc/chakra-ui.mdc diff --git a/rules-mdc/cloud_platforms/serverless/modal.mdc b/rules-mdc/cloud_platforms/serverless/modal.mdc deleted file mode 100644 index b0b821d..0000000 --- a/rules-mdc/cloud_platforms/serverless/modal.mdc +++ /dev/null @@ -1,210 +0,0 @@ ---- -description: This rule outlines best practices for developing and maintaining modal libraries, covering aspects from code organization and performance to security and testing. It aims to guide developers in creating robust, efficient, and user-friendly modal components. -globs: **/*.{js,jsx,ts,tsx,mjs,cjs} ---- -- **Library Information:** - - Name: modal - - Category: cloud_platforms - - Subcategory: serverless - -- **General Principles:** - - **Clarity and Purpose:** Modals should have a clear and concise purpose, conveyed through a descriptive title. Content should be helpful and action-oriented. - - **User Control:** Prioritize user control by using modals sparingly and providing visible, intuitive close options (e.g., close button, overlay click). - - **Accessibility:** Ensure modals are accessible to all users by testing with assistive technologies and adhering to accessibility standards (e.g., ARIA attributes). - -- **Code Organization and Structure:** - - **Directory Structure:** - - `src/`: Contains the source code of the modal library. - - `components/`: Reusable modal components (e.g., `Modal.jsx`, `ModalHeader.jsx`, `ModalBody.jsx`, `ModalFooter.jsx`). - - `hooks/`: Custom hooks for managing modal state and logic (e.g., `useModal.js`). - - `utils/`: Utility functions (e.g., validation, formatting). - - `styles/`: CSS or styling components. - - `types/`: TypeScript type definitions. - - `examples/`: Example usage of the modal library. - - `tests/`: Unit and integration tests. - - `docs/`: Documentation for the library. - - **File Naming Conventions:** - - Use descriptive names for components (e.g., `ConfirmationModal.jsx`, `InputModal.jsx`). - - Follow a consistent naming convention (e.g., PascalCase for components, camelCase for variables and functions). - - **Module Organization:** - - Organize code into logical modules and submodules. Each module should have a specific responsibility. - - Use ES modules (import/export) for modularity and tree-shaking. - - **Component Architecture:** - - Favor a component-based architecture. Each modal element (header, body, footer) should be a reusable component. - - Use composition to create complex modals from smaller, reusable components. - - **Code Splitting Strategies:** - - Consider code splitting for large modal libraries to improve initial load time. - - Lazy load modal content or components that are not immediately needed. - -- **Common Patterns and Anti-patterns:** - - **Design Patterns:** - - **Controlled Components:** Use controlled components for modal content to manage state effectively. - - **Render Props or Hooks:** Provide flexibility in rendering modal content using render props or custom hooks. - - **Provider Pattern:** Use a context provider to manage global modal state and configuration. - - **Recommended Approaches:** - - Use a state management library (e.g., Zustand, Jotai) for complex modal state. - - Implement a modal queue to manage multiple modals efficiently. - - Provide a consistent API for opening and closing modals. - - **Anti-patterns:** - - **Overusing Modals:** Avoid using modals for non-critical information or actions. - - **Deeply Nested Components:** Minimize deeply nested components within modals to improve performance. - - **Ignoring Accessibility:** Neglecting accessibility can make the modal unusable for some users. - - **State Management Best Practices:** - - Choose a state management solution that fits the complexity of the modal library. - - Keep state minimal and derive values when possible. - - Use immutable data structures to prevent unexpected side effects. - - **Error Handling Patterns:** - - Implement error boundaries to catch errors within modals. - - Provide informative error messages to the user. - - Log errors for debugging purposes. - -- **Performance Considerations:** - - **Optimization Techniques:** - - Memoize components to prevent unnecessary re-renders. - - Use virtualization for long lists of modal content. - - Debounce or throttle event handlers to improve responsiveness. - - **Memory Management:** - - Clean up event listeners and timers when the modal is closed. - - Avoid creating large data structures within modals. - - Release resources when the modal is unmounted. - - **Rendering Optimization:** - - Use CSS transforms for animations instead of modifying layout properties. - - Minimize the number of DOM updates. - - Use techniques like `requestAnimationFrame` for smoother animations. - - **Bundle Size Optimization:** - - Use tree-shaking to remove unused code from the bundle. - - Minify and compress the code. - - Use code splitting to reduce the initial bundle size. - - **Lazy Loading Strategies:** - - Lazy load modal content or components that are not immediately visible. - - Use dynamic imports to load modules on demand. - -- **Security Best Practices:** - - **Common Vulnerabilities:** - - **Cross-Site Scripting (XSS):** Sanitize user inputs to prevent XSS attacks. - - **Injection Attacks:** Protect against injection attacks by validating user inputs. - - **Input Validation:** - - Validate all user inputs within the modal. - - Use appropriate data types and formats. - - Sanitize inputs to remove malicious code. - - **Authentication and Authorization Patterns:** - - Implement authentication and authorization mechanisms to protect sensitive data. - - Use secure cookies or tokens to store user credentials. - - Enforce access control policies. - - **Data Protection Strategies:** - - Encrypt sensitive data at rest and in transit. - - Use secure storage mechanisms to protect data. - - Implement data loss prevention measures. - - **Secure API Communication:** - - Use HTTPS for all API communication. - - Validate API responses. - - Protect API keys and secrets. - -- **Testing Approaches:** - - **Unit Testing Strategies:** - - Test individual components and functions in isolation. - - Use mocking and stubbing to isolate dependencies. - - Test edge cases and error conditions. - - **Integration Testing:** - - Test the interaction between components and modules. - - Verify that the modal works correctly with other parts of the application. - - **End-to-End Testing:** - - Test the entire modal workflow from start to finish. - - Use automated testing tools to simulate user interactions. - - **Test Organization:** - - Organize tests into logical groups based on functionality. - - Use descriptive test names. - - Keep tests concise and focused. - - **Mocking and Stubbing:** - - Use mocking to simulate external dependencies. - - Use stubbing to replace complex functions with simpler versions. - - Avoid over-mocking, as it can lead to brittle tests. - -- **Common Pitfalls and Gotchas:** - - **Frequent Mistakes:** - - Forgetting to handle focus management when opening/closing modal - - Not properly managing the stacking context of modals. - - Ignoring keyboard navigation. - - **Edge Cases:** - - Handling modals within modals. - - Supporting different screen sizes and orientations. - - Handling modals in server-side rendered applications. - - **Version-Specific Issues:** - - Be aware of compatibility issues with different versions of dependencies. - - Test the modal library with different browsers and devices. - - **Compatibility Concerns:** - - Ensure the modal library is compatible with different JavaScript frameworks and libraries. - - Test with different browsers and devices. - - **Debugging Strategies:** - - Use browser developer tools to inspect the modal's HTML and CSS. - - Use logging to track the flow of execution. - - Use a debugger to step through the code. - -- **Tooling and Environment:** - - **Recommended Development Tools:** - - VS Code with extensions for React/TypeScript/ESLint. - - Chrome DevTools for debugging. - - **Build Configuration:** - - Use a build tool like webpack, Parcel, or Rollup. - - Configure the build tool to optimize the bundle size. - - **Linting and Formatting:** - - Use ESLint to enforce code style and detect potential errors. - - Use Prettier to automatically format the code. - - **Deployment Best Practices:** - - Deploy the modal library to a CDN for fast and reliable delivery. - - Use version control to track changes to the code. - - Automate the deployment process. - - **CI/CD Integration:** - - Integrate the modal library with a CI/CD pipeline for automated testing and deployment. - - Use a CI/CD tool like Jenkins, Travis CI, or CircleCI. - -- **Accessibility Considerations (WCAG Compliance):** - - **Keyboard Navigation:** Ensure all interactive elements within the modal are reachable and operable using the keyboard. Use tab index appropriately. - - **Focus Management:** Trap focus within the modal when it's open. Return focus to the previously focused element when the modal is closed. Prevent focus leaking to elements behind the modal. - - **ARIA Attributes:** - - Use `role="dialog"` or `role="alertdialog"` to indicate the modal's purpose. - - Use `aria-labelledby` to associate the modal's title with the modal element. - - Use `aria-describedby` to associate the modal's content with the modal element. - - Implement `aria-modal="true"` to signify the modal is blocking interaction with the rest of the page. - - **Color Contrast:** Ensure sufficient color contrast between text and background elements. - - **Screen Reader Compatibility:** Test the modal with screen readers to ensure content is read correctly and controls are accessible. - - **Visual Cues:** Provide clear visual cues to indicate the active element. - - **Alternative Text:** Ensure images have descriptive alternative text. - -- **UI/UX Best Practices:** - - **Modal Size and Positioning:** Ensure the modal is appropriately sized and positioned on the screen. Avoid modals that are too large or obstruct important content. - - **Animation and Transitions:** Use subtle animations and transitions to enhance the user experience. Avoid excessive or distracting animations. - - **Responsiveness:** Ensure the modal is responsive and adapts to different screen sizes and orientations. - - **Dark Overlay:** Use a dark overlay to dim the background and focus the user's attention on the modal. The overlay should be semi-transparent. - - **Clear Calls to Action:** Use clear and concise button labels for calls to action. Avoid ambiguous or confusing labels. - -- **Example Snippets (Illustrative):** - - **React Component:** - jsx - import React, { useState } from 'react'; - - const Modal = ({ isOpen, onClose, children }) => { - if (!isOpen) return null; - - return ( - - - {children} - - - - ); - }; - - export default Modal; - - - **TypeScript Type Definitions:** - typescript - interface ModalProps { - isOpen: boolean; - onClose: () => void; - children: React.ReactNode; - } - - -By adhering to these best practices, you can create robust, accessible, and user-friendly modal libraries that enhance the overall user experience of your applications. \ No newline at end of file diff --git a/rules-mdc/cloud_platforms/deployment/cloudflare.mdc b/rules-mdc/cloudflare.mdc similarity index 100% rename from rules-mdc/cloud_platforms/deployment/cloudflare.mdc rename to rules-mdc/cloudflare.mdc diff --git a/rules-mdc/web_technologies/styling/css.mdc b/rules-mdc/css.mdc similarity index 100% rename from rules-mdc/web_technologies/styling/css.mdc rename to rules-mdc/css.mdc diff --git a/rules-mdc/ai_ml/gpu_computing/cuda.mdc b/rules-mdc/cuda.mdc similarity index 100% rename from rules-mdc/ai_ml/gpu_computing/cuda.mdc rename to rules-mdc/cuda.mdc diff --git a/rules-mdc/development_tools/testing/detox.mdc b/rules-mdc/detox.mdc similarity index 100% rename from rules-mdc/development_tools/testing/detox.mdc rename to rules-mdc/detox.mdc diff --git a/rules-mdc/backend_frameworks/python/django.mdc b/rules-mdc/django.mdc similarity index 100% rename from rules-mdc/backend_frameworks/python/django.mdc rename to rules-mdc/django.mdc diff --git a/rules-mdc/development_tools/containerization/docker.mdc b/rules-mdc/docker.mdc similarity index 100% rename from rules-mdc/development_tools/containerization/docker.mdc rename to rules-mdc/docker.mdc diff --git a/rules-mdc/database_tools/analytics/duckdb.mdc b/rules-mdc/duckdb.mdc similarity index 100% rename from rules-mdc/database_tools/analytics/duckdb.mdc rename to rules-mdc/duckdb.mdc diff --git a/rules-mdc/cross_platform/desktop/electron.mdc b/rules-mdc/electron.mdc similarity index 100% rename from rules-mdc/cross_platform/desktop/electron.mdc rename to rules-mdc/electron.mdc diff --git a/rules-mdc/cross_platform/mobile/expo.mdc b/rules-mdc/expo.mdc similarity index 100% rename from rules-mdc/cross_platform/mobile/expo.mdc rename to rules-mdc/expo.mdc diff --git a/rules-mdc/backend_frameworks/nodejs/express.mdc b/rules-mdc/express.mdc similarity index 100% rename from rules-mdc/backend_frameworks/nodejs/express.mdc rename to rules-mdc/express.mdc diff --git a/rules-mdc/backend_frameworks/python/fastapi.mdc b/rules-mdc/fastapi.mdc similarity index 100% rename from rules-mdc/backend_frameworks/python/fastapi.mdc rename to rules-mdc/fastapi.mdc diff --git a/rules-mdc/backend_frameworks/go/fiber.mdc b/rules-mdc/fiber.mdc similarity index 100% rename from rules-mdc/backend_frameworks/go/fiber.mdc rename to rules-mdc/fiber.mdc diff --git a/rules-mdc/backend_frameworks/python/flask.mdc b/rules-mdc/flask.mdc similarity index 100% rename from rules-mdc/backend_frameworks/python/flask.mdc rename to rules-mdc/flask.mdc diff --git a/rules-mdc/cross_platform/mobile/flutter.mdc b/rules-mdc/flutter.mdc similarity index 100% rename from rules-mdc/cross_platform/mobile/flutter.mdc rename to rules-mdc/flutter.mdc diff --git a/rules-mdc/frontend_frameworks/react/react-native.mdc b/rules-mdc/frontend_frameworks/react/react-native.mdc deleted file mode 100644 index 59e8b08..0000000 --- a/rules-mdc/frontend_frameworks/react/react-native.mdc +++ /dev/null @@ -1,196 +0,0 @@ ---- -description: This rule provides comprehensive guidelines for React Native development, covering code organization, performance, security, testing, and common pitfalls. Adhering to these practices ensures maintainable, scalable, and efficient React Native applications. -globs: **/*.{js,jsx,ts,tsx} ---- -# React Native Best Practices - -This document outlines best practices for developing React Native applications, covering various aspects from code organization to performance optimization. - -## 1. Code Organization and Structure - -* **Directory Structure:** - * Adopt a scalable and maintainable directory structure. Feature-based organization is often preferred. - * Example: - - src/ - ├── components/ # Reusable UI components - ├── screens/ # App screens/views - ├── navigation/ # Navigation configurations - ├── services/ # API services and data fetching - ├── utils/ # Utility functions - ├── constants/ # Constant values - ├── context/ # React Context providers - ├── types/ # TypeScript type definitions - └── App.tsx # Root component - -* **File Naming Conventions:** - * Use descriptive and consistent file names. - * Components: `ComponentName.tsx` (or `.jsx`) - * Styles: `ComponentName.styles.ts` (or `.js`) - * Utility functions: `utilityName.ts` (or `.js`) - * Consider using kebab-case for folders. -* **Module Organization:** - * Group related components, styles, and assets within the same directory. - * Use `index.ts` (or `.js`) files to export modules, simplifying imports. - * Example: - - // components/Button/index.ts - export { default as Button } from './Button'; - -* **Component Architecture:** - * Favor functional components with hooks over class components. - * Separate concerns using container and presentational components. - * **Container components:** Handle data fetching and state management. - * **Presentational components:** Focus on rendering UI based on props. - * Use composition to create flexible and reusable components. -* **Code Splitting Strategies:** - * Implement lazy loading for screens and components to reduce initial bundle size. - * Use `React.lazy` and `Suspense` for code splitting. - * Dynamic imports can be useful for loading non-critical modules on demand. - -## 2. Common Patterns and Anti-patterns - -* **Design Patterns:** - * **Higher-Order Components (HOCs):** Wrap components with shared logic. - * **Render Props:** Share code between React components using a prop whose value is a function. - * **Hooks:** Extract stateful logic into reusable functions. - * **Compound Components:** Allow components to implicitly share state (e.g., Tabs). -* **Recommended Approaches:** - * **State Management:** Use appropriate state management solutions (e.g., Redux, Zustand, React Context) based on the application's complexity. For local state management, `useState` and `useReducer` hooks are preferred. - * **API Calls:** Use `async/await` for asynchronous operations and handle errors gracefully. - * **Navigation:** Utilize `react-navigation` or `react-native-navigation` for screen transitions and navigation logic. -* **Anti-patterns:** - * **Mutating state directly:** Use `setState` or state update functions from hooks. - * **Passing too many props:** Refactor components or use context to share data. - * **Overusing global state:** Consider component-level state when appropriate. - * **Long functions:** Break down functions into smaller, more manageable pieces. -* **State Management Best Practices:** - * Choose the right state management tool for the job (Context API, Redux, Zustand, Recoil). - * Keep state minimal and derive values when possible. - * Use immutable data structures to simplify state updates. - * Optimize re-renders by using `React.memo`, `useMemo`, and `useCallback`. -* **Error Handling Patterns:** - * Use `try/catch` blocks to handle synchronous errors. - * Implement error boundaries to catch errors in React components. - * Log errors to a monitoring service for tracking and analysis (e.g., Sentry, Bugsnag). - * Provide user-friendly error messages and recovery options. - -## 3. Performance Considerations - -* **Optimization Techniques:** - * **Memoization:** Use `React.memo` to prevent unnecessary re-renders of components. - * **PureComponent:** Use `PureComponent` for class components to perform shallow prop comparisons. - * **Virtualization:** Use `FlatList` or `SectionList` for rendering large lists of data efficiently. - * **Debouncing and Throttling:** Limit the rate at which functions are executed in response to rapid events (e.g., scrolling, typing). -* **Memory Management:** - * Avoid memory leaks by properly cleaning up event listeners and timers in `useEffect` hooks. - * Release resources when components unmount. - * Be mindful of image sizes and optimize them for mobile devices. -* **Rendering Optimization:** - * Minimize the number of re-renders by using `useCallback` and `useMemo` to memoize functions and values. - * Avoid inline function definitions in render methods. - * Use `shouldComponentUpdate` (for class components) or `React.memo` to prevent unnecessary renders. -* **Bundle Size Optimization:** - * Use code splitting to reduce the initial bundle size. - * Remove unused code using tree shaking. - * Optimize image assets using tools like ImageOptim or TinyPNG. - * Analyze bundle size using tools like `webpack-bundle-analyzer`. -* **Lazy Loading Strategies:** - * Implement lazy loading for images using libraries like `react-native-fast-image`. - * Lazy load components using `React.lazy` and `Suspense`. - -## 4. Security Best Practices - -* **Common Vulnerabilities:** - * **Cross-Site Scripting (XSS):** Prevent XSS attacks by sanitizing user input before rendering it in the UI. - * **SQL Injection:** Use parameterized queries or ORMs to prevent SQL injection attacks. - * **Insecure Data Storage:** Avoid storing sensitive data in plain text on the device. - * **Man-in-the-Middle (MITM) Attacks:** Use HTTPS to encrypt communication between the app and the server. -* **Input Validation:** - * Validate all user input on both the client and server sides. - * Use regular expressions to enforce input formats. - * Sanitize input to remove potentially malicious characters. -* **Authentication and Authorization Patterns:** - * Use secure authentication methods like OAuth 2.0 or JWT. - * Implement role-based access control to restrict access to sensitive data and functionality. - * Store authentication tokens securely using the device's keychain or secure storage. -* **Data Protection Strategies:** - * Encrypt sensitive data at rest using encryption libraries. - * Use secure storage options provided by the platform (e.g., Keychain on iOS, KeyStore on Android). - * Avoid logging sensitive data. -* **Secure API Communication:** - * Use HTTPS for all API communication. - * Implement proper authentication and authorization for API endpoints. - * Protect against CSRF attacks by using anti-CSRF tokens. - * Rate limit API requests to prevent abuse. - -## 5. Testing Approaches - -* **Unit Testing:** - * Test individual components and functions in isolation. - * Use testing frameworks like Jest or Mocha. - * Write tests for edge cases and error conditions. -* **Integration Testing:** - * Test the interaction between different components and modules. - * Verify that data flows correctly between different parts of the application. -* **End-to-End Testing:** - * Test the entire application flow from start to finish. - * Use testing frameworks like Detox or Appium. - * Run tests on real devices or emulators. -* **Test Organization:** - * Organize tests in a way that mirrors the application's directory structure. - * Use descriptive test names to clearly indicate what is being tested. - * Keep tests small and focused. -* **Mocking and Stubbing:** - * Use mocking libraries like Jest's `jest.mock` to isolate components during testing. - * Stub out dependencies to control their behavior. - -## 6. Common Pitfalls and Gotchas - -* **Frequent Mistakes:** - * **Incorrectly using `setState`:** Understand the asynchronous nature of `setState` and use functional updates when necessary. - * **Not optimizing images:** Large images can significantly impact performance. - * **Ignoring memory leaks:** Failing to clean up event listeners and timers can lead to memory leaks. - * **Over-rendering:** Unnecessary re-renders can degrade performance. -* **Edge Cases:** - * **Handling different screen sizes and densities:** Use responsive design techniques to adapt to various screen sizes. - * **Dealing with network latency:** Implement loading indicators and error handling for API requests. - * **Handling different locales and languages:** Use internationalization (i18n) libraries to support multiple languages. -* **Version-Specific Issues:** - * Be aware of breaking changes in React Native updates. - * Test your application on different versions of React Native to ensure compatibility. - * Use `react-native-upgrade-helper` to help with upgrades. -* **Compatibility Concerns:** - * Test your application on different devices and operating systems. - * Be aware of platform-specific APIs and features. - * Use conditional rendering or platform-specific code when necessary. -* **Debugging Strategies:** - * Use the React Native debugger to inspect component state and props. - * Use `console.log` statements to trace code execution. - * Use error logging to capture and track errors. - * Learn to use the Chrome Developer Tools for debugging JavaScript code. - -## 7. Tooling and Environment - -* **Recommended Development Tools:** - * **VS Code:** A popular code editor with excellent React Native support. - * **React Native Debugger:** A standalone debugger for React Native applications. - * **Expo CLI:** A tool for creating, building, and deploying React Native applications. - * **Android Studio/Xcode:** The official IDEs for Android and iOS development, respectively. -* **Build Configuration:** - * Use environment variables to configure different build environments (e.g., development, staging, production). - * Optimize build settings for performance. -* **Linting and Formatting:** - * Use ESLint and Prettier to enforce code style and prevent errors. - * Configure ESLint with React Native-specific rules. - * Use a pre-commit hook to automatically format code before committing. -* **Deployment Best Practices:** - * Use code signing to ensure the integrity of your application. - * Follow the platform-specific deployment guidelines (e.g., Google Play Store, Apple App Store). - * Use a continuous integration/continuous deployment (CI/CD) pipeline to automate the deployment process. -* **CI/CD Integration:** - * Use CI/CD tools like Jenkins, CircleCI, or GitHub Actions to automate building, testing, and deploying your application. - * Configure CI/CD to run unit tests, integration tests, and end-to-end tests. - * Automate the process of creating and deploying release builds. - -By following these best practices, you can develop robust, scalable, and maintainable React Native applications. \ No newline at end of file diff --git a/rules-mdc/cloud_platforms/major_platforms/gcp.mdc b/rules-mdc/gcp.mdc similarity index 100% rename from rules-mdc/cloud_platforms/major_platforms/gcp.mdc rename to rules-mdc/gcp.mdc diff --git a/rules-mdc/development_tools/version_control/git.mdc b/rules-mdc/git.mdc similarity index 100% rename from rules-mdc/development_tools/version_control/git.mdc rename to rules-mdc/git.mdc diff --git a/rules-mdc/development_tools/ci_cd/github-actions.mdc b/rules-mdc/github-actions.mdc similarity index 100% rename from rules-mdc/development_tools/ci_cd/github-actions.mdc rename to rules-mdc/github-actions.mdc diff --git a/rules-mdc/web_technologies/api/graphql.mdc b/rules-mdc/graphql.mdc similarity index 100% rename from rules-mdc/web_technologies/api/graphql.mdc rename to rules-mdc/graphql.mdc diff --git a/rules-mdc/web_technologies/http_client/guzzle.mdc b/rules-mdc/guzzle.mdc similarity index 100% rename from rules-mdc/web_technologies/http_client/guzzle.mdc rename to rules-mdc/guzzle.mdc diff --git a/rules-mdc/blockchain/ethereum/hardhat.mdc b/rules-mdc/hardhat.mdc similarity index 100% rename from rules-mdc/blockchain/ethereum/hardhat.mdc rename to rules-mdc/hardhat.mdc diff --git a/rules-mdc/web_technologies/modern_patterns/htmx.mdc b/rules-mdc/htmx.mdc similarity index 100% rename from rules-mdc/web_technologies/modern_patterns/htmx.mdc rename to rules-mdc/htmx.mdc diff --git a/rules-mdc/ai_ml/llm_tools/huggingface.mdc b/rules-mdc/huggingface.mdc similarity index 100% rename from rules-mdc/ai_ml/llm_tools/huggingface.mdc rename to rules-mdc/huggingface.mdc diff --git a/rules-mdc/development_tools/testing/jest.mdc b/rules-mdc/jest.mdc similarity index 100% rename from rules-mdc/development_tools/testing/jest.mdc rename to rules-mdc/jest.mdc diff --git a/rules-mdc/ui_libraries/mobile_ui/jetpack-compose.mdc b/rules-mdc/jetpack-compose.mdc similarity index 100% rename from rules-mdc/ui_libraries/mobile_ui/jetpack-compose.mdc rename to rules-mdc/jetpack-compose.mdc diff --git a/rules-mdc/development_tools/containerization/kubernetes.mdc b/rules-mdc/kubernetes.mdc similarity index 100% rename from rules-mdc/development_tools/containerization/kubernetes.mdc rename to rules-mdc/kubernetes.mdc diff --git a/rules-mdc/ai_ml/llm_tools/langchain.mdc b/rules-mdc/langchain.mdc similarity index 100% rename from rules-mdc/ai_ml/llm_tools/langchain.mdc rename to rules-mdc/langchain.mdc diff --git a/rules-mdc/backend_frameworks/php/laravel.mdc b/rules-mdc/laravel.mdc similarity index 100% rename from rules-mdc/backend_frameworks/php/laravel.mdc rename to rules-mdc/laravel.mdc diff --git a/rules-mdc/ui_libraries/component_libraries/material-ui.mdc b/rules-mdc/material-ui.mdc similarity index 100% rename from rules-mdc/ui_libraries/component_libraries/material-ui.mdc rename to rules-mdc/material-ui.mdc diff --git a/rules-mdc/development_tools/documentation/mkdocs.mdc b/rules-mdc/mkdocs.mdc similarity index 100% rename from rules-mdc/development_tools/documentation/mkdocs.mdc rename to rules-mdc/mkdocs.mdc diff --git a/rules-mdc/state_management/react/mobx.mdc b/rules-mdc/mobx.mdc similarity index 100% rename from rules-mdc/state_management/react/mobx.mdc rename to rules-mdc/mobx.mdc diff --git a/rules-mdc/cloud_platforms/deployment/modal.mdc b/rules-mdc/modal.mdc similarity index 100% rename from rules-mdc/cloud_platforms/deployment/modal.mdc rename to rules-mdc/modal.mdc diff --git a/rules-mdc/database_tools/nosql/mongodb.mdc b/rules-mdc/mongodb.mdc similarity index 100% rename from rules-mdc/database_tools/nosql/mongodb.mdc rename to rules-mdc/mongodb.mdc diff --git a/rules-mdc/backend_frameworks/nodejs/nestjs.mdc b/rules-mdc/nestjs.mdc similarity index 100% rename from rules-mdc/backend_frameworks/nodejs/nestjs.mdc rename to rules-mdc/nestjs.mdc diff --git a/rules-mdc/frontend_frameworks/react/next-js.mdc b/rules-mdc/next-js.mdc similarity index 100% rename from rules-mdc/frontend_frameworks/react/next-js.mdc rename to rules-mdc/next-js.mdc diff --git a/rules-mdc/frontend_frameworks/vue/nuxt.mdc b/rules-mdc/nuxt.mdc similarity index 100% rename from rules-mdc/frontend_frameworks/vue/nuxt.mdc rename to rules-mdc/nuxt.mdc diff --git a/rules-mdc/ai_ml/machine_learning/pandas.mdc b/rules-mdc/pandas.mdc similarity index 100% rename from rules-mdc/ai_ml/machine_learning/pandas.mdc rename to rules-mdc/pandas.mdc diff --git a/rules-mdc/development_tools/testing/playwright.mdc b/rules-mdc/playwright.mdc similarity index 100% rename from rules-mdc/development_tools/testing/playwright.mdc rename to rules-mdc/playwright.mdc diff --git a/rules-mdc/database_tools/sql/postgresql.mdc b/rules-mdc/postgresql.mdc similarity index 100% rename from rules-mdc/database_tools/sql/postgresql.mdc rename to rules-mdc/postgresql.mdc diff --git a/rules-mdc/database_tools/sql/prisma.mdc b/rules-mdc/prisma.mdc similarity index 100% rename from rules-mdc/database_tools/sql/prisma.mdc rename to rules-mdc/prisma.mdc diff --git a/rules-mdc/ai_ml/machine_learning/pytorch.mdc b/rules-mdc/pytorch.mdc similarity index 100% rename from rules-mdc/ai_ml/machine_learning/pytorch.mdc rename to rules-mdc/pytorch.mdc diff --git a/rules-mdc/frontend_frameworks/qwik/qwik.mdc b/rules-mdc/qwik.mdc similarity index 100% rename from rules-mdc/frontend_frameworks/qwik/qwik.mdc rename to rules-mdc/qwik.mdc diff --git a/rules-mdc/frontend_frameworks/react/react-mobx.mdc b/rules-mdc/react-mobx.mdc similarity index 100% rename from rules-mdc/frontend_frameworks/react/react-mobx.mdc rename to rules-mdc/react-mobx.mdc diff --git a/rules-mdc/cross_platform/mobile/react-native.mdc b/rules-mdc/react-native.mdc similarity index 100% rename from rules-mdc/cross_platform/mobile/react-native.mdc rename to rules-mdc/react-native.mdc diff --git a/rules-mdc/frontend_frameworks/react/react-query.mdc b/rules-mdc/react-query.mdc similarity index 100% rename from rules-mdc/frontend_frameworks/react/react-query.mdc rename to rules-mdc/react-query.mdc diff --git a/rules-mdc/frontend_frameworks/react/react-redux.mdc b/rules-mdc/react-redux.mdc similarity index 100% rename from rules-mdc/frontend_frameworks/react/react-redux.mdc rename to rules-mdc/react-redux.mdc diff --git a/rules-mdc/frontend_frameworks/react/react.mdc b/rules-mdc/react.mdc similarity index 100% rename from rules-mdc/frontend_frameworks/react/react.mdc rename to rules-mdc/react.mdc diff --git a/rules-mdc/database_tools/nosql/redis.mdc b/rules-mdc/redis.mdc similarity index 100% rename from rules-mdc/database_tools/nosql/redis.mdc rename to rules-mdc/redis.mdc diff --git a/rules-mdc/state_management/react/redux.mdc b/rules-mdc/redux.mdc similarity index 100% rename from rules-mdc/state_management/react/redux.mdc rename to rules-mdc/redux.mdc diff --git a/rules-mdc/state_management/flutter/riverpod.mdc b/rules-mdc/riverpod.mdc similarity index 100% rename from rules-mdc/state_management/flutter/riverpod.mdc rename to rules-mdc/riverpod.mdc diff --git a/rules-mdc/backend_frameworks/rust/rocket.mdc b/rules-mdc/rocket.mdc similarity index 100% rename from rules-mdc/backend_frameworks/rust/rocket.mdc rename to rules-mdc/rocket.mdc diff --git a/rules-mdc/ai_ml/machine_learning/scikit-learn.mdc b/rules-mdc/scikit-learn.mdc similarity index 100% rename from rules-mdc/ai_ml/machine_learning/scikit-learn.mdc rename to rules-mdc/scikit-learn.mdc diff --git a/rules-mdc/backend_frameworks/go/servemux.mdc b/rules-mdc/servemux.mdc similarity index 100% rename from rules-mdc/backend_frameworks/go/servemux.mdc rename to rules-mdc/servemux.mdc diff --git a/rules-mdc/ui_libraries/component_libraries/shadcn.mdc b/rules-mdc/shadcn.mdc similarity index 100% rename from rules-mdc/ui_libraries/component_libraries/shadcn.mdc rename to rules-mdc/shadcn.mdc diff --git a/rules-mdc/blockchain/ethereum/solidity.mdc b/rules-mdc/solidity.mdc similarity index 100% rename from rules-mdc/blockchain/ethereum/solidity.mdc rename to rules-mdc/solidity.mdc diff --git a/rules-mdc/frontend_frameworks/solid/solidjs.mdc b/rules-mdc/solidjs.mdc similarity index 100% rename from rules-mdc/frontend_frameworks/solid/solidjs.mdc rename to rules-mdc/solidjs.mdc diff --git a/rules-mdc/backend_frameworks/java/springboot.mdc b/rules-mdc/springboot.mdc similarity index 100% rename from rules-mdc/backend_frameworks/java/springboot.mdc rename to rules-mdc/springboot.mdc diff --git a/rules-mdc/database_tools/sql/supabase.mdc b/rules-mdc/supabase.mdc similarity index 100% rename from rules-mdc/database_tools/sql/supabase.mdc rename to rules-mdc/supabase.mdc diff --git a/rules-mdc/frontend_frameworks/svelte/svelte.mdc b/rules-mdc/svelte.mdc similarity index 100% rename from rules-mdc/frontend_frameworks/svelte/svelte.mdc rename to rules-mdc/svelte.mdc diff --git a/rules-mdc/frontend_frameworks/svelte/sveltekit.mdc b/rules-mdc/sveltekit.mdc similarity index 100% rename from rules-mdc/frontend_frameworks/svelte/sveltekit.mdc rename to rules-mdc/sveltekit.mdc diff --git a/rules-mdc/web_technologies/styling/tailwind.mdc b/rules-mdc/tailwind.mdc similarity index 100% rename from rules-mdc/web_technologies/styling/tailwind.mdc rename to rules-mdc/tailwind.mdc diff --git a/rules-mdc/cross_platform/desktop/tauri.mdc b/rules-mdc/tauri.mdc similarity index 100% rename from rules-mdc/cross_platform/desktop/tauri.mdc rename to rules-mdc/tauri.mdc diff --git a/rules-mdc/ai_ml/machine_learning/tensorflow.mdc b/rules-mdc/tensorflow.mdc similarity index 100% rename from rules-mdc/ai_ml/machine_learning/tensorflow.mdc rename to rules-mdc/tensorflow.mdc diff --git a/rules-mdc/development_tools/infrastructure/terraform.mdc b/rules-mdc/terraform.mdc similarity index 100% rename from rules-mdc/development_tools/infrastructure/terraform.mdc rename to rules-mdc/terraform.mdc diff --git a/rules-mdc/web_technologies/modern_patterns/trpc.mdc b/rules-mdc/trpc.mdc similarity index 100% rename from rules-mdc/web_technologies/modern_patterns/trpc.mdc rename to rules-mdc/trpc.mdc diff --git a/rules-mdc/development_tools/build_tools/turbopack.mdc b/rules-mdc/turbopack.mdc similarity index 100% rename from rules-mdc/development_tools/build_tools/turbopack.mdc rename to rules-mdc/turbopack.mdc diff --git a/rules-mdc/web_technologies/type_checking/typescript.mdc b/rules-mdc/typescript.mdc similarity index 100% rename from rules-mdc/web_technologies/type_checking/typescript.mdc rename to rules-mdc/typescript.mdc diff --git a/rules-mdc/ui_libraries/component_libraries/tailwind.mdc b/rules-mdc/ui_libraries/component_libraries/tailwind.mdc deleted file mode 100644 index 4f83404..0000000 --- a/rules-mdc/ui_libraries/component_libraries/tailwind.mdc +++ /dev/null @@ -1,92 +0,0 @@ ---- -description: Provides guidelines and best practices for effectively using Tailwind CSS, focusing on performance, organization, and maintainability. This rule ensures consistent styling and efficient component development across the project. -globs: **/*.{html,js,jsx,ts,tsx,vue,svelte} ---- -- **Leverage Tailwind's PurgeCSS:** Configure PurgeCSS properly to remove unused styles in production, drastically reducing the final CSS bundle size. Ensure you configure it to scan all relevant files (HTML, JS/TS components, etc.). - - Configure `tailwind.config.js` with the appropriate `content` array to ensure that PurgeCSS correctly identifies used classes. - - Use the JIT (Just-In-Time) compiler in development for faster build times and complete feature availability. - -- **Use Tailwind's Configuration File:** Customize Tailwind's default theme, colors, spacing, and breakpoints in the `tailwind.config.js` file. This ensures consistency across the project and allows for easy updates. - - Define a design system using semantic names for colors and spacing (e.g., `primary-brand`, `space-md`) rather than hardcoding values. - - Utilize Tailwind's theme extension feature to add custom styles without overriding the defaults. - -- **Adopt a Mobile-First Approach:** Design components and layouts starting with mobile devices and then progressively enhance them for larger screens using Tailwind's responsive modifiers (e.g., `sm:`, `md:`, `lg:`, `xl:`). - - Avoid deeply nested responsive modifiers. Refactor components to be more adaptable if necessary. - -- **Utilize Tailwind UI (if applicable):** If using Tailwind UI, leverage the pre-built components as a starting point and customize them to fit your project's specific needs. Be aware of licensing implications. - - Extract common patterns and modifications into reusable components to avoid repeating code. - -- **Optimize for Performance:** Beyond PurgeCSS, be mindful of CSS specificity and avoid overly complex selectors. Use Tailwind's `apply` directive judiciously. - - Use `@layer` directive in your CSS to organize your styles and improve performance. - - Consider CSS extraction and inlining critical CSS for faster initial page load. - - Profile your application's CSS to identify performance bottlenecks. - -- **Stay Organized with Components:** Break down complex UIs into smaller, reusable components. Use a consistent naming convention for component files and Tailwind classes. - - Create a component library to store and manage reusable components. - - Use tools like Storybook or Styleguidist to document and showcase components. - - Follow the principles of atomic design when structuring your components. - -- **Integrate with a Design System:** Define a clear design system with consistent typography, colors, and spacing. Use Tailwind's configuration file to enforce these standards. - - Document the design system and make it accessible to all team members. - - Use design tokens to manage and update design values across the project. - -- **Code Organization and Structure:** - - **Directory Structure:** Organize components into logical directories based on functionality or page sections (e.g., `components/`, `pages/`, `layouts/`). - - **File Naming Conventions:** Use descriptive and consistent file names for components (e.g., `Button.jsx`, `Card.vue`). - - **Module Organization:** Group related components and utilities into modules. - - **Component Architecture:** Favor composition over inheritance when building components. Use functional components and hooks where appropriate. - - **Code Splitting:** Implement code splitting to reduce initial load time. Use dynamic imports to load components on demand. - -- **Common Patterns and Anti-patterns:** - - **Design Patterns:** Use the composite pattern for building complex UIs from smaller components. Use the provider pattern for managing global state. - - **Recommended Approaches:** Use Tailwind's utility classes for styling elements. Create custom components for complex or reusable styles. - - **Anti-patterns:** Avoid using inline styles or `!important` declarations. Avoid overly specific CSS selectors. - - **State Management:** Use a state management library (e.g., Redux, Zustand, Vuex) for complex state management. Use React Context or Vue provide/inject for simpler state management. - - **Error Handling:** Implement error boundaries to catch errors in components. Display user-friendly error messages. - -- **Performance Considerations:** - - **Optimization Techniques:** Minimize the number of DOM updates. Use memoization to prevent unnecessary re-renders. - - **Memory Management:** Avoid memory leaks by properly cleaning up event listeners and subscriptions. - - **Rendering Optimization:** Use virtualization for rendering large lists. Use the `shouldComponentUpdate` lifecycle method or `React.memo` to prevent unnecessary re-renders. - - **Bundle Size Optimization:** Use code splitting and tree shaking to reduce bundle size. Compress images and other assets. - - **Lazy Loading:** Lazy load images and other resources that are not immediately visible on the page. - -- **Security Best Practices:** - - **Common Vulnerabilities:** Be aware of XSS vulnerabilities when rendering user-generated content. Sanitize inputs to prevent XSS attacks. - - **Input Validation:** Validate all user inputs to prevent unexpected behavior. - - **Authentication and Authorization:** Implement secure authentication and authorization mechanisms. - - **Data Protection:** Protect sensitive data by encrypting it both in transit and at rest. - - **Secure API Communication:** Use HTTPS for all API communication. Validate API responses. - -- **Testing Approaches:** - - **Unit Testing:** Write unit tests for individual components and functions. - - **Integration Testing:** Write integration tests to ensure that components work together correctly. - - **End-to-End Testing:** Write end-to-end tests to test the entire application flow. - - **Test Organization:** Organize tests into logical directories based on functionality. - - **Mocking and Stubbing:** Use mocking and stubbing to isolate components during testing. - -- **Common Pitfalls and Gotchas:** - - **Frequent Mistakes:** Forgetting to configure PurgeCSS. Overusing the `apply` directive. Not using a consistent naming convention. - - **Edge Cases:** Handling different screen sizes and devices. Dealing with browser compatibility issues. - - **Version-Specific Issues:** Be aware of breaking changes in new Tailwind CSS versions. - - **Compatibility Concerns:** Ensure that Tailwind CSS is compatible with your target browsers. - - **Debugging Strategies:** Use browser developer tools to inspect CSS and debug styling issues. - -- **Tooling and Environment:** - - **Recommended Development Tools:** Use a code editor with Tailwind CSS IntelliSense. Use a browser with developer tools. - - **Build Configuration:** Configure your build tool (e.g., webpack, Parcel, Vite) to process Tailwind CSS. - - **Linting and Formatting:** Use ESLint and Prettier to enforce code style and prevent errors. Configure a Tailwind CSS plugin for your linter. - - **Deployment Best Practices:** Use a CDN to serve static assets. Configure caching to improve performance. - - **CI/CD Integration:** Integrate Tailwind CSS into your CI/CD pipeline to automate testing and deployment. - -- **Naming Conventions:** - - Use BEM (Block, Element, Modifier) or a similar naming convention for custom CSS classes. This helps to maintain consistency and avoid naming conflicts. - -- **Accessibility (A11y):** - - Use semantic HTML elements to improve accessibility. Provide alternative text for images. Ensure that your website is navigable using a keyboard. - -- **Consider using `theme()` helper function:** When using Javascript to dynamically set tailwind values, you can use the `theme()` helper function from tailwindcss to get theme values for custom classes. This ensures they are based on values you have specified in your `tailwind.config.js` and can be purged properly. - -- **Custom Utilities vs Components:** When creating custom styling, decide when to make a utility versus a component. Utilities are best for single purpose styling like font-weight, or color changes. Components should be used for more complex combinations of styling, that require more html structure. - -- **Beware of arbitrary values and `!important`:** Using these excessively will reduce your maintainability and reusability of components and CSS. \ No newline at end of file diff --git a/rules-mdc/cloud_platforms/deployment/vercel.mdc b/rules-mdc/vercel.mdc similarity index 100% rename from rules-mdc/cloud_platforms/deployment/vercel.mdc rename to rules-mdc/vercel.mdc diff --git a/rules-mdc/development_tools/build_tools/vite.mdc b/rules-mdc/vite.mdc similarity index 100% rename from rules-mdc/development_tools/build_tools/vite.mdc rename to rules-mdc/vite.mdc diff --git a/rules-mdc/development_tools/testing/vitest.mdc b/rules-mdc/vitest.mdc similarity index 100% rename from rules-mdc/development_tools/testing/vitest.mdc rename to rules-mdc/vitest.mdc diff --git a/rules-mdc/ai_ml/llm_tools/vllm.mdc b/rules-mdc/vllm.mdc similarity index 100% rename from rules-mdc/ai_ml/llm_tools/vllm.mdc rename to rules-mdc/vllm.mdc diff --git a/rules-mdc/frontend_frameworks/vue/vue.mdc b/rules-mdc/vue.mdc similarity index 100% rename from rules-mdc/frontend_frameworks/vue/vue.mdc rename to rules-mdc/vue.mdc diff --git a/rules-mdc/frontend_frameworks/vue/vue3.mdc b/rules-mdc/vue3.mdc similarity index 100% rename from rules-mdc/frontend_frameworks/vue/vue3.mdc rename to rules-mdc/vue3.mdc diff --git a/rules-mdc/development_tools/build_tools/webpack.mdc b/rules-mdc/webpack.mdc similarity index 100% rename from rules-mdc/development_tools/build_tools/webpack.mdc rename to rules-mdc/webpack.mdc diff --git a/rules-mdc/web_technologies/type_checking/zod.mdc b/rules-mdc/zod.mdc similarity index 100% rename from rules-mdc/web_technologies/type_checking/zod.mdc rename to rules-mdc/zod.mdc diff --git a/rules-mdc/state_management/react/zustand.mdc b/rules-mdc/zustand.mdc similarity index 100% rename from rules-mdc/state_management/react/zustand.mdc rename to rules-mdc/zustand.mdc