question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

eslint error "The template root requires exactly one element" on latest Vite+eslint+eslint-plugin-vue(alpha)

See original GitHub issue

Do 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.9and 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 (from yarn.lock or package-lock.json): 3.0.4
    • Installed @vue/compiler-sfc version: 3.0.4

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:20

github_iconTop GitHub Comments

3reactions
TheDutchCodercommented, Dec 21, 2020

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:

npm install --dev eslint eslint-plugin-vue

Then add a .eslintrc.js file in the root with the following settings:

module.exports = {
  root: true,
  env: {
    node: true,
  },
  extends: [
    'plugin:vue/vue3-recommended',
    'eslint:recommended',
  ],
  plugins: ['vue'],
}
1reaction
LinusBorgcommented, Dec 22, 2020

The mistake in your original .eslintrc config is that you extend plugin:vue/recommended instead of plugin:vue/vue3-recommended.

https://eslint.vuejs.org/user-guide/#usage

I don’t think there’s anything missing in docs.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found