[英]How to base .prettierignore file on .gitignore
Looking at the Prettier docs, there is a tip to base your.prettierignore file on your.gitignore file.查看 Prettier 文档,有一个将 your.prettierignore 文件基于 your.gitignore 文件的提示。
https://prettier.io/docs/en/install.html https://prettier.io/docs/en/install.html
Tip. Base your.prettierignore on.gitignore and.eslintignore (if you have one).
Can someone explain what this means and how to do this?有人可以解释这意味着什么以及如何做到这一点吗? Is there a way to automatically add everything to your.prettierignore included in your.gitignore?
有没有办法自动将所有内容添加到 your.gitignore 中包含的 your.prettierignore?
You can actually pass a flag to your prettier command --ignore-path
and then give it the path of your .gitignore
file so it will use that instead of the .prettierignore
file.您实际上可以将一个标志传递给您的更漂亮的命令
--ignore-path
,然后给它您的.gitignore
文件的路径,这样它将使用它而不是.prettierignore
文件。
prettier --ignore-path .gitignore
They're not implying there's an automatic way to do this, but you could cp.gitignore.prettierignore
(or copy it some other way, such as in your IDE).他们并不是暗示有一种自动的方法可以做到这一点,但是您可以
cp.gitignore.prettierignore
(或以其他方式复制它,例如在您的 IDE 中)。 There is a proposal to include other ignore files as well as a node tool to automate this for you if you want to, though.但是,如果您愿意,有一个建议包括其他忽略文件以及一个节点工具来为您自动执行此操作。
From what I can tell from reading the docs is they mean to have the same files in your .prettierignore
as you do in your .gitignore
, since anything in .gitignore
won't be check into your repository anyway, not that you can point the .prettierignore
to .gitignore
and have it use that file, though that would be cool.从阅读文档中我可以看出,它们意味着您的
.prettierignore
中的文件与您在.gitignore
中的文件相同,因为.gitignore
中的任何内容都不会被检入您的存储库,而不是您可以指出.prettierignore
到.gitignore
并让它使用该文件,尽管那会很酷。 There's a similar issue raised and close here that mentions using symlink since they use the same structure.这里提出并关闭了一个类似的问题,提到使用符号链接,因为它们使用相同的结构。
Don't copy the file, link it to your.gitignore so they keep in sync if you edit them in the future:不要复制文件,将其链接到 your.gitignore 以便在您将来编辑它们时保持同步:
ln -s .gitignore .prettierignore
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.