3.5 KiB
3.5 KiB
Activepieces — Coding Rules
File Structure
-
Exported types and constants must be placed at the end of the file, after all logic (functions, hooks, components, classes, etc.). This keeps the logic front and centre when reading a file, and groups the public contract at a predictable location.
// ✅ Correct function doSomething() { ... } export const MY_CONST = 'value'; export type MyType = { ... }; // ✅ Correct const businessService = () => { ... } export const MY_CONST = 'value'; export type MyType = { ... }; // ❌ Wrong — types/consts mixed in before logic export const MY_CONST = 'value'; export type MyType = { ... }; function doSomething() { ... }
Coding Conventions
- No
anytype — Use proper type definitions orunknownwith type guards - Zod error messages must be i18n keys — Every
.min(),.refine(),.superRefine(), etc. that surfaces a user-facing message must pass a string that exists as a key inpackages/web/public/locales/en/translation.json. For common messages (e.g. required fields) use theformErrorsconstant from@activepieces/shared. Add a new translation key if none fits; never use raw English sentences that are not in the translation file. @activepieces/sharedversion bump — Any change topackages/sharedmust be accompanied by a version bump inpackages/shared/package.json: bump the patch version for non-breaking additions or fixes, bump the minor version for new exports or behaviour changes.- No type casting — Do not use
as SomeTypeto force types. If you encounter an unnecessary cast, remove it. - No deprecated APIs — Before using any library method or export, check its JSDoc. If it carries a
@deprecatedtag, use the recommended replacement instead. Examples: preferz.enumoverz.nativeEnum. - Go-style error handling — Use
tryCatch/tryCatchSyncfrom@activepieces/shared - Helper functions — Define non-exported helpers outside of const declarations
- File order: Imports → Exported functions/constants → Helper functions → Types
- Comments — Only comment to explain why something is done, never what the code is doing. Code should be self-explanatory; comments that restate the code add noise and rot.
Git Push
- Always prefix
git pushwithCLAUDE_PUSH=yesto auto-approve the pre-push lint/test gate, e.g.CLAUDE_PUSH=yes git push -u origin HEAD.
Pull Requests
- When creating a PR with
gh pr create, always apply exactly one of these labels based on the nature of the change:feature— new functionalitybug— bug fixskip-changelog— changes that should not appear in the changelog (docs, CI tweaks, internal refactors, etc.)
- If the PR includes any contributions to pieces (integrations under
packages/pieces), also add thepieceslabel (in addition to the primary label above).
Database Migrations
- Before creating or modifying a database migration, always read the Database Migrations Playbook first. Follow its instructions for generating and structuring migrations.
Verification
- Always run
npm run lint-devas part of any verification step before considering a task complete.