vue eslint configuration specification

vue eslint configuration specification

JavaScript Style Guide

In order to unify the code format, to avoid low-level errors or unreasonable, is forced to use eslintthe standardspecifications

Project Configuration

It is currently provided by the use of scaffolding vue development, though vue-cli 3.0, but the company because the configuration of OAuth sake, or only temporary use vue-cli 2.0,
and thus the current configuration will be described in conjunction with two versions

purpose

Can be prompted by the editor (vscode) can be repaired at the same time, so it is the best

vue-cli 2.0

  • Select New Project standardformat
    standard

  • Test eslint (pick a place to play a few spaces)
    standard

  • When saving can automatically fix (or repair when formatting codes)

    Since the veturformat used is prettierthe way, not what we want standard, currently two modes of operation
    vscode

    • Scenario 1 : If able to prettierread what we want, this is the best
    • Scenario 2 : do not change prettier, but when you save then in accordance with standardthe form of preservation does not depend on the

    For the above description, it is currently using a second scheme (not the first way to find a solution)

    • Use 方案2, the operation flow
      • Install plug ESLint
      • vscode setting.jsonadd configuration

          // 开启
          "eslint.enable": true,
          // 保存
          "eslint.autoFixOnSave": true,
          "eslint.run": "onType",
          "eslint.options": {
              "extensions": [".js",".vue"]
          },
          "eslint.validate": [
              // 此处保存时,自动修复
              { "language": "vue", "autoFix": true },
              "javascript",
              "html",
              "vue-html"
          ]
      • effect

      vscode

vue-cli 3.0The same operation (not described in the first subtle differences)

eslint brief description

eslint There are two large branches

airbnb more stringent standard than the rules require, and this is the reason why the choice of standard, because the rules are not a hundred percent in line with each company, which will be on this basis, a private custom eslint-config-vue specific rules described see eslint official website

Close to a particular eslint check users

to sum up

  • If it can be repaired in time code formatting, this is the best
  • How to customize their own rules, some of this hard (difficult to reach)
  • Follow then add it (or some scattered between points)

Guess you like

Origin www.cnblogs.com/sinosaurus/p/11275671.html