简体   繁体   中英

Prettier format all subfolders

Im trying to use the https://github.com/trivago/prettier-plugin-sort-imports lib which on the root diercotry but not in my subdirectories.

This is my project structure:

---TheAPP
  | subfolder1
     package.json
  | subfolder2
     package.json
package.json

The library works on the root but not the subfolders. This is added to my package.json in the root:

scripts: {"prettier": "prettier --write \"**/*.{js,ts,tsx}\""},

How do i target the subfolder? Is the problem that each subfolder has its own package.json so i need to install the library to each subfolders package.json?

I guess this answers your question..... definitely, you will have to install the library to each subfolder.

How does import sort work? The plugin extracts the imports which are defined in importOrder. These imports are considered as local imports. The imports which are not part of the importOrder is considered as third party imports. https://github.com/trivago/prettier-plugin-sort-imports

The path is not right, you should go in subfolder ./**/*.{js,ts,tsx}

Try this command:


"prettier": "prettier --write \"/**/*.{js,ts,tsx}\"",

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM