mcpField
V
vue-expert-js

vue-expert-js

github.com/farmage開発224276 回インストール5 週間前に更新
リポジトリ

vue-expert-js について

JavaScript で Vue 3 アプリを開発する人向けのスキルです。TypeScript の代わりに JSDoc で型を記述し、コンポーネント、コンポーザブル、テストの実践を扱います。

主な機能

  1. 01Vue 3 Composition API のガイダンス
  2. 02JSDoc による型注釈
  3. 03コンポーネントとコンポーザブルの設計
  4. 04Pinia による状態管理のガイダンス
  5. 05Vitest によるテスト

活用シーン

  1. 01JavaScript で Vue 3 コンポーネントを構築
  2. 02公開 API に JSDoc の型を追加
  3. 03再利用可能なコンポーザブルを設計
  4. 04コンポーネントと状態ロジックをテスト

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/farmage/opencode-skills --skill vue-expert-js

インストール後、Claude Code で/vue-expert-jsを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

references/
component-architecture.md
composables-patterns.md
jsdoc-typing.md
state-management.md
testing-patterns.md

詳細

Vue エキスパート(JavaScript)

TypeScript の代わりに JavaScript と JSDoc による型注釈を使用して、Vue 3 アプリケーションを構築するシニア Vue スペシャリストです。

コアワークフロー

  1. アーキテクチャを設計する — JSDoc の型注釈を使用して、コンポーネント構成とコンポーザブルを計画します
  2. 実装する — <script setup>(lang="ts" は使用しません)と、必要に応じて .mjs モジュールを使用して構築します
  3. 注釈を付ける — 網羅的な JSDoc コメント(@typedef、@param、@returns、@type)を追加して完全な型カバレッジを実現します。次に、JSDoc プラグイン(eslint-plugin-jsdoc)を使って ESLint を実行し、カバレッジを確認します。作業を進める前に、抜けや形式の誤った注釈をすべて修正します
  4. テストする — JavaScript ファイルを使って Vitest で検証し、すべての公開 API で JSDoc のカバレッジを確認します。テストに失敗した場合は、該当するコンポーザブルまたはコンポーネントを見直し、ロジックまたは注釈を修正して、テストスイートが成功するまで再実行します

リファレンスガイド

状況に応じて詳細なガイダンスを読み込みます。

トピックリファレンス読み込むタイミング
JSDoc による型注釈references/jsdoc-typing.mdJSDoc の型、@typedef、@param、型ヒント
コンポーザブルreferences/composables-patterns.mdカスタムコンポーザブル、ref、reactive、ライフサイクルフック
コンポーネントreferences/component-architecture.mdprops、emits、slots、provide/inject
状態references/state-management.mdPinia、ストア、リアクティブな状態
テストreferences/testing-patterns.mdVitest、コンポーネントテスト、モック

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 の機能を実装する場合:

  1. <script setup>(lang 属性なし)と JSDoc で型付けした props/emits を含むコンポーネントファイル
  2. 複雑な prop または状態の構造を定義する @typedef
  3. @param と @returns の注釈を含むコンポーザブル
  4. 型カバレッジに関する簡潔な説明

知識リファレンス

Vue 3 Composition API、JSDoc、ESM モジュール、Pinia、Vue Router 4、Vite、VueUse、Vitest、Vue Test Utils、JavaScript ES2022+

ドキュメント

コメント