Subscribe on changes!

vue/compiler warning

avatar
Nov 6th 2023

Vue version

3.3.8

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-eplgin?file=src%2Fmain.ts

Please do a yarn serve

Steps to reproduce

Upgrade vue version to 3.3.8 and vue/compiler also to 3.3.8. execute yarn serve Use defineProps in a component with importing it. When you import it, you get below warning in compiler

yarn run v1.22.18
warning ../../../package.json: No license field
$ vue-cli-service serve --mode localhost
 INFO  Starting development server...
[51%] building (144/335 modules)
[@vue/compiler-sfc] `defineProps` is a compiler macro and no longer needs to be imported.

If you remove the import of defineProps, then you get below error

8:1 error 'defineProps' is not defined

What is expected?

Warning to be match with the code. Either able to use defineProps with import or remove it stops seeing warning asking to import

What is actually happening?

Warning asking to remove import of deinineProps and once it's removed, it's throwing the error asking to import it

System Info

No response

Any additional comments?

No response

avatar
Nov 6th 2023

8:1 error 'defineProps' is not defined

This is from ESLint and an old version of eslint-plugin-vue. Now that you are using @vue/cli-plugin-eslint, which only supports eslint-plugin-vue v8, you need to add the following configuration in your package.json:

  "eslintConfig": {
    "root": true,
    "env": {
      "node": true,
+     "vue/setup-compiler-macros": true
    },

https://github.com/vuejs/eslint-plugin-vue/blob/v8.7.1/docs/user-guide/README.md#compiler-macros-such-as-defineprops-and-defineemits-generate-no-undef-warnings