Skip to content

Commit

Permalink
feat(sg): convert dot to underline
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiyuanzmj committed Dec 23, 2023
1 parent 9b94f36 commit 028e4af
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ export default antfu(
'yaml/indent': 'off',
},
},
ignores: ['**/playground/**'],
},
)
2 changes: 2 additions & 0 deletions playground/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const compRef = shallowRef()
v-loading.fullscreen.lock="true"
v-memo="[select?.id === i.id]"
v-on="on"
v-on:click="alert"
@sub-mit.prevent
@click.once="select = i"
@submit="alert"
@update:model-value="select.id = $event"
Expand Down
1 change: 1 addition & 0 deletions src/sg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export async function sg(target: string) {

if (['setup-sfc', 'define-render', 'export-render'].includes(macro)) {
await $`${sg} scan -c ${config}.yml -U --filter '^self-closing-tag' ${target}`
await $`${sg} scan -c ${config}.yml -U --filter '^dot-to-underline' ${target}`
await $`${sg} scan -c ${config}.yml -U --filter '^v-' ${target}`
await $`${sg} scan -c ${config}.yml -U --filter '^${macro === 'setup-sfc' ? 'export-render' : macro}' ${target}`
await useTsx(async () => {
Expand Down
26 changes: 17 additions & 9 deletions src/sg/rules/jsx-directive/v-directive.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
id: v-directive
language: html
rule:
kind: attribute
kind: quoted_attribute_value
has:
kind: attribute_value
pattern: $V
follows:
kind: attribute_name
pattern: $NAME
regex: ^v-
precedes:
kind: quoted_attribute_value
has:
kind: attribute_value
pattern: $V
stopBy: end
regex: ^v-|@
stopBy: end
fix: |-
{$V}
---

id: dot-to-underline
language: html
rule:
kind: attribute_name
pattern: $NAME
transform:
K:
replace:
replace: \.
by: _
source: $NAME
fix: |-
$K={$V}
$K

0 comments on commit 028e4af

Please sign in to comment.