DEV Community

Mikhail Karan
Mikhail Karan

Posted on

4 2

Setting up ESLint for Vue 3 in VSCode

Make sure eslint is installed and updated for your project

npm install --save-dev eslint eslint-plugin-vue
Enter fullscreen mode Exit fullscreen mode

Create a .eslintrc.js file in your projects root directory:

module.exports = {
  extends: [
    // add more generic rulesets here, such as:
    // 'eslint:recommended',
    'plugin:vue/vue3-recommended',
    // 'plugin:vue/vue3-essential', // This option doesn't impose formatting rules
    // 'plugin:vue/vue3-strongly-recommended', // This option imposes formatting rules on your code to improve readability 
  ],
  rules: {
    // override/add rules settings here, such as:
    // 'vue/no-unused-vars': 'error'
  }
}
Enter fullscreen mode Exit fullscreen mode

Disable vetur in VSCodes settings (if you had it installed)

I'd personally recommend only disabling it on the project level using the workspace settings tab. Mainly because if you still have some vue 2 projects you want vetur to continue to lint them.

"vetur.validation.style": false
Enter fullscreen mode Exit fullscreen mode

vetur doesn't yet support vue 3 fully so it can conflict with some of the new features. If you add a <Teleport> ... </Teleport> to a component, you'll see a huge red wall because vue 2 didn't support multiple root elements in a component, while vue 3 does.

HTML All The Things

While you're here, check out the HTML All The Things Podcast that I co-host. We talk about Web Development, Freelancing, Small Business and Productivity.

Resources

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

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (2)

Collapse
 
glittle profile image
Glen Little

Thanks!
For the "vetur.validation.style": false sample, can you show/explain exactly where that should be put?

Collapse
 
tobiasb profile image
Tobias Brandstädter

I'm not sure about how relevant this still is, but in VS Code there is a function called Workspace Settings. You can view them as JSON by searching for "Workspace Settings (JSON)" in your command palette.

code.visualstudio.com/docs/getstar...

Jetbrains image

Build Secure, Ship Fast

Discover best practices to secure CI/CD without slowing down your pipeline.

Read more

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay