Index of every page on this site: llms.txt
All skills
jyasuu avatar

/vue-best-practices

@d3e2684
Run it yourself

Vue 3 and Vue.js best practices for TypeScript, vue-tsc, and Volar. This skill should be used when writing, reviewing, or refactoring Vue components to ensure correct typing patterns. Triggers on tasks involving Vue components, props extraction, wrapper components, template type checking, or Volar configuration.

  • 18 files
  • 39.7 KB
  • MIT
  • Updated 10 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/jyasuu/cheat-sheet/vue-best-practices

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

rulesscript-setup-jsdoc.md

≈495 tokens on demand. Your agent reads this file only when SKILL.md points to it.

JSDoc Documentation for Script Setup Components

Impact: MEDIUM - enables proper documentation for composition API components

<script setup> doesn't have an obvious place to attach JSDoc comments for the component itself. Use a dual-script pattern.

Problem

Incorrect:

<script setup lang="ts">
/**
 * This comment doesn't appear in IDE hover or docs
 * @component
 */
import { ref } from 'vue'

const count = ref(0)
</script>

JSDoc comments inside <script setup> don't attach to the component export because there's no explicit export statement.

Solution

Use both <script> and <script setup> blocks:

Correct:

<script lang="ts">
/**
 * A counter component that displays and increments a value.
 *
 * @example
 * ```vue
 * <Counter :initial="5" @update="handleUpdate" />
 * ```
 *
 * @component
 */
export default {}
</script>

<script setup lang="ts">
import { ref } from 'vue'

const props = defineProps<{
  /** Starting value for the counter */
  initial?: number
}>()

const emit = defineEmits<{
  /** Emitted when counter value changes */
  update: [value: number]
}>()

const count = ref(props.initial ?? 0)
</script>

How It Works

  • The regular <script> block's default export is merged with <script setup>
  • JSDoc on export default {} attaches to the component
  • Props and emits JSDoc in <script setup> still work normally

What Gets Documented

Location Shows In
export default {} JSDoc Component import hover
defineProps JSDoc Prop hover in templates
defineEmits JSDoc Event handler hover

Reference

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at d3e2684. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 10 months ago
metadata
{
  "author": "hyf0",
  "version": "8.0.0"
}

README badge

README badge for jyasuu/cheat-sheet/vue-best-practices