@dianzhong/create-harness-app 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/dist/index.mjs +412 -0
  2. package/package.json +29 -0
  3. package/templates/axios/.env.example +2 -0
  4. package/templates/axios/src/api/auth.ts +19 -0
  5. package/templates/axios/src/api/request.ts +61 -0
  6. package/templates/axios/src/types/api.ts +26 -0
  7. package/templates/axios/src/utils/auth.ts +5 -0
  8. package/templates/axios/src/utils/storage.ts +17 -0
  9. package/templates/harness/full/.agents/skills/find-skills/SKILL.md +143 -0
  10. package/templates/harness/full/.agents/skills/vue-best-practices/LICENSE.md +21 -0
  11. package/templates/harness/full/.agents/skills/vue-best-practices/SKILL.md +155 -0
  12. package/templates/harness/full/.agents/skills/vue-best-practices/SYNC.md +5 -0
  13. package/templates/harness/full/.agents/skills/vue-best-practices/references/animation-class-based-technique.md +258 -0
  14. package/templates/harness/full/.agents/skills/vue-best-practices/references/animation-state-driven-technique.md +287 -0
  15. package/templates/harness/full/.agents/skills/vue-best-practices/references/component-async.md +99 -0
  16. package/templates/harness/full/.agents/skills/vue-best-practices/references/component-data-flow.md +313 -0
  17. package/templates/harness/full/.agents/skills/vue-best-practices/references/component-fallthrough-attrs.md +179 -0
  18. package/templates/harness/full/.agents/skills/vue-best-practices/references/component-keep-alive.md +139 -0
  19. package/templates/harness/full/.agents/skills/vue-best-practices/references/component-slots.md +226 -0
  20. package/templates/harness/full/.agents/skills/vue-best-practices/references/component-suspense.md +231 -0
  21. package/templates/harness/full/.agents/skills/vue-best-practices/references/component-teleport.md +110 -0
  22. package/templates/harness/full/.agents/skills/vue-best-practices/references/component-transition-group.md +131 -0
  23. package/templates/harness/full/.agents/skills/vue-best-practices/references/component-transition.md +135 -0
  24. package/templates/harness/full/.agents/skills/vue-best-practices/references/composables.md +303 -0
  25. package/templates/harness/full/.agents/skills/vue-best-practices/references/directives.md +168 -0
  26. package/templates/harness/full/.agents/skills/vue-best-practices/references/perf-avoid-component-abstraction-in-lists.md +177 -0
  27. package/templates/harness/full/.agents/skills/vue-best-practices/references/perf-v-once-v-memo-directives.md +185 -0
  28. package/templates/harness/full/.agents/skills/vue-best-practices/references/perf-virtualize-large-lists.md +182 -0
  29. package/templates/harness/full/.agents/skills/vue-best-practices/references/plugins.md +178 -0
  30. package/templates/harness/full/.agents/skills/vue-best-practices/references/reactivity.md +371 -0
  31. package/templates/harness/full/.agents/skills/vue-best-practices/references/render-functions.md +227 -0
  32. package/templates/harness/full/.agents/skills/vue-best-practices/references/sfc.md +355 -0
  33. package/templates/harness/full/.agents/skills/vue-best-practices/references/state-management.md +138 -0
  34. package/templates/harness/full/.agents/skills/vue-best-practices/references/updated-hook-performance.md +193 -0
  35. package/templates/harness/full/.claude/agents/code-reviewer.md +109 -0
  36. package/templates/harness/full/.claude/agents/harness-reviewer.md +51 -0
  37. package/templates/harness/full/.claude/hooks/guard-tool.cjs +234 -0
  38. package/templates/harness/full/.claude/hooks/notify.cjs +168 -0
  39. package/templates/harness/full/.claude/hooks/quality-gate.cjs +135 -0
  40. package/templates/harness/full/.claude/rules/delivery.md +66 -0
  41. package/templates/harness/full/.claude/rules/formatting.md +7 -0
  42. package/templates/harness/full/.claude/rules/git.md +8 -0
  43. package/templates/harness/full/.claude/rules/skills-mcp.md +13 -0
  44. package/templates/harness/full/.claude/rules/vue.md +227 -0
  45. package/templates/harness/full/.claude/settings.json +123 -0
  46. package/templates/harness/full/.claude/skills/find-skills/SKILL.md +143 -0
  47. package/templates/harness/full/.claude/skills/vue-best-practices/LICENSE.md +21 -0
  48. package/templates/harness/full/.claude/skills/vue-best-practices/SKILL.md +155 -0
  49. package/templates/harness/full/.claude/skills/vue-best-practices/SYNC.md +5 -0
  50. package/templates/harness/full/.claude/skills/vue-best-practices/references/animation-class-based-technique.md +258 -0
  51. package/templates/harness/full/.claude/skills/vue-best-practices/references/animation-state-driven-technique.md +287 -0
  52. package/templates/harness/full/.claude/skills/vue-best-practices/references/component-async.md +99 -0
  53. package/templates/harness/full/.claude/skills/vue-best-practices/references/component-data-flow.md +313 -0
  54. package/templates/harness/full/.claude/skills/vue-best-practices/references/component-fallthrough-attrs.md +179 -0
  55. package/templates/harness/full/.claude/skills/vue-best-practices/references/component-keep-alive.md +139 -0
  56. package/templates/harness/full/.claude/skills/vue-best-practices/references/component-slots.md +226 -0
  57. package/templates/harness/full/.claude/skills/vue-best-practices/references/component-suspense.md +231 -0
  58. package/templates/harness/full/.claude/skills/vue-best-practices/references/component-teleport.md +110 -0
  59. package/templates/harness/full/.claude/skills/vue-best-practices/references/component-transition-group.md +131 -0
  60. package/templates/harness/full/.claude/skills/vue-best-practices/references/component-transition.md +135 -0
  61. package/templates/harness/full/.claude/skills/vue-best-practices/references/composables.md +303 -0
  62. package/templates/harness/full/.claude/skills/vue-best-practices/references/directives.md +168 -0
  63. package/templates/harness/full/.claude/skills/vue-best-practices/references/perf-avoid-component-abstraction-in-lists.md +177 -0
  64. package/templates/harness/full/.claude/skills/vue-best-practices/references/perf-v-once-v-memo-directives.md +185 -0
  65. package/templates/harness/full/.claude/skills/vue-best-practices/references/perf-virtualize-large-lists.md +182 -0
  66. package/templates/harness/full/.claude/skills/vue-best-practices/references/plugins.md +178 -0
  67. package/templates/harness/full/.claude/skills/vue-best-practices/references/reactivity.md +371 -0
  68. package/templates/harness/full/.claude/skills/vue-best-practices/references/render-functions.md +227 -0
  69. package/templates/harness/full/.claude/skills/vue-best-practices/references/sfc.md +355 -0
  70. package/templates/harness/full/.claude/skills/vue-best-practices/references/state-management.md +138 -0
  71. package/templates/harness/full/.claude/skills/vue-best-practices/references/updated-hook-performance.md +193 -0
  72. package/templates/harness/full/.editorconfig +8 -0
  73. package/templates/harness/full/.husky/commit-msg +1 -0
  74. package/templates/harness/full/.husky/pre-commit +1 -0
  75. package/templates/harness/full/.lintstagedrc.json +4 -0
  76. package/templates/harness/full/.nvmrc +1 -0
  77. package/templates/harness/full/.oxlintrc.json +11 -0
  78. package/templates/harness/full/.prettierrc.json +6 -0
  79. package/templates/harness/full/AGENTS.md +3 -0
  80. package/templates/harness/full/CLAUDE.md +28 -0
  81. package/templates/harness/full/GEMINI.md +3 -0
  82. package/templates/harness/full/commitlint.config.ts +3 -0
  83. package/templates/harness/full/docs/ai-harness.md +77 -0
  84. package/templates/harness/full/docs/delivery-template.md +66 -0
  85. package/templates/harness/full/docs/git.md +24 -0
  86. package/templates/harness/full/docs/harness-quick-reference.md +89 -0
  87. package/templates/harness/full/docs/review-checklist.md +49 -0
  88. package/templates/harness/full/scripts/harness-hooks.test.mjs +218 -0
  89. package/templates/harness/full/scripts/verify-skills.mjs +248 -0
  90. package/templates/harness/full/scripts/verify-skills.test.mjs +72 -0
  91. package/templates/harness/full/skills-lock.json +50 -0
  92. package/templates/harness/minimal/.claude/hooks/guard-tool.cjs +234 -0
  93. package/templates/harness/minimal/.claude/hooks/quality-gate.cjs +135 -0
  94. package/templates/harness/minimal/.claude/settings.json +27 -0
  95. package/templates/harness/minimal/CLAUDE.md +12 -0
@@ -0,0 +1,371 @@
1
+ ---
2
+ title: Reactivity Core Patterns (ref, reactive, shallowRef, computed, watch)
3
+ impact: MEDIUM
4
+ impactDescription: Clear reactivity choices keep state predictable and reduce unnecessary updates in Vue 3 apps
5
+ type: efficiency
6
+ tags:
7
+ [
8
+ vue3,
9
+ reactivity,
10
+ ref,
11
+ reactive,
12
+ shallowRef,
13
+ computed,
14
+ watch,
15
+ watchEffect,
16
+ external-state,
17
+ best-practice,
18
+ ]
19
+ ---
20
+
21
+ # Reactivity Core Patterns (ref, reactive, shallowRef, computed, watch)
22
+
23
+ **Impact: MEDIUM** - Choose the right reactive primitive first, derive with `computed`, and use watchers only for side effects.
24
+
25
+ This reference covers the core reactivity decisions for local state, external data, derived values, and effects.
26
+
27
+ ## Task List
28
+
29
+ - Declare reactive state correctly
30
+ - Always use `shallowRef()` instead of `ref()` for primitive values
31
+ - Choose the correct reactive declaration method for objects/arrays/map/set
32
+ - Follow best practices for `reactive`
33
+ - Avoid destructuring from `reactive()` directly
34
+ - Watch correctly for `reactive`
35
+ - Follow best practices for `computed`
36
+ - Prefer `computed` over watcher-assigned derived refs
37
+ - Keep filtered/sorted derivations out of templates
38
+ - Use `computed` for reusable class/style logic
39
+ - Keep computed getters pure (no side effects) and put side effects in watchers
40
+ - Follow best practices for watchers
41
+ - Use `immediate: true` instead of duplicate initial calls
42
+ - Clean up async effects for watchers
43
+
44
+ ## Declare reactive state correctly
45
+
46
+ ### Always use `shallowRef()` instead of `ref()` for primitive values (string, number, boolean, null, etc.) for better performance.
47
+
48
+ **Incorrect:**
49
+
50
+ ```ts
51
+ import { ref } from 'vue'
52
+
53
+ const count = ref(0)
54
+ ```
55
+
56
+ **Correct:**
57
+
58
+ ```ts
59
+ import { shallowRef } from 'vue'
60
+
61
+ const count = shallowRef(0)
62
+ ```
63
+
64
+ ### Choose the correct reactive declaration method for objects/arrays/map/set
65
+
66
+ Use `ref()` when you often **replace the entire value** (`state.value = newObj`) and still want deep reactivity inside it, usually used for:
67
+
68
+ - Frequently reassigned state (replace fetched object/list, reset to defaults, switch presets).
69
+ - Composable return values where updates happen mostly via `.value` reassignment.
70
+
71
+ Use `reactive()` when you mainly **mutate properties** and full replacement is uncommon, usually used for:
72
+
73
+ - “Single state object” patterns (stores/forms): `state.count++`, `state.items.push(...)`, `state.user.name = ...`.
74
+ - Situations where you want to avoid `.value` and update nested fields in place.
75
+
76
+ ```ts
77
+ import { reactive } from 'vue'
78
+
79
+ const state = reactive({
80
+ count: 0,
81
+ user: { name: 'Alice', age: 30 },
82
+ })
83
+
84
+ state.count++ // ✅ reactive
85
+ state.user.age = 31 // ✅ reactive
86
+ // ❌ avoid replacing the reactive object reference:
87
+ // state = reactive({ count: 1 })
88
+ ```
89
+
90
+ Use `shallowRef()` when the value is **opaque / should not be proxied** (class instances, external library objects, very large nested data) and you only want updates to trigger when you **replace** `state.value` (no deep tracking), usually used for:
91
+
92
+ - Storing external instances/handles (SDK clients, class instances) without Vue proxying internals.
93
+ - Large data where you update by replacing the root reference (immutable-style updates).
94
+
95
+ ```ts
96
+ import { shallowRef } from 'vue'
97
+
98
+ const user = shallowRef({ name: 'Alice', age: 30 })
99
+
100
+ user.value.age = 31 // ❌ not reactive
101
+ user.value = { name: 'Bob', age: 25 } // ✅ triggers update
102
+ ```
103
+
104
+ Use `shallowReactive()` when you want **only top-level properties** reactive; nested objects remain raw, usually used for:
105
+
106
+ - Container objects where only top-level keys change and nested payloads should stay unmanaged/unproxied.
107
+ - Mixed structures where Vue tracks the wrapper object, but not deeply nested or foreign objects.
108
+
109
+ ```ts
110
+ import { shallowReactive } from 'vue'
111
+
112
+ const state = shallowReactive({
113
+ count: 0,
114
+ user: { name: 'Alice', age: 30 },
115
+ })
116
+
117
+ state.count++ // ✅ reactive
118
+ state.user.age = 31 // ❌ not reactive
119
+ ```
120
+
121
+ ## Best practices for `reactive`
122
+
123
+ ### Avoid destructuring from `reactive()` directly
124
+
125
+ **BAD:**
126
+
127
+ ```ts
128
+ import { reactive } from 'vue'
129
+
130
+ const state = reactive({ count: 0 })
131
+ const { count } = state // ❌ disconnected from reactivity
132
+ ```
133
+
134
+ ### Watch correctly for reactive
135
+
136
+ **BAD:**
137
+
138
+ passing a non-getter value into `watch()`
139
+
140
+ ```ts
141
+ import { reactive, watch } from 'vue'
142
+
143
+ const state = reactive({ count: 0 })
144
+
145
+ // ❌ watch expects a getter, ref, reactive object, or array of these
146
+ watch(state.count, () => {
147
+ /* ... */
148
+ })
149
+ ```
150
+
151
+ **GOOD:**
152
+
153
+ preserve reactivity with `toRefs()` and use a getter for `watch()`
154
+
155
+ ```ts
156
+ import { reactive, toRefs, watch } from 'vue'
157
+
158
+ const state = reactive({ count: 0 })
159
+ const { count } = toRefs(state) // ✅ count is a ref
160
+
161
+ watch(count, () => {
162
+ /* ... */
163
+ }) // ✅
164
+ watch(
165
+ () => state.count,
166
+ () => {
167
+ /* ... */
168
+ },
169
+ ) // ✅
170
+ ```
171
+
172
+ ## Best practices for `computed`
173
+
174
+ ### Prefer `computed` over watcher-assigned derived refs
175
+
176
+ **BAD:**
177
+
178
+ ```ts
179
+ import { ref, watchEffect } from 'vue'
180
+
181
+ const items = ref([{ price: 10 }, { price: 20 }])
182
+ const total = ref(0)
183
+
184
+ watchEffect(() => {
185
+ total.value = items.value.reduce((sum, item) => sum + item.price, 0)
186
+ })
187
+ ```
188
+
189
+ **GOOD:**
190
+
191
+ ```ts
192
+ import { computed, ref } from 'vue'
193
+
194
+ const items = ref([{ price: 10 }, { price: 20 }])
195
+ const total = computed(() => items.value.reduce((sum, item) => sum + item.price, 0))
196
+ ```
197
+
198
+ ### Keep filtered/sorted derivations out of templates
199
+
200
+ **BAD:**
201
+
202
+ ```vue
203
+ <script setup>
204
+ import { ref } from 'vue'
205
+
206
+ const items = ref([
207
+ { id: 1, name: 'B', active: true },
208
+ { id: 2, name: 'A', active: false },
209
+ ])
210
+
211
+ function getSortedItems() {
212
+ return [...items.value].sort((a, b) => a.name.localeCompare(b.name))
213
+ }
214
+ </script>
215
+
216
+ <template>
217
+ <li v-for="item in items.filter((item) => item.active)" :key="item.id">
218
+ {{ item.name }}
219
+ </li>
220
+
221
+ <li v-for="item in getSortedItems()" :key="item.id">
222
+ {{ item.name }}
223
+ </li>
224
+ </template>
225
+ ```
226
+
227
+ **GOOD:**
228
+
229
+ ```vue
230
+ <script setup>
231
+ import { computed, ref } from 'vue'
232
+
233
+ const items = ref([
234
+ { id: 1, name: 'B', active: true },
235
+ { id: 2, name: 'A', active: false },
236
+ ])
237
+
238
+ const visibleItems = computed(() =>
239
+ items.value.filter((item) => item.active).sort((a, b) => a.name.localeCompare(b.name)),
240
+ )
241
+ </script>
242
+
243
+ <template>
244
+ <li v-for="item in visibleItems" :key="item.id">
245
+ {{ item.name }}
246
+ </li>
247
+ </template>
248
+ ```
249
+
250
+ ### Use `computed` for reusable class/style logic
251
+
252
+ **BAD:**
253
+
254
+ ```vue
255
+ <template>
256
+ <button
257
+ :class="{ btn: true, 'btn-primary': type === 'primary' && !disabled, 'btn-disabled': disabled }"
258
+ >
259
+ {{ label }}
260
+ </button>
261
+ </template>
262
+ ```
263
+
264
+ **GOOD:**
265
+
266
+ ```vue
267
+ <script setup>
268
+ import { computed } from 'vue'
269
+
270
+ const props = defineProps({
271
+ type: { type: String, default: 'primary' },
272
+ disabled: Boolean,
273
+ label: String,
274
+ })
275
+
276
+ const buttonClasses = computed(() => ({
277
+ btn: true,
278
+ [`btn-${props.type}`]: !props.disabled,
279
+ 'btn-disabled': props.disabled,
280
+ }))
281
+ </script>
282
+
283
+ <template>
284
+ <button :class="buttonClasses">
285
+ {{ label }}
286
+ </button>
287
+ </template>
288
+ ```
289
+
290
+ ### Keep computed getters pure (no side effects) and put side effects in watchers instead
291
+
292
+ A computed getter should only derive a value. No mutation, no API calls, no storage writes, no event emits.
293
+ ([Reference](https://vuejs.org/guide/essentials/computed.html#best-practices))
294
+
295
+ **BAD:**
296
+
297
+ side effects inside computed
298
+
299
+ ```ts
300
+ const count = ref(0)
301
+
302
+ const doubled = computed(() => {
303
+ // ❌ side effect
304
+ if (count.value > 10) console.warn('Too big!')
305
+ return count.value * 2
306
+ })
307
+ ```
308
+
309
+ **GOOD:**
310
+
311
+ pure computed + `watch()` for side effects
312
+
313
+ ```ts
314
+ const count = ref(0)
315
+ const doubled = computed(() => count.value * 2)
316
+
317
+ watch(count, (value) => {
318
+ if (value > 10) console.warn('Too big!')
319
+ })
320
+ ```
321
+
322
+ ## Best practices for watchers
323
+
324
+ ### Use `immediate: true` instead of duplicate initial calls
325
+
326
+ **BAD:**
327
+
328
+ ```ts
329
+ import { onMounted, ref, watch } from 'vue'
330
+
331
+ const userId = ref(1)
332
+
333
+ function loadUser(id) {
334
+ // ...
335
+ }
336
+
337
+ onMounted(() => loadUser(userId.value))
338
+ watch(userId, (id) => loadUser(id))
339
+ ```
340
+
341
+ **GOOD:**
342
+
343
+ ```ts
344
+ import { ref, watch } from 'vue'
345
+
346
+ const userId = ref(1)
347
+
348
+ watch(userId, (id) => loadUser(id), { immediate: true })
349
+ ```
350
+
351
+ ### Clean up async effects for watchers
352
+
353
+ When reacting to rapid changes (search boxes, filters), cancel the previous request.
354
+
355
+ **GOOD:**
356
+
357
+ ```ts
358
+ const query = ref('')
359
+ const results = ref<string[]>([])
360
+
361
+ watch(query, async (q, _prev, onCleanup) => {
362
+ const controller = new AbortController()
363
+ onCleanup(() => controller.abort())
364
+
365
+ const res = await fetch(`/api/search?q=${encodeURIComponent(q)}`, {
366
+ signal: controller.signal,
367
+ })
368
+
369
+ results.value = await res.json()
370
+ })
371
+ ```
@@ -0,0 +1,227 @@
1
+ ---
2
+ title: Render Function Patterns and Performance
3
+ impact: MEDIUM
4
+ impactDescription: Render functions require explicit patterns for lists, events, v-model, and performance to stay correct and maintainable
5
+ type: best-practice
6
+ tags: [vue3, render-function, h, v-model, directives, performance, jsx]
7
+ ---
8
+
9
+ # Render Function Patterns and Performance
10
+
11
+ **Impact: MEDIUM** - Render functions are powerful but opt out of template compiler optimizations. Use them intentionally and apply the key patterns below to keep output correct and performant.
12
+
13
+ ## Task List
14
+
15
+ - Prefer templates; use render functions only when templates cannot express the logic
16
+ - Always add stable keys when rendering lists with `h()`/JSX
17
+ - Use `withModifiers` / `withKeys` for event modifiers
18
+ - Implement `v-model` via `modelValue` + `onUpdate:modelValue`
19
+ - Apply custom directives with `withDirectives`
20
+ - Use functional components for stateless presentational UI
21
+
22
+ ## Prefer templates over render functions
23
+
24
+ **BAD:**
25
+
26
+ ```vue
27
+ <script setup>
28
+ import { h, ref } from 'vue'
29
+
30
+ const count = ref(0)
31
+ const render = () => h('div', `Count: ${count.value}`)
32
+ </script>
33
+ ```
34
+
35
+ **GOOD:**
36
+
37
+ ```vue
38
+ <script setup>
39
+ import { ref } from 'vue'
40
+
41
+ const count = ref(0)
42
+ </script>
43
+
44
+ <template>
45
+ <div>Count: {{ count }}</div>
46
+ </template>
47
+ ```
48
+
49
+ ## Always add keys for list rendering
50
+
51
+ **BAD:**
52
+
53
+ ```javascript
54
+ import { h, ref } from 'vue'
55
+
56
+ export default {
57
+ setup() {
58
+ const items = ref([{ id: 1, name: 'Apple' }])
59
+
60
+ return () =>
61
+ h(
62
+ 'ul',
63
+ items.value.map((item) => h('li', item.name)),
64
+ )
65
+ },
66
+ }
67
+ ```
68
+
69
+ **GOOD:**
70
+
71
+ ```javascript
72
+ import { h, ref } from 'vue'
73
+
74
+ export default {
75
+ setup() {
76
+ const items = ref([{ id: 1, name: 'Apple' }])
77
+
78
+ return () =>
79
+ h(
80
+ 'ul',
81
+ items.value.map((item) => h('li', { key: item.id }, item.name)),
82
+ )
83
+ },
84
+ }
85
+ ```
86
+
87
+ ## Use `withModifiers` / `withKeys` for event modifiers
88
+
89
+ **BAD:**
90
+
91
+ ```javascript
92
+ import { h } from 'vue'
93
+
94
+ export default {
95
+ setup() {
96
+ const handleClick = (e) => {
97
+ e.stopPropagation()
98
+ e.preventDefault()
99
+ }
100
+
101
+ return () => h('button', { onClick: handleClick }, 'Click')
102
+ },
103
+ }
104
+ ```
105
+
106
+ **GOOD:**
107
+
108
+ ```javascript
109
+ import { h, withKeys, withModifiers } from 'vue'
110
+
111
+ export default {
112
+ setup() {
113
+ const handleClick = () => {}
114
+ const handleEnter = () => {}
115
+
116
+ return () =>
117
+ h('div', [
118
+ h(
119
+ 'button',
120
+ {
121
+ onClick: withModifiers(handleClick, ['stop', 'prevent']),
122
+ },
123
+ 'Click',
124
+ ),
125
+ h('input', {
126
+ onKeyup: withKeys(handleEnter, ['enter']),
127
+ }),
128
+ ])
129
+ },
130
+ }
131
+ ```
132
+
133
+ ## Implement `v-model` explicitly
134
+
135
+ **BAD:**
136
+
137
+ ```javascript
138
+ import { h, ref } from 'vue'
139
+
140
+ import CustomInput from './CustomInput.vue'
141
+
142
+ export default {
143
+ setup() {
144
+ const text = ref('')
145
+ return () => h(CustomInput, { modelValue: text.value })
146
+ },
147
+ }
148
+ ```
149
+
150
+ **GOOD:**
151
+
152
+ ```javascript
153
+ import { h, ref } from 'vue'
154
+
155
+ import CustomInput from './CustomInput.vue'
156
+
157
+ export default {
158
+ setup() {
159
+ const text = ref('')
160
+ return () =>
161
+ h(CustomInput, {
162
+ modelValue: text.value,
163
+ 'onUpdate:modelValue': (value) => {
164
+ text.value = value
165
+ },
166
+ })
167
+ },
168
+ }
169
+ ```
170
+
171
+ ## Use `withDirectives` for custom directives
172
+
173
+ **BAD:**
174
+
175
+ ```javascript
176
+ import { h } from 'vue'
177
+
178
+ const vFocus = { mounted: (el) => el.focus() }
179
+
180
+ export default {
181
+ setup() {
182
+ return () => h('input', { 'v-focus': true })
183
+ },
184
+ }
185
+ ```
186
+
187
+ **GOOD:**
188
+
189
+ ```javascript
190
+ import { h, withDirectives } from 'vue'
191
+
192
+ const vFocus = { mounted: (el) => el.focus() }
193
+
194
+ export default {
195
+ setup() {
196
+ return () => withDirectives(h('input'), [[vFocus]])
197
+ },
198
+ }
199
+ ```
200
+
201
+ ## Prefer functional components for stateless UI
202
+
203
+ **BAD:**
204
+
205
+ ```javascript
206
+ import { h } from 'vue'
207
+
208
+ export default {
209
+ setup() {
210
+ return () => h('span', { class: 'badge' }, 'New')
211
+ },
212
+ }
213
+ ```
214
+
215
+ **GOOD:**
216
+
217
+ ```javascript
218
+ import { h } from 'vue'
219
+
220
+ function Badge(props, { slots }) {
221
+ return h('span', { class: 'badge' }, slots.default?.())
222
+ }
223
+
224
+ Badge.props = ['variant']
225
+
226
+ export default Badge
227
+ ```