1.1.5 â€ĸ Published 1 year ago

generate-vue-emits v1.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

generate-vue-emits

A cli tool to generate emits options from Vue files.

The tool analizes all emit calls in script tags of Vue SFC files and creates emits option from them, then inserts it into the original files. It supports both composition and options API.

īŧŠ It cannot detect emit calls in template tags.

🚀 Usage

$ npx generate-vue-emits generate -- ./src/**/*.vue

Here is an example output:

export default {
  name: 'UserList',
  components: {},
+    emits: { input: null, click: null },
  methods: {
    onClick() {
      this.$emit('click')
    }
    onInput(value: string) {
      this.$emit('input', value)
    }
  }
}

īŧŠ Note that the tool does not format the output itself. It is strongly recommended that you use it with some formatter.

If -t option is set, typed validation functions are inserted instead of null.

$ npx auto-insert-emits generate -t -- ./src/**/*.vue
export default {
  name: 'UserList',
  components: {},
+    emits: { input: (payload: string) => payload, click: () => true },
.
.
.
}

You can also specify the position where emits option should be inserted by -p option (By default it would be inserted as the third item of the options).

$ npx auto-insert-emits generate -p 0 ./src/**/*.vue # inserted on the top.

📄 License

MIT.

🙏 Special Thanks

This repository uses kawamataryo's wounderful suppress-ts-errors repository as a boilerplate.

1.1.5

1 year ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago