Loading...
Loading...
TypeScript, React, and Node.js coding standards: naming, types, hooks, components, error handling, refactoring, code review. Use when creating/editing TS/JS/React files, naming variables or components, designing API endpoints, handling async, structuring components, or when the user asks "how should I name...", "what's the best way to...", "is this good practice...", "can you review this code". Keywords: TypeScript, React, hooks, React Query, Jest, RTL, naming, immutability. Do not load for: CSS-only changes, documentation writing, JSON config edits, shell scripts.
npx skill4agent add lichens-innovation/skills typescript-and-react-guidelines| Principle | Rule |
|---|---|
| Readability First | Code is read more than written. Clear names > clever code. |
| KISS | Simplest solution that works. Avoid over-engineering. |
| Avoid GodComponent | Single responsibility per component; extract utilities, hooks, sub-components. |
| DRY | Extract common logic. Create reusable components. |
| YAGNI | Don't build features before they're needed. |
| Immutability | Never mutate — always return new values. |
interface FormatRangeArgs { start: number; end: number }const formatRange = ({ start, end }: FormatRangeArgs) => ...src/utils/xyz.utils.tscomponent-name.utils.tsmarket-list-item.utils.tsmarket-list-item.tsxuse-xyz.tssrc/hooks/use-xyz.tshooks/features/market-list/hooks/use-market-filters.ts| Topic | Example File | When to load |
|---|---|---|
| Variable & function naming (incl. boolean prefixes) | | When naming anything (arrow functions only; booleans: is/has/should/can/will) |
| Immutability patterns | | When working with state/objects/arrays |
| Error handling | | When writing async code |
| Async / Promise patterns | | When using await/Promise |
| Type safety | | When defining interfaces/types (no inline types; no nested types; extract named types) |
| Control flow & readability | | Early returns, const vs let, Array.includes/some, nullish coalescing, destructuring |
| Topic | Example File | When to load |
|---|---|---|
| Component structure | | When creating a component |
| Topic | Example File | When to load |
|---|---|---|
| Unit test patterns | | When writing Jest/RTL tests (AAA, screen, spyOn, it.each, getByRole, mock factory) |
| Topic | File |
|---|---|
| All BAD patterns grouped | |
| Code smells detection | |
components/button.tsx # kebab-case (not Button.tsx)
hooks/use-auth.ts # kebab-case (not useAuth.ts)
lib/format-date.ts # kebab-case (not formatDate.ts)
types/market.types.ts # kebab-case + optional .types / .utils / .store suffix
features/market-list/market-list-item.tsx
settings-screen.tsx # e.g. settings-screen.tsx, use-device-discovery.tsusetsconfig.jsonconst count = 0FunctionComponent<Props>FC<Props>any<>...</><Fragment>keyuseconst handleClick = () => { ... }selectedItem = items.find(i => i.id === selectedId)isLoadinguseQueryuseMutationuseStateuseEffectXxxQueryKey.allXxxQueryKey.list(...)XxxQueryKey.detail(id)[ComponentName] failed to loadhooks/*.utils.ts*.types.tsfeatures/scene-3d/scene-manager/controllers/// TODO: JIRA-1234 - descriptionlogger.info()logger.error()logger.warn()logger.debug()console.*[useDeviceDiscovery] storing last known camera IPconsole.logconst fn = ({ a, b }: Args) => ...param?: Typeparam: Type | undefined{ page = 1, size = 10 }ReactNodeJSX.Element | null | undefinedPropsWithChildren<Props>childrenRecord<K, V>Record<K, V>===array.find(...) !== undefinedgaprowGapcolumnGapmarginpaddinguseWindowDimensionsDimensions.get| Type | File | Use when |
|---|---|---|
| Hook | assets/hook-template.ts | Creating a data-fetching or effect hook |
| Hook (TanStack Query) | assets/hook-tanstack-query-template.ts | Creating a hook with @tanstack/react-query (queryKey, queryFn, placeholderData) |
| Component | assets/component-template.tsx | Creating a React component |
| Utility | assets/utils-template.ts | Creating pure or side-effect helpers ( |
skills-ref validate ./skills/typescript-and-react-guidelines