Files
landing-for-digital-product/CONVENTIONS.md
2026-01-02 16:43:29 +03:00

63 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 📐 Coding Conventions
## Именование
- **Компоненты:** PascalCase (`Button.tsx`)
- **Утилиты:** kebab-case (`format-date.ts`)
- **Хуки:** camelCase с use (`useInView.ts`)
```typescript
const userName = "John";
const MAX_RETRIES = 3;
```
## Структура компонента
```typescript
"use client";
import { Button } from "@/shared/ui/button";
interface MyComponentProps {
title: string;
}
export function MyComponent({ title }: MyComponentProps) {
return <div>{title}</div>;
}
```
## TypeScript
Всегда типизируйте props:
```typescript
interface ButtonProps {
children: React.ReactNode;
variant?: "primary" | "secondary";
}
```
## Импорты
Порядок: React → Внешние → Наши (@/...)
```typescript
import { useState } from "react";
import { motion } from "framer-motion";
import { Button } from "@/shared/ui/button";
```
**ВСЕГДА используйте @/ для абсолютных импортов.**
## Стилизация
Порядок Tailwind: Layout → Sizing → Spacing → Typography → Colors
Условные классы через cn():
```typescript
import { cn } from '@/shared/lib/utils';
<button className={cn('px-4 py-2', variant === 'primary' && 'bg-primary')}>
```