[英]How do I run prettier on a specific subdirectory on my project?
I have a typescript project structure something like this:我有一个 typescript 项目结构是这样的:
--workflows
|--app1
|--src
|--app2
|--src
I am trying to run prettier, but I only want to run on app1.我正在尝试运行更漂亮,但我只想在 app1 上运行。
I tried something like this:我试过这样的事情:
prettier --write \"workflows/app1/**/*.{js, ts}\"
This doesn't return any files.这不会返回任何文件。
But if I run something like this:但是如果我运行这样的东西:
prettier --write \"workflows/**/*.{js, ts}\"
It returns all files under workflows directory.它返回工作流目录下的所有文件。
What am I doing wrong?我究竟做错了什么? How can I get it to run only for files under app1?
我怎样才能让它只为 app1 下的文件运行?
According to the docs you can use a .prettierignore
file in the root of your project: https://prettier.io/docs/en/ignore.html根据文档,您可以在项目的根目录中使用
.prettierignore
文件: https://prettier.io/docs/en/ignore.html
Simply create a file called.prettierignore and type the directories you want to exclude in your case:只需创建一个名为 .prettierignore 的文件,然后键入要在您的情况下排除的目录:
app2
You can also use the --ignore-path
option in the CLI您还可以在 CLI 中使用
--ignore-path
选项
It worked without using quotes它在不使用引号的情况下工作
prettier --write workflows/app1/**/*.{js, ts}
Json looks like this: Json 看起来像这样:
"scripts": {
"review": "prettier --write workflows/app1/**/*.{js,ts}"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.