diff --git a/package.json b/package.json index 096164e..a715b6f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@vue-macros/cli", "type": "module", - "version": "1.0.6", + "version": "1.0.7", "packageManager": "pnpm@8.10.5", "description": "Rewriting at vue macros powered by ast-grep.", "author": "zhiyuanzmj ", diff --git a/playground/src/App.vue b/playground/src/App.vue index 18eb10c..c0b4f05 100644 --- a/playground/src/App.vue +++ b/playground/src/App.vue @@ -25,7 +25,7 @@ const select = $ref<{ id: number }>(list[0])
{{ id }}
diff --git a/src/index.ts b/src/index.ts index 26afe61..3f46c61 100755 --- a/src/index.ts +++ b/src/index.ts @@ -9,7 +9,10 @@ function printHelp() { console.log(` Rewriting at Vue Macros using ast-grep. -${chalk.underline('Usage:')} vue-macros [directory] {(default current directory)} +${chalk.underline('Usage:')} vue-macros [directory] + +${chalk.underline('Directory:')} + default current directory ${chalk.underline('Commands:')} sg Rewrite code in specified directory diff --git a/src/rules/jsx-directive/v-text.yml b/src/rules/jsx-directive/v-text.yml index b983e63..5cf2896 100644 --- a/src/rules/jsx-directive/v-text.yml +++ b/src/rules/jsx-directive/v-text.yml @@ -1,12 +1,39 @@ id: v-text -language: tsx +language: html rule: - kind: jsx_expression - has: - kind: object - pattern: $A - not: - inside: - kind: jsx_attribute + kind: text + pattern: $A +transform: + B: + replace: + replace: \{\{ + by: '{' + source: $A + C: + replace: + replace: \}\} + by: '}' + source: $B fix: - $A + $C + +--- + +id: v-text to jsx comment +language: html +rule: + kind: comment + pattern: $A +transform: + B: + replace: + replace: + by: '*/}' + source: $B +fix: + $C diff --git a/src/rules/setup-sfc.yml b/src/rules/setup-sfc.yml index 00384db..62c86ef 100644 --- a/src/rules/setup-sfc.yml +++ b/src/rules/setup-sfc.yml @@ -24,6 +24,8 @@ language: html rule: kind: fragment pattern: $A + has: + kind: script_element fix: /*$A*/ --- diff --git a/src/utils/is-event.yml b/src/utils/is-event.yml index 9207b44..cce9851 100644 --- a/src/utils/is-event.yml +++ b/src/utils/is-event.yml @@ -9,7 +9,6 @@ rule: - kind: identifier - kind: function - kind: arrow_function - follows: - kind: property_identifier + inside: + kind: jsx_attribute regex: ^on[A-Z_] - stopBy: end