react-coding-standards
React & TypeScript coding standards
This skill applies company coding standards expressed as Avoid (anti-patterns) and Prefer (recommended patterns) to in-code patterns only. For file and folder naming and structure, use react-files-structure-standards.
Source of truth (priority order)
When resolving standards, use this order:
- Project tooling: ESLint config (
eslint.config.js/.eslintrc*), TypeScript config (tsconfig.json,tsconfig.app.json). Runyarn lintornpm run lint; fix auto-fixable issues first. - Reference files in
references/(see table below) for Avoid/Prefer rules and examples. - Reference codebase (if provided): e.g. a frontend app under the same org — use it to infer naming, structure, and patterns (hooks returning data only,
FunctionComponent+ destructured props,*.utils.ts/*.store.ts, test style with Vitest or Jest).
Reference categories
Standards are defined in the references/ folder. Load these files when you need the exact Avoid/Prefer rules and examples:
| Category | File | Scope |
|---|---|---|
| Coding patterns | references/common-coding-patterns.md | TypeScript (types, control flow, errors, enums, destructuring, etc.) |
| Naming patterns | references/common-naming-patterns.md | In-code naming (boolean prefixes, descriptive names) |
| React patterns | references/common-react-patterns.md | Hooks, components, JSX, state, styling, fragments |
| Unit testing | references/common-unit-testing.md | Jest / Vitest, React Testing Library, AAA, mocks, selectors |
| Codebase summary | references/reference-codebase-summary.md | Concrete patterns from reference frontend (optional) |
Three-phase workflow
When the skill is invoked on code (selected files, git staged files, branch):
Preliminary — Run linter
- Run the project linter:
yarn lintornpm run lint(use the one that matches the project). - Collect every reported rule violation (rule id/name, file, line, message).
- For each violation:
- If the rule is auto-fixable (e.g.
--fix/eslint --fix), run the fix (e.g.yarn lint --fixornpm run lint --fix) and consider the violation resolved. - If the fix is not automatic, do your best to find a solution with the help of coding guidelines in
references/*.md(coding → common-coding-patterns, naming → common-naming-patterns, React → common-react-patterns, tests → common-unit-testing) and apply the Prefer correction described for that rule.
- If the rule is auto-fixable (e.g.
- Re-run the linter after fixes; repeat until lint passes or only violations that need manual interpretation remain.
Phase 1 — Collect violations
- Analyze the provided code against the reference files above.
- Identify every place where the code matches an Avoid pattern.
- List each violation in a single report with:
- Category (coding / naming / React / unit testing)
- Rule name (e.g. "Avoid Using
anyfor Type Definitions") - Location (file and line or snippet)
- Short reason (what is wrong)
- If no Avoid pattern is found, state that the code complies and stop. Otherwise proceed to Phase 2.
Phase 2 — Apply corrections
- For each violation in the report:
- Open the corresponding reference file and find the Prefer section paired with that Avoid rule.
- Apply the recommended correction so the code follows the Prefer pattern.
- Preserve business logic and behavior; only change structure, naming, or patterns.
- Prefer minimal edits: one logical change per violation, no unnecessary rewrites.
- When several standards apply to the same area, prioritize: TypeScript safety → naming clarity → React architecture → testing structure.
Rules of thumb
- Strict avoid/prefer: Only treat as violations what is explicitly described as Avoid in the reference files; only apply fixes that are explicitly described as Prefer there.
- One violation, one fix: One Avoid → one corresponding Prefer; do not mix multiple rules in a single edit unless they target the same line.
- Readability and maintainability: After corrections, the code should be easier to read and maintain, without changing behavior.
Quick reference
- Lint first: Run
yarn lintornpm run lint; fix auto-fixable issues, then resolve remaining ones usingreferences/*.md. - Tests: Project may use Jest or Vitest; same patterns apply (AAA,
screen,it.each, mock factories). Usevi(Vitest) orjest(Jest) for spies/mocks. - Collect next: Complete the full list of Avoid violations (manual analysis) before making edits.
- Then redress: Apply each Prefer in turn, using the reference file as the source of truth.
- File/folder naming: Use react-files-structure-standards for normalizing file and folder names and structure.
More from lichens-innovation/skills
react-single-responsibility
Strategies to simplify components, hooks, and methods: decomposition order (utilities, hooks, sub-components), early returns, control flow, parameter design, and code smell fixes. Use when the user says: ungodify this method/function/component, simplify this method/function/component, make this method/function/component less complex; or when refactoring a large component, hook, or function, reducing complexity, applying single responsibility, or asking how to simplify a component, hook, or method.
29generate-pr-description
Generates pull request descriptions by comparing current branch with parent branch. Creates semantic commit-style PR titles and fills PR templates. Use when the user asks to generate PR description, prepare pull request, or create merge request description. The user may include ticket IDs in the request (e.g. tickets: NN-123, TB-456) from the company tracking system; treat those as the related issue IDs for the PR.
28review-staged-changes
Reviews staged git changes for code quality, maintainability, readability, and potential regressions. Verifies changes make sense in context, improve maintainability, enhance readability, and don't introduce side effects. Use when reviewing staged changes, examining git diffs, or when the user asks to review modifications before committing.
25hello-world
This skill welcomes users in ASCII art with OS information. Use when the user says 'hello' or 'hi'.
20typescript-and-react-guidelines
|
10single-responsibility
|
6