prettier
差别
这里会显示出您选择的修订版和当前版本之间的差别。
| 两侧同时换到之前的修订记录前一修订版后一修订版 | 前一修订版 | ||
| prettier [2021/07/22 13:35] – admin | prettier [2021/11/08 18:02] (当前版本) – admin | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| ====== Prettier ====== | ====== Prettier ====== | ||
| + | * https:// | ||
| - | **安装** | + | ===== 安装 |
| <code bash> | <code bash> | ||
| - | yarn add --dev --exact prettier | + | npm install |
| </ | </ | ||
| - | **配置** | + | ===== 配置 |
| - | <code bash> | + | |
| - | echo {}> | + | |
| - | </ | + | |
| - | < | + | < |
| - | # 单行代码的最大宽度 | + | module.exports = { |
| - | printWidth: 80 | + | // https:// |
| - | # 使用制表符 (tab) 缩进行而不是空格 (space) | + | |
| - | useTabs: false | + | |
| - | # 指定每个缩进级别的空格数 | + | |
| - | tabWidth: 2 | + | |
| - | # 在语句末尾打印分号 | + | overrides: |
| - | semi: true | + | { |
| - | # 使用单引号而不是双引号 | + | files: |
| - | singleQuote: false | + | options: |
| - | # 换行格式 | + | printWidth: |
| - | endOfLine: lf | + | |
| - | + | | |
| - | overrides: | + | ], |
| - | | + | }; |
| - | options: | + | |
| - | printWidth: 150 | + | |
| - | tabWidth: 2 | + | |
| - | - files: | + | |
| - | options: | + | |
| - | printWidth: | + | |
| - | | + | |
| - | - files: " | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| </ | </ | ||
| - | <file .prettierignore> | + | ===== Ignoring Code ===== |
| + | * https:// | ||
| + | |||
| + | < | ||
| # Ignore artifacts: | # Ignore artifacts: | ||
| build | build | ||
| coverage | coverage | ||
| - | |||
| - | # Ignore all HTML files: | ||
| - | *.html | ||
| </ | </ | ||
| - | **使用** | + | ===== 使用 |
| <code bash> | <code bash> | ||
| - | yarn prettier --write . | + | npx prettier --write |
| </ | </ | ||
| + | |||
| + | ===== Pre-commit Hook ===== | ||
| + | * https:// | ||
| + | |||
| + | <code bash> | ||
| + | npx mrm@2 lint-staged | ||
| + | </ | ||
| + | |||
prettier.1626932152.txt.gz · 最后更改: 2021/07/22 13:35 由 admin
