Setup ESLINT and PRETTIER in Vue3 - JavaScript Version

markliu2013

Mark

Posted on May 3, 2024

Setup ESLINT and PRETTIER in Vue3 - JavaScript Version

This article is base on
https://dev.to/markliu2013/how-to-create-a-vue3-application-with-webpack-javascript-version-2d93

We want to add eslint and prettier for the project.

Install Eslint and Prettier


npm i -D eslint prettier eslint-config-prettier eslint-plugin-prettier
npm i -D eslint-plugin-vue

Enter fullscreen mode Exit fullscreen mode

Create .eslintrc.js

module.exports = {
  env: {
    browser: true,
    es2021: true
  },
  extends: [
    'eslint:recommended',
    'prettier',
    'plugin:prettier/recommended',
    'plugin:vue/vue3-recommended'
  ],
};


Enter fullscreen mode Exit fullscreen mode

Create .prettierrc.json

{
  "semi": true,
  "tabWidth": 2,
  "printWidth": 100,
  "singleQuote": true,
  "trailingComma": "none"
}
Enter fullscreen mode Exit fullscreen mode

Run Eslint and Prettier

"lint": "eslint ./src --ext .js,.vue",
"lint:fix": "eslint ./src --ext .js,.vue --fix",
"format": "prettier 'src/**/*.{js,vue,css,md,json}' --write"
Enter fullscreen mode Exit fullscreen mode
πŸ’– πŸ’ͺ πŸ™… 🚩
markliu2013
Mark

Posted on May 3, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related