3.6 KiB
3.6 KiB
JSDoc Patterns
@category Guidance
When adding or vetting JSDoc categories in public source files:
- Use exactly one
@categorytag for each public JSDoc block that represents a documented API. - Use shared categories consistently across the repository. Domain-specific categories are allowed when they improve navigation within a file or package, but avoid one-off categories unless they name an important API/domain concept.
- Prefer lowercase category names by default, plural nouns for API buckets, and gerunds for operation families.
- Preserve canonical casing for acronyms and proper API/domain names, such as
type IDs,DateTime,Undici, andHttpAgent. - Prefer shared API-shape categories for common Effect/library patterns, and use domain-topic categories only when they provide clearer navigation.
- Avoid vague fallback categories. Do not use
utils,common, ormisc; pick a specific shared or domain category instead.
Common Shared Categories
- API shapes:
constructors,destructors,models,schemas,guards,predicates,getters,accessors,instances,constants,protocols,prototypes,re-exports,unsafe,testing - Effect/service concepts:
services,tags,layers,context,resource management,running - Type-level APIs:
utility typesfor type-level helpers/contracts; usemodelsfor exported type/interface/class shapes that represent domain data - Error APIs:
errorsfor error models/classes/types,error handlingfor recovery/catching/mapping APIs - Operations:
combinators,filtering,mapping,sequencing,zipping,combining,merging,converting,transforming,folding,splitting,repetition - Encoding/data formats:
encoding,decoding,serialization - Observability:
tracing,metrics,logging - Other common concepts:
annotations,references,symbols,type IDs,configuration,math,comparisons,ordering
Category Normalization
Normalize category names before adding or reviewing JSDoc:
- Lowercase plain category names. Preserve established acronyms and proper
names, such as
type IDs,DateTime,JSON getters,Base64 getters, andStandard Schema. - Prefer shared plural buckets when the meaning is the same, such as
constructors,models,schemas,guards,getters,services,layers,generators,subscriptions,cookies, andsizes. - Prefer shared operation families over narrow synonyms when precision is not
important, such as
combining,mapping,filtering,folding,converting,transforming,sequencing, andrepetition. - Replace vague fallback categories such as
utils,common,misc, orhelperswith a specific shared or domain category. - Use
servicesforContext.ServiceandContext.Referenceexports, and usetagsonly forContext.Tagexports. - Fix obvious typos and compact variants during cleanup, such as
transferables,re-exports,resource management, andStandard Schema.
Distinctions
Keep these distinctions:
servicesareContext.Service/Context.Referenceexports and service contracts/shapes,tagsareContext.Tagexports, andlayersprovide services.gettersretrieve values/properties, whileaccessorsare contextual service or environment access helpers.errorsare error data types, whileerror handlingis for APIs that handle failures.modelsdescribe domain/API data structures, whileschemasare schema values/combinators andutility typesare type-level helpers/contracts.guardsare TypeScript type guards,predicatesare boolean tests, andfilteringis for filtering operations.