typescript-code-review
БесплатноБез исполняемых скриптовНе проверенTypeScript and React code review guidelines (type safety, React patterns, performance). Auto-loads when reviewing TypeScript/React code.
Об этом скилле
TypeScript/React Code Review Patterns
This skill provides TypeScript and React-specific code review guidelines. Use alongside typescript-style for comprehensive review.
Critical Security Issues
XSS Vulnerabilities
// VULNERABLE - dangerouslySetInnerHTML without sanitization
<div dangerouslySetInnerHTML={{ __html: userInput }} />
// VULNERABLE - innerHTML assignment
element.innerHTML = userContent;
// SAFE - use DOMPurify
import DOMPurify from 'dompurify';
<div dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(userInput) }} />
// SAFER - avoid innerHTML entirely
<div>{userContent}</div> // React auto-escapes
Insecure Data Exposure
// VULNERABLE - logging sensitive data
console.log("User data:", user); // May include tokens, passwords
console.log("Request:", request.headers); // Auth headers
// VULNERABLE - exposing in error messages
throw new Error(`Auth failed for ${credentials}`);
// SAFE - sanitize before logging
console.log("User ID:", user.id); // Only necessary fields
Unsafe eval/Function Constructor
// VULNERABLE - code execution from strings
eval(userInput);
new Function(userInput)();
setTimeout(userInput, 1000); // String argument
// SAFE - avoid string evaluation
setTimeout(() => { processInput(userInput); }, 1000);
Missing CSRF Protection
// VULNERABLE - no CSRF token
fetch('/api/delete', { method: 'POST', body: data });
// SAFE - include CSRF token
fetch('/api/delete', {
method: 'POST',
headers: { 'X-CSRF-Token': csrfToken },
body: data,
});
High Priority Type Safety Issues
Unsafe Type Assertions
// DANGEROUS - bypasses type checking
const user = data as User;
const items = response as any[];
// SAFER - use type guards
function isUser(data: unknown): data is User {
return typeof data === 'object' && data !== null && 'id' in data;
}
if (isUser(data)) {
// data is now typed as User
}
Non-null Assertion Abuse
// DANGEROUS - runtime error if null
const name = user!.profile!.name!;
// SAFE - explicit null handling
const name = user?.profile?.name ?? 'Unknown';
// Or with explicit checks
if (user?.profile?.name) {
const name = user.profile.name;
}
Missing Error Handling in Async Code
// BUG - unhandled promise rejection
async function fetchData() {
const response = await fetch(url);
return response.json(); // What if fetch fails?
}
// CORRECT - handle errors
async function fetchData() {
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
return response.json();
} catch (error) {
console.error('Fetch failed:', error);
throw error; // Re-throw or return default
}
}
Ignoring Promise Results
// BUG - fire and forget
saveUser(userData); // No await, no error handling
// CORRECT
await saveUser(userData);
// or
saveUser(userData).catch(console.error);
React Anti-Patterns
Missing useEffect Dependencies
// BUG - stale closure, missing dependency
useEffect(() => {
fetchUser(userId); // userId not in deps!
}, []); // Empty deps = runs once with initial userId
// CORRECT - include all dependencies
useEffect(() => {
fetchUser(userId);
}, [userId]);
State Updates on Unmounted Components
// BUG - memory leak, state update after unmount
useEffect(() => {
fetchData().then(setData);
}, []);
// CORRECT - cleanup with flag or AbortController
useEffect(() => {
let mounted = true;
fetchData().then((data) => {
if (mounted) setData(data);
});
return () => { mounted = false; };
}, []);
// BETTER - use AbortController
useEffect(() => {
const controller = new AbortController();
fetch(url, { signal: controller.signal })
.then(res => res.json())
.then(setData)
.catch(err => {
if (err.name !== 'AbortError') throw err;
});
return () => controller.abort();
}, [url]);
Missing Key Prop in Lists
// BUG - using index as key (causes issues on reorder)
items.map((item, index) => <Item key={index} data={item} />)
// CORRECT - use stable unique identifier
items.map((item) => <Item key={item.id} data={item} />)
Inline Functions in JSX (Performance)
// PERFORMANCE - new function on every render
<Button onClick={() => handleClick(id)} />
// BETTER - memoize if passed to memoized child
const handleButtonClick = useCallback(() => handleClick(id), [id]);
<MemoizedButton onClick={handleButtonClick} />
Props Drilling Deep
// CODE SMELL - passing props through many levels
<App user={user}>
<Layout user={user}>
<Sidebar user={user}>
<UserProfile user={user} />
// BETTER - use Context for cross-cutting concerns
const UserContext = createContext<User | null>(null);
<UserContext.Provider value={user}>
<App />
</UserContext.Provider>
Установить typescript-code-review в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл typescript-code-review?
TypeScript and React code review guidelines (type safety, React patterns, performance). Auto-loads when reviewing TypeScript/React code.
Как установить скилл typescript-code-review?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл typescript-code-review запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic