vue front-end HbuliderEslint real-time verification automatic repair settings

vue front-end HbuliderEslint real-time verification automatic repair settings

Whether it is a multi-person collaboration or a personal project, code standards are very important. Doing so can not only avoid basic syntax errors to a great extent, ESLint is a grammar rule and code style checking tool that can be used to ensure that grammatically correct and uniformly styled code is written.

ESLint plugin installation in HBuilderX

HBuilderX includes 4 syntax checking plug-ins: htmlhint, stylelint, eslint-plugin-vue, eslint-js. Click Tools -> Plugin Installation, the interface is as follows:

insert image description here

Click Plugin Market to enter the Plugin Market and enter eslint to search.

insert image description here

Click eslint, go to the details page, and click Install Plugin. Note: hbulider version must be 2.6.8 or above

insert image description here

After installing eslint-vue and eslint-js. Click on the menu settings and check Save automatic repairs

insert image description here

Custom eslint-js rules

Click on the above picture "Open file .eslintrc.js for configuration", and open the file code as follows:

  module.exports = {  
      "plugins": [  
          "html"  
      ],  
      "parser": "esprima",  
      "parserOptions": {  
          "ecmaVersion": 2018,  
          "sourceType": "module",  
          "ecmaFeatures": {  
              "jsx": true  
          },  
          "allowImportExportEverywhere": false  
      },  
      "rules": {                                  
          "camelcase": 2, //Force camel case naming,  
          "indent": [2, 4], // indentation style "id-match": 0, // name detection "init-declarations": 1, // must be assigned an initial value when declaring "no-undef": 1, // can not have undefined variables "no-multi-spaces": "error", // prohibit multiple spaces "semi": [2, "always"] ,// automatic addition of semicolons "quotes": ["error", "single"] // use single quotes }  
  };  

Detailed rules reference: eslint common configuration restarts Hbulider and automatically fixes code inconsistencies in JS code each time it is saved.

Precautions

The above settings for using the Hbulider code automatic repair function are only applicable to Hbulider versions above 2.6.8.
References: HBuilderX syntax check, eslint real-time check automatic repair function description

The above is the detailed content of the real-time verification and automatic repair settings of HbuliderEslint on the vue front end. For more information about HbuliderEslint real-time verification and automatic repair, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • VUEJS practice: fixing errors and beautifying time (2)
  • Vue project turns off eslint verification
  • vue+ESLint configuration save automatically format code
  • Complete steps for configuring eslint code specifications for vue-cli3 projects

<<:  HTML markup language - form

>>:  Detailed analysis of the syntax of Mysql update to modify multiple fields and

Recommend

Detailed steps for deploying Microsoft Sql Server with Docker

Table of contents 1 Background 2 Create a contain...

Native js realizes the drag and drop of the nine-square grid

Use native JS to write a nine-square grid to achi...

JavaScript mobile H5 image generation solution explanation

Now there are many WeChat public account operatio...

How to use http and WebSocket in CocosCreator

Table of contents 1. HttpGET 2. HTTP POST WebSock...

Next.js Getting Started Tutorial

Table of contents Introduction Create a Next.js p...

MySQL triggers: creating and using triggers

This article uses examples to describe the creati...

How to install and persist the postgresql database in docker

Skip the Docker installation steps 1. Pull the po...

Windows 10 is too difficult to use. How to customize your Ubuntu?

Author | Editor Awen | Produced by Tu Min | CSDN ...

A detailed introduction to JavaScript primitive values ​​and wrapper objects

Table of contents Preface text Primitive types Pr...

Element dynamic routing breadcrumbs implementation example

To master: localStorage, component encapsulation ...

Pure CSS to achieve click to expand and read the full text function

Note When developing an article display list inte...

Complete steps to use mock.js in Vue project

Using mock.js in Vue project Development tool sel...

Website design should pay attention to the sense of color hierarchy

Recently I have been saying that design needs to h...

Vue parent component calls child component function implementation

Vue parent component calls the function of the ch...