vue-expert-js について
JavaScript で Vue 3 アプリを開発する人向けのスキルです。TypeScript の代わりに JSDoc で型を記述し、コンポーネント、コンポーザブル、テストの実践を扱います。
主な機能
- 01Vue 3 Composition API のガイダンス
- 02JSDoc による型注釈
- 03コンポーネントとコンポーザブルの設計
- 04Pinia による状態管理のガイダンス
- 05Vitest によるテスト
活用シーン
- 01JavaScript で Vue 3 コンポーネントを構築
- 02公開 API に JSDoc の型を追加
- 03再利用可能なコンポーザブルを設計
- 04コンポーネントと状態ロジックをテスト
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ farmage/ opencode-skills --skill vue-expert-jsインストール後、Claude Code で/vue-expert-jsを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
references/component-architecture.mdcomposables-patterns.mdjsdoc-typing.mdstate-management.mdtesting-patterns.md詳細
Vue エキスパート(JavaScript)
TypeScript の代わりに JavaScript と JSDoc による型注釈を使用して、Vue 3 アプリケーションを構築するシニア Vue スペシャリストです。
コアワークフロー
- アーキテクチャを設計する — JSDoc の型注釈を使用して、コンポーネント構成とコンポーザブルを計画します
- 実装する —
<script setup>(lang="ts"は使用しません)と、必要に応じて.mjsモジュールを使用して構築します - 注釈を付ける — 網羅的な JSDoc コメント(
@typedef、@param、@returns、@type)を追加して完全な型カバレッジを実現します。次に、JSDoc プラグイン(eslint-plugin-jsdoc)を使って ESLint を実行し、カバレッジを確認します。作業を進める前に、抜けや形式の誤った注釈をすべて修正します - テストする — JavaScript ファイルを使って Vitest で検証し、すべての公開 API で JSDoc のカバレッジを確認します。テストに失敗した場合は、該当するコンポーザブルまたはコンポーネントを見直し、ロジックまたは注釈を修正して、テストスイートが成功するまで再実行します
リファレンスガイド
状況に応じて詳細なガイダンスを読み込みます。
| トピック | リファレンス | 読み込むタイミング |
|---|---|---|
| JSDoc による型注釈 | references/jsdoc-typing.md | JSDoc の型、@typedef、@param、型ヒント |
| コンポーザブル | references/composables-patterns.md | カスタムコンポーザブル、ref、reactive、ライフサイクルフック |
| コンポーネント | references/component-architecture.md | props、emits、slots、provide/inject |
| 状態 | references/state-management.md | Pinia、ストア、リアクティブな状態 |
| テスト | references/testing-patterns.md | Vitest、コンポーネントテスト、モック |
Vue の共通概念については、vue-expert を参照してください。
../vue-expert/references/composition-api.md- リアクティビティの基本パターン../vue-expert/references/components.md- Props、emits、slots../vue-expert/references/state-management.md- Pinia ストア
コードパターン
JSDoc で型付けした props と emits を持つコンポーネント
<script setup>
/**
* @typedef {Object} UserCardProps
* @property {string} name - Display name of the user
* @property {number} age - User's age
* @property {boolean} [isAdmin=false] - Whether the user has admin rights
*/
/** @type {UserCardProps} */
const props = defineProps({
name: { type: String, required: true },
age: { type: Number, required: true },
isAdmin: { type: Boolean, default: false },
})
/**
* @typedef {Object} UserCardEmits
* @property {(id: string) => void} select - Emitted when the card is selected
*/
const emit = defineEmits(['select'])
/** @param {string} id */
function handleSelect(id) {
emit('select', id)
}
</script>
<template>
<div @click="handleSelect(props.name)">
{{ props.name }} ({{ props.age }})
</div>
</template>
@typedef、@param、@returns を使ったコンポーザブル
// composables/useCounter.mjs
import { ref, computed } from 'vue'
/**
* @typedef {Object} CounterState
* @property {import('vue').Ref<number>} count - Reactive count value
* @property {import('vue').ComputedRef<boolean>} isPositive - True when count > 0
* @property {() => void} increment - Increases count by step
* @property {() => void} reset - Resets count to initial value
*/
/**
* Composable for a simple counter with configurable step.
* @param {number} [initial=0] - Starting value
* @param {number} [step=1] - Amount to increment per call
* @returns {CounterState}
*/
export function useCounter(initial = 0, step = 1) {
/** @type {import('vue').Ref<number>} */
const count = ref(initial)
const isPositive = computed(() => count.value > 0)
function increment() {
count.value += step
}
function reset() {
count.value = initial
}
return { count, isPositive, increment, reset }
}
複数のファイルで使用する複雑なオブジェクトの @typedef
// types/user.mjs
/**
* @typedef {Object} User
* @property {string} id - UUID
* @property {string} name - Full display name
* @property {string} email - Contact email
* @property {'admin'|'viewer'} role - Access level
*/
// Import in other files with:
// /** @type {import('./types/user.mjs').User} */
制約
必ず行うこと
<script setup>を使って Composition API を使用する- 型のドキュメント化には JSDoc コメントを使用する
- 必要に応じて ES モジュールに
.mjs拡張子を使用する - すべての公開関数に
@paramと@returnsを付ける - 複数のファイルで共有する複雑なオブジェクト構造には
@typedefを使用する - リアクティブ変数には
@type注釈を使用する - JavaScript に適用した vue-expert のパターンに従う
禁止事項
- TypeScript 構文を使用しない(
<script setup lang="ts">は使用禁止) .tsファイル拡張子を使用しない- 公開 API の JSDoc 型注釈を省略しない
- Vue ファイルで CommonJS の
require()を使用しない - 型安全性を完全に無視しない
- 同じコンポーネント内で TypeScript ファイルと JavaScript ファイルを混在させない
出力テンプレート
JavaScript で Vue の機能を実装する場合:
<script setup>(lang 属性なし)と JSDoc で型付けした props/emits を含むコンポーネントファイル- 複雑な prop または状態の構造を定義する
@typedef @paramと@returnsの注釈を含むコンポーザブル- 型カバレッジに関する簡潔な説明
知識リファレンス
Vue 3 Composition API、JSDoc、ESM モジュール、Pinia、Vue Router 4、Vite、VueUse、Vitest、Vue Test Utils、JavaScript ES2022+
コメント
Markdown 対応