Skip to content

Commit

Permalink
feat(jsx-directive): support template-ref
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiyuanzmj committed Dec 2, 2023
1 parent c89ddce commit 6eda9fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions playground/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<script setup lang="ts">
import { shallowRef } from 'vue';
import Comp from './components/Comp.vue'
const list = [{ id: 1 }]
const bind = { }
const on = { submit: () => {} }
const select = $ref<{ id: number }>(list[0])
const compRef = shallowRef()
</script>

<template>
Expand All @@ -14,6 +16,7 @@ const select = $ref<{ id: number }>(list[0])
:key="i.id"
v-bind="bind"
v-model:id="i.id"
ref="compRef"
v-loading.fullscreen.lock="true"
v-memo="[select?.id === i.id]"
v-on="on"
Expand Down
20 changes: 20 additions & 0 deletions src/rules/jsx-directive/v-bind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@ fix: |-
---

id: v-template-ref
language: html
rule:
kind: quoted_attribute_value
pattern: $VALUE
follows:
kind: attribute_name
regex: ^ref$
stopBy: end
transform:
V:
substring:
startChar: 1
endChar: -1
source: $VALUE
fix: |-
{$V}
---

id: v-bind transform to {...props}
language: html
rule:
Expand Down

0 comments on commit 6eda9fa

Please sign in to comment.