Why use them?

Validation of ESLint code

Js as a flexible weak type language, code style is strange, 1000 people write JS there are 1000 kinds of writing. While there is no officially recommended code specification for JS, there are some popular ones in the community, such as StandardJS and Airbnb. Using ESLint in conjunction with these specifications can detect potential problems in code and improve code quality, but does not completely unify the code style

Prettier Formatting code

Prettier is a tool for completely unifying your code style with your colleagues. Prettier as the name implies, Prettier code, Prettier code, makes it easier to read.

However, in the process of using them, we found that there are direct conflicts. The code that originally conforms to THE ESlint specification can not be automatically formatted after saving, which is very uncomfortable. Cooperate well but quarrel, can only say lack lubricant 🙂

Eslint-config-prettier

Prettier eslint-config-prettier eslint-config-prettier eslint-config-prettier

Installation

Tip: First, you might be interested in installing [eslint-plugin-prettier]. Follow the instructions over there. This is optional, though.

Install eslint-config-prettier:

npm install --save-dev eslint-config-prettier
Copy the code

Then, add eslint-config-prettier to the “extends” array in your .eslintrc.* file. Make sure to put it last, so it gets the chance to override other configs.

{
  "extends": [
    "some-other-config-you-use"."prettier"]}Copy the code