Because the project in the company usually contains front-end code and Node code, divided into two folders, but they are the same Git project, it takes a lot of time to configure Prettier and ESLint, there is a little confusion about loading priority, some experience was gained from several experiments.
Suppose the open directory structure is:
|-a
|- package.json
|-b
|- package.json
|- package.json
Copy the code
- Vscode’s prettier plug-in always looks for the outermost directory where prettier exists
node_modules/prettier/index.js
If the outermost layer is not present, the VSCode output panel will report an error (but does not affect the VScode formatting function) :
- The esLint plugin will look at where the file is currently open and look for
node_modules/eslint/lib/api.js
If there is no directory at the same level, search the directory at the next level. If there is no directory at the same level, no error will be reported and no verification will be played. Its configuration file.eslintrc.js
The same goes for configuration files andnode_modules/eslint/lib/api.js
Can not be the same directory, if the configuration file is not writtenroot: true,
It also goes up, configuration functions merge.
In addition, if commit verification is configured (either for the inner package.json or outer layer), the prettier/eslint command is the same as the prettier/eslint command in the Git directory.
If there are mistakes, welcome criticism and correction!