Cursor rule
.cursor/rules/typescript-guidelines.mdcTypeScript best practices and conventions for the NOWCRM codebase
Cursor rules
Quality
58/100
Scores the file, not the repository.Length
488 words
16 headings · 9 code blocksRepository
26
— · pushed 116 days agoLast changed
3 days ago
First indexed 3 days ago.1234567# TypeScript Guidelines89## Core TypeScript Principles10NOWCRM enforces strict TypeScript usage to ensure type safety and maintainable code. This document outlines our TypeScript conventions and best practices.1112## Type Safety1314### Strict Typing15- **No 'any' type allowed**16- TypeScript strict mode enabled17- noImplicitAny enabled18```typescript19 // ✅ Correct20 function processUser(user: User) {21 return user.name;22 }2324 // ❌ Incorrect25 function processUser(user: any) {26 return user.name;27 }28```2930### Type Definitions3132#### Types over Interfaces33- Use `type` for all type definitions34- Exception: When extending third-party interfaces35```typescript36 // ✅ Correct37 type User = {38 id: string;39 name: string;40 email: string;41 };4243 // ❌ Incorrect44 interface User {45 id: string;46 name: string;47 email: string;48 }49```5051### String Literals over Enums52- Use string literal unions instead of enums53- Exception: GraphQL enums54```typescript55 // ✅ Correct56 type UserRole = 'admin' | 'user' | 'guest';5758 // ❌ Incorrect59 enum UserRole {60 Admin = 'admin',61 User = 'user',62 Guest = 'guest',63 }64```6566## Naming Conventions6768### Component Props69- Suffix component prop types with 'Props'70- Keep props focused and single-purpose71```typescript72 // ✅ Correct73 type ButtonProps = {74 label: string;75 onClick: () => void;76 variant?: 'primary' | 'secondary';77 };7879 // ❌ Incorrect80 type ButtonParameters = {81 label: string;82 onClick: () => void;83 variant?: 'primary' | 'secondary';84 };85```8687## Type Inference8889### Leverage TypeScript Inference90- Use type inference when types are clear91- Explicitly type when inference is ambiguous92```typescript93 // ✅ Correct - Clear inference94 const users = ['John', 'Jane']; // inferred as string[]9596 // ✅ Correct - Explicit typing needed97 const processUser = (user: User): UserResponse => {98 // Complex processing99 return response;100 };101102 // ❌ Incorrect - Unnecessary explicit typing103 const users: string[] = ['John', 'Jane'];104```105106## Best Practices107108### Type Guards109- Use type guards for runtime type checking110- Prefer discriminated unions111```typescript112 // ✅ Correct113 type Success = {114 type: 'success';115 data: User;116 };117118 type Error = {119 type: 'error';120 message: string;121 };122123 type Result = Success | Error;124125 function handleResult(result: Result) {126 if (result.type === 'success') {127 // TypeScript knows result.data exists128 console.log(result.data);129 }130 }131```132133### Generics134- Use generics for reusable type patterns135- Keep generic names descriptive136```typescript137 // ✅ Correct138 type ApiResponse<TData> = {139 data: TData;140 status: number;141 message: string;142 };143144 // ❌ Incorrect145 type ApiResponse<T> = {146 data: T;147 status: number;148 message: string;149 };150```151152### Type Exports153- Export types when they're used across files154- Keep type definitions close to their usage155```typescript156 // types.ts157 export type User = {158 id: string;159 name: string;160 };161162 // UserComponent.tsx163 import { type User } from './types';164```165166### Utility Types167- Leverage TypeScript utility types168- Create custom utility types for repeated patterns169```typescript170 // Built-in utility types171 type UserPartial = Partial<User>;172 type UserReadonly = Readonly<User>;173174 // Custom utility types175 type NonNullableProperties<T> = {176 [P in keyof T]: NonNullable<T[P]>;177 };178```
Also in nowtec/nowCRM
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| nowtec/nowCRM.cursor/rules/architecture.mdc · 26 | Cursor rules | arch | 54/100 | 3 days ago | |
| nowtec/nowCRM.cursor/rules/code-style.mdc · 26 | Cursor rules | lint-formatstylearchdocs | 62/100 | 3 days ago | |
| nowtec/nowCRM.cursor/rules/file-structure.mdc · 26 | Cursor rules | buildstylearch | 70/100 | 3 days ago | |
| nowtec/nowCRM.cursor/rules/react-general-guidelines.mdc · 26 | Cursor rules | archuiperformancedo-not | 61/100 | 3 days ago | |
| nowtec/nowCRM.cursor/rules/readme.mdc · 26 | Cursor rules | testlint-formatarchtypes+2 | 73/100 | 3 days ago | |
| nowtec/nowCRM.cursor/rules/testing-guidelines.mdc · 26 | Cursor rules | setupteststylearch+3 | 73/100 | 3 days ago | |
| nowtec/nowCRM.cursor/rules/translations.mdc · 26 | Cursor rules | stylearchagent-behaviour | 62/100 | 3 days ago | |
| nowtec/nowCRMCLAUDE.md · 26 | CLAUDE.md | buildstyledeployment | 21/100 | 3 days ago |
Diff against .cursor/rules/architecture.mdc Diff against .cursor/rules/code-style.mdc Diff against .cursor/rules/file-structure.mdc Diff against .cursor/rules/react-general-guidelines.mdc Diff against .cursor/rules/readme.mdc Diff against .cursor/rules/testing-guidelines.mdc Diff against .cursor/rules/translations.mdc Diff against CLAUDE.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago |
