0.0.18 • Published 11 months ago

@wattanx/insert-emits-option v0.0.18

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Insert Emits Option

Get the event name from the emit used in script or template and add it to the emits option as an array.

In Vue3, it is recommended to set the emits option.

This tool is a tool to assist in the migration of the emits option.

This tool supports the options api and composition api.

Usage

npx @wattanx/insert-emits-option <files...>

Path to the target vue file, which can be set with the glob pattern. eg: src/**/*.vue

options

optiondefaultdescription
-t, --tsconfig-path./tsconfig.jsonPath to tsconfig.json.

Example

before:

// HelloWorld.vue
<template>
  <div>
    <button @click="$emit('save', $event)">SAVE</button>
    <button @click="$emit('cancel')">CANCEl</button>
  </div>
</template>
<script lang="ts">
import { defineComponent, toRefs, computed, ref } from "vue";

export default defineComponent({
  name: "HelloWorld",
  setup(_, { emit }) {
    const onChange = () => {
      emit("change", 124);
    };

    return {
      onChange,
    };
  },
});
</script>

after:

// HelloWorld.vue
<template>
  <div>
    <button @click="$emit('save', $event)">SAVE</button>
    <button @click="$emit('cancel')">CANCEl</button>
  </div>
</template>
<script lang="ts">
import { defineComponent, toRefs, computed, ref } from "vue";

export default defineComponent({
  name: "HelloWorld",
  setup(_, { emit }) {
    const onChange = () => {
      emit("change", 124);
    };

    return {
      onChange,
    };
  },
+  emits: ["change",'save','cancel']
});

⚠️ It is always added to the end of the option without being formatted.

0.0.18

11 months ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago