coding-conventions
1
总安装量
1
周安装量
#44375
全站排名
安装命令
npx skills add https://smithery.ai
Agent 安装分布
claude-code
1
Skill 文档
Seconds Out – Coding Conventions
ê°í ê·ì¹ (Compact Style)
- useEffect, í¨ì ì ì¸ ë± ê´ë ¨ ì½ë ë¸ë¡ ì¬ì´ì ë¹ ì¤ ìì´ ì°ê²°
- ë ¼ë¦¬ì ì¼ë¡ ë¤ë¥¸ ì¹ì ë§ ë¹ ì¤ë¡ 구ë¶
// Good
useEffect(() => { ... }, [deps1]);
useEffect(() => { ... }, [deps2]);
// Bad
useEffect(() => { ... }, [deps1]);
useEffect(() => { ... }, [deps2]);
Import ìì (ê·¸ë£¹ë³ ë¹ ì¤ êµ¬ë¶)
// 1) ì¸ë¶ ë¼ì´ë¸ë¬ë¦¬
import { useEffect, useState } from 'react';
// 2) ë´ë¶ ì ë ê²½ë¡ (~/)
import { useEventCallback } from '~/hooks';
// 3) ìë ê²½ë¡ (ì»´í¬ëí¸, í
, ì í¸)
import Controls from './components/Controls';
import { useTimerSequence } from './hooks';
// 4) ì¤íì¼
import css from './Component.module.scss';
// 5) íì
(import type)
import type { TimerConfig } from './types';
import type { FC } from 'react';
Export ê·ì¹
ë°°ë´ íì¼ (index.ts):
// ì»´í¬ëí¸ default re-export
export { default } from './Component';
// 모ë named re-export
export { default as moduleName } from './moduleName';
// íì
re-export
export type { TypeName } from './types';
ê°ë³ íì¼: íì¼ ëì export default
íì íì¼:
// types/TimerConfig.ts
interface TimerConfig { ... }
export default TimerConfig;
export type { ThemeName, BellName };
// types/index.ts
export type { default as TimerConfig, ThemeName } from './TimerConfig';
íì í ì¬ì©
useEventCallback
- ì½ë°± í¨ìë
useEventCallbackì¼ë¡ ê°ì¸ì ìì ì ì¸ ì°¸ì¡° ì ì§
const handleClick = useEventCallback(() => { ... });
useMounted
- localStorage ì°ë ì hydration 문ì ë°©ì§
const mounted = useMounted();
useEffect(() => {
if (mounted) {
// localStorage ì ê·¼
}
}, [mounted]);
ì¤íì¼ë§
- CSS Modules + SCSS:
import css from './Component.module.scss' - í´ëì¤ ì¬ì©:
className={css.root} - ì¡°ê±´ë¶ í´ëì¤:
cn()ì í¸ ì¬ì©
import { cn } from '~/lib/utils';
<div className={cn(css.root, {
[css.active]: isActive,
})} />
- CSS ë³ìë¡ í
ë§ ì£¼ì
:
style={{ '--color': value } as CSSProperties}
ëë í 리 구조
src/
âââ components/
â âââ [Domain]/ # ëë©ì¸ë³ ì»´í¬ëí¸
â â âââ Component.tsx
â â âââ Component.module.scss
â â âââ index.ts # ë°°ë´ íì¼
â â âââ components/ # íì ì»´í¬ëí¸
â â âââ hooks/ # ëë©ì¸ ì ì© í
â â âââ types/ # ëë©ì¸ ì ì© íì
â â âââ utils/ # ëë©ì¸ ì ì© ì í¸
â âââ ui/ # shadcn/ui ì»´í¬ëí¸
âââ hooks/ # ê³µíµ í
âââ lib/ # ê³µíµ ì í¸ë¦¬í°
âââ providers/ # Context Providers
âââ main.tsx
shadcn/ui ì»´í¬ëí¸
- function ì ì¸ ë°©ì ì¬ì© (íì´í í¨ì X)
- data-slot ìì± ì¶ê°
- Radix UI namespace import
import * as DialogPrimitive from '@radix-ui/react-dialog';
function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>) {
return <DialogPrimitive.Root data-slot="dialog" {...props} />;
}
ì¸ë¶ ë¼ì´ë¸ë¬ë¦¬ Import
// Radix UI - namespace import
import * as SelectPrimitive from '@radix-ui/react-select';
// lucide-react - named import
import { PlusCircle, Check } from 'lucide-react';
기í
- 주ìì íêµì´ ì¬ì©
- eslint-disable 주ìì export ë°ë¡ ìì ìì±
// eslint-disable-next-line react-refresh/only-export-components
export { useMyContext };