How to format the entire project according to eslint

One: Review of the past


I have shared how to set eslint and Prettier to format the project before, but such formatting is only triggered when the file is modified, and the automatic formatting code is triggered.

So, here comes the question, the code that has been formed for a long time, do we have to click and open the files one by one, and then press a space to save it?

That's just so inelegant.

Two: format by folder


Why do I say format by folder? Because, like the node project, there is a dependent folder node_modules folder, this folder is not uploaded to the git warehouse, and does not need to be formatted.
Then we only need to right-click on other folders, select Reformat Code, and if necessary, check Include subdirectories (including subdirectories), then click Run and wait for a while, let the editor run for a while, and you will get the completed
format customized projects.

image.png
image.png

Three: Conclusion


Some people say that if you do this, git is all your submissions, but think about it in reverse, the code formatting of the entire project is implemented in the team, and then, all use the same set of formatting specifications, we can avoid different Human code conflicts caused by formatting. Clearly, the pros outweigh the cons. Why not do it!

How to add eslint and Prettier to the project: https://www.yuque.com/morange/morange/gn4wgi

message

Taking the first step is half the battle.

Guess you like

Origin blog.csdn.net/Long861774/article/details/126637635