Regenerate all MDC rules with fresh Exa data and December 2025 best practices

- Refreshed all 241 library rules with current best practices
- Updated Exa search results for all libraries with 2025 content
- Fixed --regenerate-all flag logic to properly process all libraries
- Removed duplicate astro entry in rules.json (merged tags)
- Added missing docker.mdc and vim.mdc files
- All rules now include modern patterns and anti-patterns
- Updated with framework-specific recommendations for 2025

Technical improvements:
- Fixed retry_failed_only logic in generate_mdc_files.py
- Improved progress tracking for regeneration scenarios
- Ensured proper handling of --refresh-exa flag
This commit is contained in:
sanjeed5
2025-12-17 22:40:28 +05:30
parent 331fb6ffac
commit 8fbf269085
244 changed files with 66701 additions and 52708 deletions
+329 -283
View File
@@ -1,339 +1,385 @@
---
description: This rule provides comprehensive best practices for Ionic Framework development, covering code organization, performance, security, testing, and more. Following these guidelines will result in more maintainable, performant, and secure Ionic applications.
globs: *.ts,*.html,*.scss
description: This guide provides definitive best practices for developing high-performance, maintainable, and accessible Ionic applications using modern TypeScript and web standards.
globs: **/*.{js,jsx,ts,tsx}
---
---
# Ionic Framework Best Practices
# ionic Best Practices
This document outlines best practices for developing Ionic applications. Following these guidelines will help ensure your applications are maintainable, performant, secure, and testable.
Ionic Framework enables powerful cross-platform applications. Adhering to these guidelines ensures your codebase is robust, performant, and aligned with modern web development standards.
## 1. Code Organization and Structure
### 1.1 Directory Structure Best Practices
Adopt a consistent, component-centric file structure for clarity and maintainability.
A well-organized directory structure is crucial for maintainability. Consider this structure as a starting point:
### 1.1 One Component Per Directory
Each Ionic component (or Stencil component it wraps) must reside in its own directory, co-locating all related files.
src/
app/
components/
my-component/
my-component.component.ts
my-component.component.html
my-component.component.scss
my-component.component.spec.ts
pages/
home/
home.page.ts
home.page.html
home.page.scss
home.page.spec.ts
services/
data.service.ts
app.component.ts
app.module.ts
app-routing.module.ts
assets/
theme/
variables.scss
environments/
environment.ts
environment.prod.ts
❌ **BAD: Scattered files**
```
// components/my-button.tsx
// components/my-button.css
// components/my-card.tsx
// components/my-card.css
```
✅ **GOOD: Component-per-directory**
```
├── components
│ ├── ion-button
│ │ ├── ion-button.css
│ │ └── ion-button.tsx
│ └── ion-card
│ ├── ion-card.css
│ └── ion-card.tsx
```
* **`src/app`**: Contains the core application code.
* **`src/app/components`**: Reusable UI components.
* **`src/app/pages`**: Individual application pages/views.
* **`src/app/services`**: Application services for data access, business logic, etc.
* **`src/assets`**: Static assets like images, fonts, etc.
* **`src/theme`**: Global styles and variables.
* **`src/environments`**: Environment-specific configuration.
### 1.2 Naming Conventions
### 1.2 File Naming Conventions
Use descriptive, noun-based names for components, prefixed for uniqueness.
Use consistent file naming conventions:
* **HTML Tag**: Use a unique, brand-specific prefix (e.g., `ion-`). Names should be nouns.
* **TS Class**: No prefix for the ES6 class name, as classes are scoped.
* Components: `my-component.component.ts`, `my-component.component.html`, `my-component.component.scss`
* Pages: `home.page.ts`, `home.page.html`, `home.page.scss`
* Services: `data.service.ts`
* Modules: `app.module.ts`, `my-module.module.ts`
* Interfaces: `my-interface.ts`
* Enums: `my-enum.ts`
❌ **BAD: Verb-based or un-prefixed tags**
```tsx
// my-animating.tsx
@Component({ tag: 'animating-component' })
export class AnimatingComponent {}
```
This consistency improves readability and maintainability.
✅ **GOOD: Noun-based, prefixed tags**
```tsx
// ion-animation.tsx
@Component({ tag: 'ion-animation' })
export class Animation {}
```
### 1.3 Module Organization
### 1.3 Component File Structure (Newspaper Metaphor)
* **Feature Modules:** Group related components, pages, and services into feature modules. This promotes modularity and lazy loading.
* **Shared Module:** Create a shared module for commonly used components, directives, and pipes.
* **Core Module:** A core module is used for application-wide services that you only need to instantiate once. Import it only into the `AppModule`.
* **Lazy Loading:** Lazy load feature modules to improve initial load time.
Organize component class members logically, from high-level summaries to detailed implementations.
typescript
// Example of a Feature Module
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MyComponent } from './my-component/my-component.component';
import { MyPage } from './my-page/my-page.page';
import { MyService } from './my-service/my-service.service';
import { MyRoutingModule } from './my-routing.module';
@NgModule({
declarations: [MyComponent, MyPage],
imports: [CommonModule, MyRoutingModule],
providers: [MyService],
```typescript
@Component({
tag: 'ion-example',
styleUrls: {
ios: 'ion-example.ios.css',
md: 'ion-example.md.css',
},
})
export class MyModule {}
export class IonExample {
/** 1. Internal Properties (not exposed) */
private internalValue: number = 0;
/** 2. Reference to host HTML element */
@Element() el!: HTMLElement;
/** 3. State() variables (internal reactive state) */
@State() isActive: boolean = false;
/** 4. Public Property API (@Prop()) with JSDocs */
/**
* The text to display on the button.
*/
@Prop() text: string = '';
/**
* If `true`, the button is disabled.
*/
@Prop() disabled: boolean = false;
/** 5. Prop lifecycle events (@Watch()) */
@Watch('disabled')
disabledChanged(newValue: boolean, oldValue: boolean) {
console.log(`Disabled changed from ${oldValue} to ${newValue}`);
}
/** 6. Events section (@Event()) with JSDocs */
/**
* Emitted when the button is clicked.
*/
@Event() ionClick!: EventEmitter<void>;
/** 7. Component lifecycle events (ordered by natural call order) */
connectedCallback() { /* ... */ }
disconnectedCallback() { /* ... */ }
componentWillLoad() { /* ... */ }
componentDidLoad() { /* ... */ }
componentWillRender() { /* ... */ }
componentDidRender() { /* ... */ }
/** 8. Listeners (@Listen()) */
@Listen('click', { target: 'document' })
onClick(event: Event) {
if (event.target === this.el) {
this.ionClick.emit();
}
}
/** 9. Public Methods (@Method()) with JSDocs */
/**
* Focuses the button.
*/
@Method()
async setFocus() {
this.el.focus();
}
/** 10. Private Methods (internal logic) */
private updateInternalState() {
this.internalValue++;
}
/** 11. Render function (JSX/TSX) */
render() {
return (
<button disabled={this.disabled} onClick={() => this.ionClick.emit()}>
{this.text}
</button>
);
}
}
```
## 2. TypeScript Best Practices
Leverage TypeScript for type safety, improved tooling, and maintainability.
### 2.1 Enforce Strict Typing
Always enable `noImplicitAny` and `strictNullChecks` in your `tsconfig.json`. Avoid `any` unless absolutely necessary.
❌ **BAD: Implicit `any`**
```typescript
function processData(data) { // data is implicitly 'any'
console.log(data.value);
}
```
✅ **GOOD: Explicit typing**
```typescript
interface Data {
value: string;
}
function processData(data: Data): void {
console.log(data.value);
}
```
### 2.2 Use `private` for Internal Members
Mark internal class properties and methods as `private` to enforce encapsulation and aid dead code detection.
❌ **BAD: All public by default**
```typescript
export class MyComponent {
helperMethod() { /* ... */ } // Public, but only used internally
}
```
✅ **GOOD: Encapsulated internals**
```typescript
export class MyComponent {
private helperMethod() { /* ... */ } // Clearly internal
}
```
### 2.3 JSDocs for Public API
Document all `@Prop()`, `@Event()`, and `@Method()` decorators with JSDoc comments to generate documentation and improve editor experience.
❌ **BAD: Undocumented public API**
```typescript
@Prop() value: string;
@Event() ionChange: EventEmitter<string>;
```
✅ **GOOD: Documented public API**
```typescript
/**
* The current value of the input.
*/
@Prop() value: string = '';
/**
* Emitted when the value changes.
*/
@Event() ionChange!: EventEmitter<string>;
```
## 3. Common Patterns and Anti-patterns
Adopt patterns that leverage Ionic's strengths and avoid common pitfalls.
### 3.1 Always `await` Asynchronous Native Plugin Calls
Capacitor/Cordova plugin calls are asynchronous. Always `await` their resolution to prevent race conditions and unexpected behavior.
❌ **BAD: Fire-and-forget native calls**
```typescript
import { Camera } from '@capacitor/camera';
async takePhoto() {
Camera.getPhoto({ /* ... */ }); // Missing await
console.log('Photo request sent'); // May log before photo is taken
}
```
✅ **GOOD: Await native calls**
```typescript
import { Camera, CameraResultType } from '@capacitor/camera';
### 1.4 Component Architecture
async takePhoto() {
const photo = await Camera.getPhoto({
quality: 90,
allowEditing: false,
resultType: CameraResultType.Uri
});
console.log('Photo taken:', photo.webPath);
}
```
* **Smart vs. Dumb Components:**
* **Smart Components (Pages):** Handle data fetching, state management, and interactions with services.
* **Dumb Components (Components):** Receive data via inputs and emit events via outputs. Focus on presentation and UI logic.
* **Component Reusability:** Design components to be reusable across different parts of the application.
* **Avoid Direct DOM Manipulation:** Use Angular's data binding and directives instead of directly manipulating the DOM.
* **Follow the Single Responsibility Principle (SRP):** Ensure each component has a specific purpose.
### 3.2 Prefer Ionic Components for UI
### 1.5 Code Splitting
Leverage Ionic's rich set of UI components for adaptive styling, performance, and accessibility. Avoid custom implementations where an Ionic component exists.
❌ **BAD: Custom button for navigation**
```html
<button onclick="navigateTo('/home')">Home</button>
```
✅ **GOOD: Ionic button with router link**
```html
<ion-button routerLink="/home" routerDirection="forward">Home</ion-button>
```
### 3.3 Theming with CSS Variables
* **Lazy Loading Modules:** As mentioned, lazy load feature modules to reduce the initial bundle size.
* **Route-Based Code Splitting:** Split code based on application routes.
* **Conditional Loading:** Load components or modules only when they are needed.
Customize your app's look and feel using Ionic's CSS Variables for consistent, platform-adaptive theming.
❌ **BAD: Hardcoded styles**
```css
.my-component {
background-color: #3880ff; /* Primary blue */
}
```
## 2. Common Patterns and Anti-Patterns
✅ **GOOD: CSS Variables for theming**
```css
.my-component {
background-color: var(--ion-color-primary);
}
```
### 2.1 Design Patterns
## 4. Performance Considerations
* **Model-View-Controller (MVC):** Ionic, built on Angular, largely follows the MVC pattern.
* **Singleton:** Use singletons for services that need to maintain global state (e.g., authentication service).
* **Observer:** Use RxJS Observables for asynchronous operations and data streams.
* **Facade:** Provide a simplified interface to a complex subsystem.
* **Dependency Injection:** Use Angular's dependency injection system to provide components with their dependencies.
Ionic is built for performance. Follow these to maintain a fast, responsive app.
### 2.2 Recommended Approaches for Common Tasks
### 4.1 Optimize DOM Updates
* **Data Fetching:** Use Angular's `HttpClient` with RxJS Observables for making API requests.
* **Form Handling:** Use Angular's reactive forms or template-driven forms for managing form data.
* **Navigation:** Use the Ionic `NavController` for navigating between pages.
* **State Management:** Use a state management library like NgRx or Akita for complex applications.
* **UI Components:** Leverage Ionic's built-in UI components for a consistent look and feel.
Avoid direct, heavy DOM manipulation. Let the framework (Angular, React, Vue, Stencil) manage DOM updates efficiently.
### 2.3 Anti-Patterns and Code Smells
❌ **BAD: Manually updating styles on scroll**
```typescript
// In a scroll event listener
this.el.style.transform = `translateY(${scrollTop}px)`; // Triggers layout thrashing
```
* **Massive Components:** Avoid creating components that are too large or complex. Break them down into smaller, reusable components.
* **Direct DOM Manipulation:** As mentioned, avoid directly manipulating the DOM.
* **Nested Subscriptions:** Avoid deeply nested RxJS subscriptions, which can lead to memory leaks and difficult-to-debug code. Use operators like `switchMap`, `mergeMap`, or `concatMap` to flatten subscriptions.
* **Overusing `any` Type:** Avoid using the `any` type excessively. Use specific types to improve type safety and code maintainability.
* **Ignoring Errors:** Always handle errors properly to prevent unexpected behavior.
* **Global Variables:** Avoid using global variables, which can lead to naming conflicts and unpredictable behavior.
✅ **GOOD: Use CSS transforms or Ionic's built-in scroll events**
```typescript
// Use CSS for animations or leverage Ionic's virtual scroll
// Or, if absolutely necessary, batch DOM reads/writes
```
### 2.4 State Management
### 4.2 Leverage Built-in Optimizations
* **Component State:** For simple component-specific state, use Angular's `@Input` and `@Output` decorators.
* **Service State:** For application-wide state that needs to be shared between components, use a service with RxJS `BehaviorSubject` or `ReplaySubject`.
* **NgRx/Akita:** For complex applications with significant state management needs, consider using a state management library like NgRx or Akita.
* NgRx leverages Redux principles, offering a predictable state container with actions, reducers, and effects. This is suitable for large-scale applications needing centralized state management, change tracking, and debugging tools. However, NgRx can introduce boilerplate and complexity.
* Akita, a state management pattern on top of RxJS, simplifies the process with less boilerplate and easier learning curve compared to Redux-based solutions. It’s suitable for small to medium-sized applications requiring scalable yet simple state management.
Ionic components often include hardware-accelerated transitions, lazy loading, and tree-shaking. Ensure your build process enables these.
### 2.5 Error Handling
* **Tree-shaking**: Use modern bundlers (Webpack, Rollup) and ES Modules.
* **Lazy Loading**: For routes and components, especially in Angular/React/Vue.
* **Centralized Error Handling:** Create a centralized error handling service to handle errors consistently across the application.
* **Error Interceptors:** Use Angular's `HttpInterceptor` to intercept HTTP requests and handle errors globally.
* **User-Friendly Error Messages:** Display user-friendly error messages to the user.
* **Logging:** Log errors to a server for debugging and monitoring purposes.
* **Retry Mechanism:** Implement a retry mechanism for transient errors.
## 5. Common Pitfalls and Gotchas
## 3. Performance Considerations
Be aware of these common issues to prevent bugs and performance regressions.
### 3.1 Optimization Techniques
### 5.1 Ignoring Accessibility (a11y)
* **Lazy Loading:** As previously emphasized, use lazy loading for modules and components.
* **Ahead-of-Time (AOT) Compilation:** Use AOT compilation to compile the application during the build process, which improves startup time.
* **Change Detection Optimization:**
* **`OnPush` Change Detection:** Use `OnPush` change detection strategy for components that only depend on input properties. This can significantly improve performance.
* **`trackBy` Function:** Use the `trackBy` function in `*ngFor` loops to improve rendering performance when the underlying data changes.
* **Virtual Scrolling:** Use virtual scrolling for long lists to render only the visible items.
* **Image Optimization:** Optimize images by compressing them and using appropriate formats.
* **Minify and Bundle:** Minify and bundle JavaScript and CSS files to reduce file sizes.
* **Caching:** Implement caching strategies for frequently accessed data.
* **Debouncing and Throttling:** Use debouncing and throttling to limit the frequency of event handlers.
Ionic components are built with accessibility in mind, but developers must use them correctly. Run automated accessibility audits as part of CI.
### 3.2 Memory Management
❌ **BAD: Missing `aria-label` or semantic elements**
```html
<ion-icon name="menu" (click)="openMenu()"></ion-icon>
```
* **Unsubscribe from Observables:** Always unsubscribe from RxJS subscriptions to prevent memory leaks. Use the `takeUntil` operator or a `Subject` to manage subscriptions.
* **Avoid Circular Dependencies:** Avoid circular dependencies between modules, which can lead to memory leaks.
* **Release Resources:** Release resources when they are no longer needed.
* **Use `async` Pipe:** Use the `async` pipe in templates to automatically unsubscribe from Observables.
✅ **GOOD: Accessible elements**
```html
<ion-menu-button auto-hide="false"></ion-menu-button>
<!-- Or for a standalone icon that triggers an action -->
<ion-icon name="menu" aria-label="Open menu" (click)="openMenu()"></ion-icon>
```
### 3.3 Rendering Optimization
### 5.2 Using Deprecated TSLint Configurations
* **Reduce DOM Updates:** Minimize the number of DOM updates by using Angular's data binding and change detection mechanisms effectively.
* **Use CSS Transforms:** Use CSS transforms instead of directly manipulating the DOM for animations and transitions.
* **Avoid Complex Expressions in Templates:** Avoid complex expressions in templates, which can impact rendering performance. Move complex logic to component classes.
* **Virtual DOM:** Angular uses a virtual DOM, but understanding how change detection works is critical to performance.
TSLint is deprecated. Migrate to ESLint with `@stencil-community/eslint-plugin` and `eslint-config-ionic` for modern static analysis.
### 3.4 Bundle Size Optimization
❌ **BAD: Relying on `tslint.json`**
```json
// tslint.json
{
"extends": "tslint-ionic-rules/strict"
}
```
* **Tree Shaking:** Use tree shaking to remove unused code from the bundle.
* **Code Splitting:** As mentioned, use code splitting to reduce the initial bundle size.
* **Remove Unused Dependencies:** Remove any unused dependencies from the `package.json` file.
* **Use Production Build:** Use the production build flag (`--prod`) when building the application for deployment.
* **Analyze Bundle Size:** Use tools like `webpack-bundle-analyzer` to analyze the bundle size and identify areas for optimization.
✅ **GOOD: Using ESLint**
```json
// .eslintrc.js
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@stencil-community/recommended',
'@ionic/eslint-config/recommended'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', '@stencil-community'],
// ... other rules and configs
};
```
### 3.5 Lazy Loading
## 6. Testing Approaches
* **Lazy Load Modules:** This is a primary optimization strategy in Ionic.
* **Lazy Load Images:** Use libraries that support lazy loading of images.
Implement a robust testing strategy for reliability and maintainability.
## 4. Security Best Practices
### 6.1 Unit Testing
### 4.1 Common Vulnerabilities and Prevention
Use Jest for unit testing individual components, services, and utilities. Focus on isolated logic.
* **Cross-Site Scripting (XSS):** Prevent XSS attacks by sanitizing user input and avoiding the use of `innerHTML`. Use Angular's built-in sanitization features.
* **Cross-Site Request Forgery (CSRF):** Implement CSRF protection by using tokens in HTTP requests.
* **Injection Attacks:** Prevent SQL injection and other injection attacks by using parameterized queries and input validation.
* **Insecure Data Storage:** Avoid storing sensitive data in local storage or cookies. Use secure storage mechanisms like the Ionic Native Storage plugin or a secure backend.
* **Man-in-the-Middle (MITM) Attacks:** Use HTTPS to encrypt communication between the app and the server.
* **Certificate Pinning:** Implement certificate pinning to prevent MITM attacks.
```typescript
// my-service.spec.ts
import { MyService } from './my-service';
### 4.2 Input Validation
describe('MyService', () => {
let service: MyService;
* **Client-Side Validation:** Implement client-side validation to provide immediate feedback to the user.
* **Server-Side Validation:** Always perform server-side validation to ensure data integrity.
* **Sanitize User Input:** Sanitize user input to prevent XSS attacks.
* **Use Regular Expressions:** Use regular expressions to validate input formats.
beforeEach(() => {
service = new MyService();
});
### 4.3 Authentication and Authorization
it('should return the correct value', () => {
expect(service.calculate(2, 3)).toBe(5);
});
});
```
* **Use Secure Authentication:** Use a secure authentication mechanism like OAuth 2.0 or JWT (JSON Web Token).
* **Implement Role-Based Access Control (RBAC):** Implement RBAC to control access to different parts of the application based on user roles.
* **Store Tokens Securely:** Store authentication tokens securely using the Ionic Native Storage plugin or a secure backend.
* **Refresh Tokens:** Use refresh tokens to automatically renew authentication tokens.
* **Implement Multi-Factor Authentication (MFA):** Implement MFA for increased security.
### 6.2 End-to-End (E2E) Testing
### 4.4 Data Protection
Use Playwright or Cypress for E2E tests to simulate user interactions across your application.
* **Encrypt Sensitive Data:** Encrypt sensitive data at rest and in transit.
* **Use HTTPS:** Use HTTPS for all communication between the app and the server.
* **Secure API Keys:** Protect API keys by storing them securely and using them only when necessary.
* **Data Masking:** Mask sensitive data in the UI.
* **Regular Security Audits:** Conduct regular security audits to identify and address potential vulnerabilities.
```javascript
// e2e/home.spec.ts (example with Playwright)
import { test, expect } from '@playwright/test';
### 4.5 Secure API Communication
* **Use HTTPS:** Use HTTPS for all API communication.
* **Validate API Responses:** Validate API responses to ensure data integrity.
* **Implement Rate Limiting:** Implement rate limiting to prevent abuse of API endpoints.
* **Use API Gateways:** Use API gateways to manage and secure API traffic.
* **Secure API Keys:** Protect API keys by storing them securely and using them only when necessary.
## 5. Testing Approaches
### 5.1 Unit Testing
* **Test Components in Isolation:** Test components in isolation using mocking and stubbing techniques.
* **Test Services in Isolation:** Test services in isolation by mocking their dependencies.
* **Use Test Doubles:** Use test doubles like stubs, mocks, and spies to isolate the code under test.
* **Test Boundary Conditions:** Test boundary conditions to ensure the code handles edge cases correctly.
* **Use Code Coverage Tools:** Use code coverage tools to measure the percentage of code that is covered by tests.
### 5.2 Integration Testing
* **Test Component Interactions:** Test the interactions between components.
* **Test Service Interactions:** Test the interactions between services.
* **Test Data Flow:** Test the flow of data through the application.
* **Use Mock HTTP Backend:** Use a mock HTTP backend to simulate API responses.
### 5.3 End-to-End Testing
* **Test User Flows:** Test the complete user flows through the application.
* **Use a Testing Framework:** Use a testing framework like Cypress or Protractor for end-to-end testing.
* **Test on Real Devices:** Test the application on real devices to ensure it works correctly in different environments.
### 5.4 Test Organization
* **Locate Tests with Source Files:** Keep test files in the same directory as the source files they test (e.g., `my-component.component.spec.ts` next to `my-component.component.ts`).
* **Use Descriptive Test Names:** Use descriptive test names to clearly indicate what the test is verifying.
* **Organize Tests by Feature:** Organize tests by feature to improve test maintainability.
### 5.5 Mocking and Stubbing
* **Use Mocking Libraries:** Use mocking libraries like Jasmine or Sinon.js to create mocks and stubs.
* **Mock Dependencies:** Mock dependencies to isolate the code under test.
* **Stub API Responses:** Stub API responses to simulate different scenarios.
## 6. Common Pitfalls and Gotchas
### 6.1 Frequent Mistakes
* **Not Unsubscribing from Observables:** Forgetting to unsubscribe from RxJS subscriptions.
* **Directly Manipulating the DOM:** Directly manipulating the DOM instead of using Angular's data binding.
* **Overusing `any` Type:** Overusing the `any` type.
* **Ignoring Errors:** Ignoring errors.
* **Not Validating User Input:** Not validating user input.
* **Storing Sensitive Data in Local Storage:** Storing sensitive data in local storage.
* **Not Using HTTPS:** Not using HTTPS for API communication.
### 6.2 Edge Cases
* **Handling Network Errors:** Handling network errors gracefully.
* **Handling Different Screen Sizes:** Handling different screen sizes and resolutions.
* **Handling Different Operating Systems:** Handling different operating systems (iOS and Android).
* **Handling Different Device Capabilities:** Handling different device capabilities (e.g., camera, GPS).
### 6.3 Version-Specific Issues
* **Breaking Changes:** Be aware of breaking changes in new versions of Ionic and Angular. Carefully review release notes.
* **Deprecated Features:** Avoid using deprecated features.
* **Compatibility Issues:** Test the application with different versions of Ionic and Angular to ensure compatibility.
### 6.4 Compatibility Concerns
* **Plugin Compatibility:** Ensure that plugins are compatible with the target platform and version of Ionic.
* **Browser Compatibility:** Ensure that the application works correctly in different browsers.
* **Cordova vs. Capacitor:** Understand the differences and implications of using Cordova versus Capacitor. Capacitor is generally recommended for new projects.
### 6.5 Debugging Strategies
* **Use Browser Developer Tools:** Use browser developer tools to debug JavaScript, CSS, and network requests.
* **Use Debugging Tools:** Use debugging tools like VS Code's debugger to step through code and inspect variables.
* **Use Logging:** Use logging to track the flow of execution and identify potential issues.
* **Use Remote Debugging:** Use remote debugging to debug the application on real devices.
* **Learn to read Stack Traces:** Understanding the stack trace is crucial for identifying the source of errors.
## 7. Tooling and Environment
### 7.1 Recommended Development Tools
* **VS Code:** VS Code is a popular IDE for Ionic development with excellent support for TypeScript, HTML, and CSS.
* **Ionic CLI:** The Ionic CLI is a command-line tool for creating, building, and deploying Ionic applications.
* **Chrome DevTools:** Chrome DevTools is a powerful tool for debugging and profiling Ionic applications.
* **Postman/Insomnia:** Use Postman or Insomnia to test API endpoints.
### 7.2 Build Configuration
* **Use Environment Variables:** Use environment variables to configure the application for different environments (e.g., development, production).
* **Configure Build Scripts:** Configure build scripts to automate build tasks.
* **Use a Build System:** Use a build system like Webpack or Parcel to manage dependencies and bundle assets.
* **Optimize Build Configuration:** Optimize the build configuration to reduce build time and bundle size.
### 7.3 Linting and Formatting
* **Use ESLint:** Use ESLint to enforce coding standards and identify potential issues.
* **Use Prettier:** Use Prettier to automatically format code.
* **Configure Editor Integration:** Configure editor integration to automatically lint and format code on save.
### 7.4 Deployment
* **Build for Production:** Build the application for production using the `--prod` flag.
* **Use a Deployment Platform:** Use a deployment platform like Firebase Hosting, Netlify, or AWS Amplify.
* **Configure HTTPS:** Configure HTTPS for the deployment environment.
* **Monitor Application Performance:** Monitor application performance after deployment.
### 7.5 CI/CD
* **Use a CI/CD Pipeline:** Use a CI/CD pipeline to automate the build, test, and deployment process.
* **Use a CI/CD Tool:** Use a CI/CD tool like Jenkins, CircleCI, or Travis CI.
* **Automate Testing:** Automate unit, integration, and end-to-end tests in the CI/CD pipeline.
* **Automate Deployment:** Automate deployment to different environments in the CI/CD pipeline.
test('should navigate to home and display title', async ({ page }) => {
await page.goto('/home');
await expect(page.locator('ion-title')).toHaveText('Home');
});
```