Skip to content
Search

Vue:ProjectTemplate:Vue2 Babel ESLint

lastmod 2020-09-28created 2020-09-283 edits

A template for installing vue2+babel+eslint with vue-cli.

Command

$ vue create .
? Please pick a preset: Manually select features
? Check the features needed for your project: Choose Vue version, Babel, Linter
? Choose a version of Vue.js that you want to start the project with 2.x
? Pick a linter / formatter config: Prettier
? Pick additional lint features: Lint on save
? Where do you prefer placing config for Babel, ESLint, etc.? In package.json
? Save this as a preset for future projects? No

Prettier was chosen as the formatting option for ESLint.

package.json file

{
  "name": "t3",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.6.5",
    "vue": "^2.6.11"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/eslint-config-prettier": "^6.0.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^6.7.2",
    "eslint-plugin-prettier": "^3.1.3",
    "eslint-plugin-vue": "^6.2.2",
    "prettier": "^1.19.1",
    "vue-template-compiler": "^2.6.11"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended",
      "@vue/prettier"
    ],
    "parserOptions": {
      "parser": "babel-eslint"
    },
    "rules": {}
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead"
  ]
}

Compared with the vue2+babel template project, the following were added.

  • devDependencies:
    • @vue/cli-plugin-eslint
    • @vue/eslint-config-prettier
    • babel-eslint
    • eslint
    • eslint-plugin-prettier
    • eslint-plugin-vue
    • prettier
  • eslintConfig.extends
    • plugin:vue/essential
    • eslint:recommended
    • @vue/prettier

ETC files

The remaining files and their contents are the same as in the Only vue2 template and vue2+babel template pages.

See also

author Zer0 sitemap