1---2name: nativescript-cursorrules-prompt-file3description: Apply for nativescript-cursorrules-prompt-file. --- description: Applies general NativeScript best practices. globs: **/*.tsx, **/*.ts, **/*.vue, **/*.svelte, src/**/*.ts, app/**/*.ts, src/**/*.tsx, app/**/*.tsx, src/**/*.vue, app/**/*.vue, src/**/4---56# nativescript-cursorrules-prompt-file78---9description: Applies general NativeScript best practices.10globs: **/*.tsx, **/*.ts, **/*.vue, **/*.svelte, src/**/*.ts, app/**/*.ts, src/**/*.tsx, app/**/*.tsx, src/**/*.vue, app/**/*.vue, src/**/*.svelte11---12- Organize code using modular components and services for maintainability.13- Use platform-specific files (`.ios.ts`, `.android.ts`) when code exceeds 20 platform-specific lines.14- When creating custom native code, use a folder structure like `custom-native/index.ios.ts`, `custom-native/index.android.ts`, `custom-native/common.ts`, `custom-native/index.d.ts` to keep platform-specific code organized and easy to import with single import elsewhere, replacing `custom-native` with the name of the custom code.15- Prefix platform-specific variables with `ios` or `android` (e.g., `iosButtonStyle`).16- Name custom components and styles descriptively (`primaryButtonStyle`, `userProfileView`).17- Use `@NativeClass()` when extending native classes when needed18- For iOS, when extending native classes, always use `static ObjCProtocols = [AnyUIKitDelegate];` to declare custom delegates if a delegate is required or used.19- For iOS, always retain custom delegate instances to prevent garbage collection. For example, `let delegate = MyCustomDelegate.new() as MyCustomDelegate`, and ensure it is retained in the class scope.20- Favor `__ANDROID__` and `__APPLE__` for conditional platform code with tree-shaking.21- Track and clean up all timers (`setTimeout`, `setInterval`) to avoid memory leaks.22- Always TailwindCSS as the CSS Framework using `"@nativescript/tailwind": "^2.1.0"` for consistent styling paired with `"tailwindcss": "~3.4.0"`.23- Add ios: and android: style variants for platform-specific styling, addVariant('android', '.ns-android &'), addVariant('ios', '.ns-ios &');24- darkMode: ['class', '.ns-dark']25- Leverage `GridLayout` or `StackLayout` for flexible, responsive layouts. Place more emphasis on proper GridLayout usage for complex layouts but use StackLayout for simpler, linear arrangements.26- Use `visibility: 'hidden'` for elements that should not affect layout when hidden.27- Try to avoid deeply nesting layout containers but instead use `GridLayout` wisely to setup complex layouts.28- Avoid direct manipulation of the visual tree during runtime to minimize rendering overhead.29- Optimize images using compression tools like TinyPNG to reduce memory and app size.30- Clean the project (`ns clean`) after modifying files in `App_Resources` or `package.json`.31- Reuse components and styles to avoid duplication.32- Use template selectors (`itemTemplateSelector`) for conditional layouts in `ListView` and `RadListView`.33- Minimize heavy computations in UI bindings or methods.34- Only if using plain xml bindings, use `Observable` or `ObservableArray` properties to reflect state changes efficiently.35- When using Angular, React, Solid, Svelte or Vue, always leverage their respective state management, lifecycle hooks, rendering optimizations and reactive bindings for optimal performance.36