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# Code Quality Rules23## Scope Control45Flag changes that expand beyond the requested feature or review scope:67- Repo-wide cleanup mixed into a targeted fix.8- Compatibility exports, aliases, shims, or wrapper layers added without an explicit migration requirement.9- Shared abstractions created before there is stable cross-feature reuse.10- Business components moved into generic shared locations without a clear ownership boundary.1112## TypeScript1314Flag:1516- `any` or broad `Record<string, any>` where generated/API types or local domain types exist.17- Re-declared API shapes instead of importing generated or returned types.18- Weak route/query param typing that leaks `string | string[] | undefined` deep into components.19- Runtime wrappers added only to satisfy TypeScript when a narrower type boundary would preserve the existing runtime shape.2021Prefer:2223- Explicit domain names that match the API contract.24- Type narrowing at route/API boundaries.25- Small conversion helpers colocated with the component that needs them.2627## Styling2829Flag:3031- New CSS modules or ad hoc CSS when Tailwind utilities and Dify tokens cover the need.32- Component-level plain `.css` files or component CSS imported through `globals.css`; use scoped `*.module.css` only when Tailwind and component variants cannot express the style.33- Generic color utilities where Dify semantic tokens exist.34- Hardcoded magic class values for colors, spacing, radius, shadow, z-index, or typography when Dify tokens, component variants, or documented radius mappings exist.35- `!` important modifiers or important CSS overrides without a narrow, documented reason.36- Manual string concatenation, template strings, array `.join(' ')`, or custom ternaries for conditional or multi-line classes.37- JS conditional class branches for primitive visual states already exposed by Dify UI/Base UI `data-*` selectors.38- Incoming `className` placed before default classes in `cn(...)`, preventing call-site overrides.39- Arbitrary z-index or one-off layering fixes on overlays.4041Use:4243- `cn(...)` from the local package or utility already used by the file.44- Dify semantic tokens and Tailwind v4 utilities.45- Existing component variants before one-off class forks.46- Primitive selectors such as `data-disabled:*`, `data-checked:*`, `data-highlighted:*`, `group-data-*`, `peer-data-*`, and `has-[:focus-visible]` before adding React state or boolean props solely for styling.47- Component-level variants, semantic tokens, and normal cascade/order before `!` overrides. Use `!` only for a contained compatibility override that cannot be expressed through the component API or local selector structure.4849## Imports5051Flag:5253- Barrel imports from `@langgenius/dify-ui`; consumers must use subpath exports.54- New overlay imports from legacy `@/app/components/base/modal`, `dialog`, or `drawer`.55- Cross-feature imports that bypass explicit top-level public files.56- Direct imports from generated/internal implementation files when a feature contract already exposes the intended surface.5758## Copy And i18n5960Flag:6162- User-facing hardcoded strings in `web/`.63- Added or renamed i18n keys that are not present in every supported locale file for the touched namespace.64- Translation namespace drift, especially using unrelated module namespaces for local feature copy.65- Generic button labels like `Continue` where the action is specific.66- Error messages that state only the failure and not the next step.6768Use feature-local translation keys by default. Alias only when crossing namespaces. `pnpm i18n:check --file <name>` should pass for any touched translation namespace.69