원클릭으로
repo-source-code-document
// Document Formisch source code with JSDoc and inline comments. Use when writing or updating documentation comments in packages/core, packages/methods, or frameworks/* source files.
// Document Formisch source code with JSDoc and inline comments. Use when writing or updating documentation comments in packages/core, packages/methods, or frameworks/* source files.
| name | repo-source-code-document |
| description | Document Formisch source code with JSDoc and inline comments. Use when writing or updating documentation comments in packages/core, packages/methods, or frameworks/* source files. |
| metadata | {"author":"formisch","version":"1.0"} |
A concise guide for documenting Formisch source code with JSDoc and inline comments.
First line format:
[Name] [category] interface. → "Form store interface."[Name] [category] type. → "Validation mode type."Special cases:
/**
* Form store interface.
*/
export interface FormStore<TSchema extends FormSchema> {
/**
* Whether the form is currently submitting.
*/
readonly isSubmitting: ReadonlySignal<boolean>;
/**
* The current error messages of the form.
*/
readonly errors: ReadonlySignal<[string, ...string[]] | null>;
}
Property patterns:
Whether the [subject] [condition].The current [description].The path to the [description] within the form.The [description] of the field element.Overload signatures only (no JSDoc on implementation):
/**
* Creates a reactive field store of a specific field within a form store.
*
* @param form The form store instance.
* @param config The field configuration.
*
* @returns The field store with reactive properties and element props.
*/
export function useField<TSchema, TFieldPath>(
form: FormStore<TSchema>,
config: UseFieldConfig<TSchema, TFieldPath>
): FieldStore<TSchema, TFieldPath>;
// @__NO_SIDE_EFFECTS__
export function useField(form: FormStore, config: UseFieldConfig): FieldStore {
// Implementation (no JSDoc)
}
Rules:
@param: The [description]. (start with "The", end with period)@returns: The [description]. (describe what is returned)// @__NO_SIDE_EFFECTS__ for pure functions only/**
* Internal symbol constant.
*/
export const INTERNAL = '~internal' as const;
No JSDoc and inline comments needed - keep clean.
Mark major logic blocks:
// Get input value from field store
const input = getFieldInput(internalFieldStore);
// If validation is required, perform validation
if (shouldValidate) {
// implementation
}
// If field is touched, validate
if (isTouched) {
validate();
}
// Otherwise, if validation mode is initial, validate
else if (validate === 'initial') {
performValidation();
}
// Otherwise, skip validation
else {
return;
}
Group related operations under one comment:
// Set validation configuration
store.validators = 0;
store.validate = config.validate ?? 'submit';
store.revalidate = config.revalidate ?? 'input';
Explain WHY, not WHAT. Can use articles and periods:
// Hint: The object is deliberately not constructed with spread operator
// for performance reasons
const obj = { prop: value };
In JSDoc:
/**
* The initial input of the field.
*
* Hint: The initial input is used for resetting and may only be changed
* during this process. It does not move when a field is moved.
*/
initialInput: Signal<unknown>;
Same properties/functions across frameworks must use identical documentation text.
Check documentation in other frameworks before adding or modifying.
index, key, item)@ts-expect-error when context is clear[Name] [category] interface.[Name] [category] type.@param name The [description].
@returns The [description].
@internal (for internal APIs only)
// Get [what]
// Set [what] to [value]
// If [condition], [action]
// Otherwise, [action]
// Hint: [explanation with articles and period]
// TODO: [task]
Review PRs and source code changes in Formisch packages/ and frameworks/. Use when reviewing pull requests, validating implementation patterns, or checking code quality before merging.
Create new API documentation routes for the Formisch website. Use when adding documentation for new exported functions, types, components, or methods that don't yet have website documentation.
Review and verify API documentation routes on the Formisch website. Use when checking documentation accuracy, completeness, and consistency with source code.
Update existing API documentation when Formisch source code changes. Use when function signatures, types, interfaces, or JSDoc comments change in the library source.
Write unit and type tests for Formisch framework packages (frameworks/preact, frameworks/solid, frameworks/svelte, frameworks/vue, frameworks/react). Use when adding tests for hooks/composables/runes (useForm/createForm, useField, useFieldArray) or components (Form, Field, FieldArray) in any framework wrapper.
Write unit tests for Formisch packages (packages/core and packages/methods) with proper TypeScript types. Use when creating new tests, fixing type errors in tests, or adding test coverage for core/methods functions.