Skip to content

忽略文件

🌐 Ignore files

Oxfmt 提供了几种方法来排除文件格式化。

🌐 Oxfmt provides several ways to exclude files from formatting.

ignorePatterns

推荐的忽略文件方法。添加到 .oxfmtrc.json

🌐 The recommended way to ignore files. Add to .oxfmtrc.json:

.oxfmtrc.json
json
{
  "ignorePatterns": ["dist/**", "*.min.js"]
}
  • 使用 .gitignore 语法
  • 路径是相对于包含 Oxfmt 配置文件的目录来解析的
  • 特定于格式化器且独立于 Git

匹配“ignorePatterns”的文件无法格式化,即使明确指定。

🌐 Files matching ignorePatterns cannot be formatted, even if explicitly specified.

.gitignore

Oxfmt 会尊重当前目录树中的 .gitignore 文件。

🌐 Oxfmt respects .gitignore files in the current directory tree.

  • 全局 gitignore 和父 '.gitignore' 文件不会被读取
  • 不需要 .git 目录

.gitignore 忽略的文件仍然可以被格式化,如果明确指定的话。

🌐 Files ignored by .gitignore can still be formatted if explicitly specified.

VCS 目录和 node_modules

🌐 VCS directories and node_modules

默认被忽略:.git.svn.jjnode_modules

🌐 Ignored by default: .git, .svn, .jj, node_modules

使用 --with-node-modules 来包含 node_modules

🌐 Use --with-node-modules to include node_modules.

锁文件

🌐 Lock files

package-lock.jsonpnpm-lock.yaml 等总是会被忽略。

.prettierignore

支持 Prettier 兼容性。使用 .gitignore 语法。

🌐 Supported for Prettier compatibility. Uses .gitignore syntax.

.prettierignore 中的文件无法格式化,即使已明确指定也不行。

🌐 Files in .prettierignore cannot be formatted, even when explicitly specified.

对于新项目,建议使用 ignorePatterns

🌐 For new projects, prefer ignorePatterns.