Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Frontend code review guidance from the Dify LLM application development platform repository.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/code-quality.md
1# Rule Catalog — Code Quality23## Conditional class names use utility function45IsUrgent: True6Category: Code Quality78### Description910Ensure conditional CSS is handled via the shared `classNames` instead of custom ternaries, string concatenation, or template strings. Centralizing class logic keeps components consistent and easier to maintain.1112### Suggested Fix1314```ts15import { cn } from '@/utils/classnames'16const classNames = cn(isActive ? 'text-primary-600' : 'text-gray-500')17```1819## Tailwind-first styling2021IsUrgent: True22Category: Code Quality2324### Description2526Favor Tailwind CSS utility classes instead of adding new `.module.css` files unless a Tailwind combination cannot achieve the required styling. Keeping styles in Tailwind improves consistency and reduces maintenance overhead.2728Update this file when adding, editing, or removing Code Quality rules so the catalog remains accurate.2930## Classname ordering for easy overrides3132### Description3334When writing components, always place the incoming `className` prop after the component’s own class values so that downstream consumers can override or extend the styling. This keeps your component’s defaults but still lets external callers change or remove specific styles.3536Example:3738```tsx39import { cn } from '@/utils/classnames'4041const Button = ({ className }) => {42return <div className={cn('bg-primary-600', className)}></div>43}44```45