Problems encountered:

  1. Why a formatted configuration of the project when vscode is opened, large red?

  2. Why does saving automatic formatting conflict?

  3. What is the relationship between the formatting plug-in installed in vscode and the dependency packages in package.json when using vscode?

  4. What is the difference between a formatted configuration file and vscode settings.json?

    If there are eslintrc and prettierrc configuration files in the root directory of your project, the vscode plugin automatically reads the configuration files and examines your code and formatting files. NPM is installed on the command line. If you have a formatting plugin installed, it detects the formatting in your configuration file and flags you in red. You can disable the plugin and the red flag will disappear. Note that the IDE may not respond so quickly. If you only install the NPM package, vscode will not be prompted by lint, you can only use the command line to see the terminal that does not conform to lint rules. The main reason for installing the NPM package is that you can use git hooks to enforce lint and formatting before committing code to keep your repository code consistent.

Now that we understand the difference, point 2 is that when we save, the code is formatted, which is what the IDE makes easy for us to develop

Some configuration in this screenshot below the waves of the yellow line, it is because I lost the relevant plug-ins, disable the lower-left corner red circle part, this is also the key to lead to conflict, because eslint and prettier formatting had cross sections, the most obvious is the single and double quotes, press the save button to see the code changes alternating single and double quotes, Then you can disable the plug-in, “editor. FormatOnSave: false” or comment out.

Finally, we usually develop formatting related points, because we are doing ali related projects, they have their own code specification web.npm.alibaba-inc.com/package/esl…

Most of our projects have this package installed, so we don’t need to configure the format specifications ourselves, just inherit them