首页 > 解决方案 > 更漂亮的不清理项目根目录中的文件

问题描述

我正在使用 Prettier 来清理我的打字稿。在我的 package.json 中,我有以下脚本:

"scripts": {
  "pretty": "prettier --write server/src/**/*.ts"
}

我的.prettierignore文件:

.DS_Store
node_modules/
lib/
static/
*.config.js

我的项目中有这些文件:

server:
  package.json
  tsconfig.json
  lib/
  src/
    scripts/
      Mine.ts
    Block.ts
    Chain.ts
    ...

出于某种原因,prettier 只涉及server/src/scripts/Mine.ts. 如果我删除该目录,那么 中只有文件server/src,它会触及每个文件。但是一旦有子目录,src目录中的文件就会被忽略。这也发生在我的 webui 项目中。

如果我尝试prettier --write server/src/*.ts,它不会递归不同的目录,但它会触及server/src.

它说 prettier 使用 fast-glob。fast-glob 文档有这个例子:

src/**/*.js — matches all files in the src directory (any level of nesting) that have the .js extension.

我究竟做错了什么?

标签: prettier

解决方案


推荐阅读