Eslint first experience

Time:2021-10-25
start
//Install eslint
//Local installation
npm i --save-dev eslint
//Or global installation
npm i -g eslint
use
eslint --init

After that, several options will appear. You can know what they mean by looking at the options. Here, focus on the first and second options

  • Popular configuration

The first option is to select some popular specifications, hereStandardFor example, enter y or n according to your needs after entering

Configuration file selectedjsThe file format is as follows:

Configuration rules – English Configuration specification – Chinese

  • Custom configuration

According to your needs, enter Y / N as follows

The obtained configuration file is as follows:

After that, you can continue to add your own specifications. For details, please seeEslint official website

Experience

It’s good to use some popular rules directly. You don’t need to configure them yourself. In the future, team cooperation is also very convenient, and most of the editors will have plug-ins to support these popular rules.

demo

This work adoptsCC agreement, reprint must indicate the author and the link to this article