eslint error "The template root requires exactly one element" on latest Vite+eslint+eslint-plugin-vue(alpha)
See original GitHub issueDo NOT ignore this template or your issue will have a very high chance to be closed without comment.
Describe the bug
New Vite install, with eslint and “eslint-plugin-vue”: “^7.0.0-alpha.9”, results in errors about multiple template roots. It’s the same as this one: https://github.com/vitejs/vite/issues/549 but I just experienced it with the latest version (with or without Vetur).
Reproduction
It’s just a clean Vite install (never used Vite before), with locally added eslint
and eslint-plugin-vue@7.0.0-alpha.9
and an eslint file that extends 'plugin:vue/vue3-essential'
and 'plugin:vue/recommended'
.
System Info
- required
vite
version: 1.0.0-rc.13 - required Operating System: Mac OS Catalina (10.15.7)
- required Node version: 12.14.1
- Optional:
- npm/yarn version: 6.14.8
- Installed
vue
version (fromyarn.lock
orpackage-lock.json
): 3.0.4 - Installed
@vue/compiler-sfc
version: 3.0.4
Issue Analytics
- State:
- Created 3 years ago
- Comments:20
Top Results From Across the Web
Vue 3 The template root requires exactly one element. eslint ...
I ended up turning off Vetur linting. Vetur thinks that it is a Vue 2 project becuase it is in a VS Code...
Read more >Vue 3 The template root requires exactly one ... - Laracasts
After scaffolding a Vue 3 project I noticed an error in my App.vue. A functional component that renders the matched component for the...
Read more >Vue 3 The template root requires exactly one element.eslint ...
https://stackoverflow.com/questions/64867504/vue-3-the-template-root-requires-exactly-one-element-eslint-plugin-vue.
Read more >Component template should contain exactly one root element.
How to Create Tailwind CSS Responsive Sidebar with Vue js 3 · ESLint with Prettier and Vue in VS Code · C# user...
Read more >VueJS Component template should contain exactly one root ...
If you are using v-if on multiple elements, use v-else-if to chain them instead. As explained, VueJS component templates can contain one and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok I finally got it to work. I would suggest adding something to the docs for this:
First install eslint and eslint-plugin-vue locally:
Then add a .eslintrc.js file in the root with the following settings:
The mistake in your original
.eslintrc
config is that you extendplugin:vue/recommended
instead ofplugin:vue/vue3-recommended
.https://eslint.vuejs.org/user-guide/#usage
I don’t think there’s anything missing in docs.