hoc-jsdoc
JSDoc writing conventions shared by backend and frontend. Use when writing or reviewing JSDoc, the type a tag carries included, in plain JavaScript or in Vue…
от openreachtech★ 17 звёзд на GitHub
Установить hoc-jsdoc в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Shared: JSDoc
Summarizes JSDoc writing conventions. All typing is JSDoc — no TypeScript syntax, no .ts
files — so always annotate types with JSDoc.
The rules in this body apply to every JavaScript file, backend and frontend alike.
How the jsdoc-plugin rules actually in effect under this project's ESLint map to each of this skill's conventions is summarized in eslint-jsdoc-rules.md. If you write JSDoc as this skill prescribes,
npm run lintproduces no jsdoc-related errors. Note that lint also enforces such points as:functiondeclarations and methods must have JSDoc (empty constructors are not exempt), each@paramrequires a type and a name, and a function that returns a value needs@returns(with a type). This skill goes one step further and requires@returnseven when nothing is returned ({void}).
Write object types with named parameters
- Do not use
{object}. - Write objects as an inline type literal, explicitly listing each property as a named parameter.
Example:
// NG
/**
* @param {object} params - Parameters.
* @param {string} params.alpha - Alpha.
*/
// OK
/**
* @param {{
* alpha: string
* }} params - Parameters.
*/
Name a single object argument params
- For a method that takes a single object argument, name the parameter
paramsunless there is a special reason not to.
// OK
/**
* @param {{
* alpha: string
* }} params - Parameters.
*/
Always write @returns
- Every function and method gets
@returns, even one that returns nothing. - For a function that returns nothing, write
@returns {void}(@returns {Promise<void>}when it is async). Never omit the tag. - Lint (
jsdoc/require-returns) only demands@returnswhen a value is actually returned, so this skill is stricter than lint here (see eslint-jsdoc-rules.md). The reason is that "returns nothing" should be stated, not inferred from the absence of a tag.
// NG: returns nothing, so @returns is omitted
/**
* @param {{
* message: string
* }} params - Parameters.
*/
// OK
/**
* @param {{
* message: string
* }} params - Parameters.
* @returns {void}
*/
Attach a description to @returns
- Attach not just a type but also a description to
@returns. - The sole exception is
@returns {void}/@returns {Promise<void>}. There is no returned value to describe, so the type stands on its own. - Do not put a hyphen between the type and the description. The leading
-is a@paramconvention (jsdoc/require-hyphen-before-param-description) and does not apply to@returns. - Lint (
jsdoc/require-returns-description) is off and does not force a description, but this skill always attaches one for QA reasons (see eslint-jsdoc-rules.md).
// NG: no description
/**
* @returns {string}
*/
// NG: a hyphen before the description
/**
* @returns {string} - Default characters to pick from.
*/
// OK
/**
* @returns {string} Default characters to pick from.
*/
Add @public to entry points
- Add
@publicto the JSDoc of any method that serves as an entry point accessed from outside.
/**
* Generate a random text of the given length.
*
* @param {{
* length: number
* }} params - Parameters.
* @returns {string | null} Generated random text, or null if it cannot be generated.
* @public
*/
generate ({
length,
}) {
// ...
}
Write array types as Array<T>
- Trailing-
[]array notation such asstring[]is prohibited. Always write it asArray<string>. - Reason: writing something like
{ alpha: number, beta: string }[]causes confusion for the reader.
// NG
/**
* @param {string[]} values - Values.
*/
// OK
/**
* @param {Array<string>} values - Values.
*/
Avoid vague types; write the most specific type you can
- Vague types such as
object/Object/any/*are not used unless clearly necessary. - Investigate the type and write it as a type literal with the most detailed properties possible, or as a concrete type name.
- Make generics concrete as far as possible. Do not leave the element type vague as
Array<object>; writeArray<UserEntity>instead.
// NG: vague element type and return type
/**
* @param {{
* users?: Array<object>
* }} params - Parameters.
* @returns {object} Users and their total count.
*/
// OK: investigate and write the detailed type
/**
* @param {{
* users?: Array<UserEntity>
* }} params - Parameters.
* @returns {{
* users: Array<UserEntity>
* total: number
* }} Users and their total count.
*/
object / Object is prohibited; use Record<string, *>
object/Objectis prohibited regardless of the reason.- Reason:
objectis dangerous in that it tolerates ambiguity includingnull. Even when you are for
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/eslint-jsdoc-rules.md
- references/import-expression.md
- references/import-tag.md
FAQ
Что делает скилл hoc-jsdoc?
JSDoc writing conventions shared by backend and frontend. Use when writing or reviewing JSDoc, the type a tag carries included, in plain JavaScript or in Vue. Use it also when clearing a type error a checker such as `tsc` reports: the error is cleared by writing the annotation, and which annotations may be written is decided here. Reading what the checker reported belongs to the type-errors convention.
Как установить скилл hoc-jsdoc?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл hoc-jsdoc запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
AnthropicGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
academy-guide
AnthropicStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
internal-comms
AnthropicA set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
skill-development
AnthropicThis skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…