Prettier
提供了 3
种方式来配置忽略文件。分别是:
Command Line
命令行Comments
注释.prettierignore
文件
Command Line
在命令行中,可以利用否定模式来结合fast-glob忽略特定文件:
shell
prettier . "!**/*.{js,jsx,vue}" --write
Comments
在项目代码中,可以利用prettier-ignore注释来忽略下一行的节点格式化。
譬如:
js
// prettier-ignore
const text = 'Hello world';
也可以利用 prettier-ignore-start
与 prettier-ignore-end
来忽略文件中的某一范围区域格式化。
Ignoring Files
但在实际开发中,我们更推荐使用 .prettierignore
文件来忽略特定文件。
譬如:
yaml
**/*.min.js
**/*.min.css
**/*.md
package.json
package-lock.json
yarn.lock
pnpm-lock.yaml