prettier
差别
这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录前一修订版后一修订版 | 前一修订版上一修订版两侧同时换到之后的修订记录 | ||
prettier [2021/07/22 13:35] – admin | prettier [2021/11/08 17:59] – admin | ||
---|---|---|---|
行 1: | 行 1: | ||
====== Prettier ====== | ====== Prettier ====== | ||
+ | * https:// | ||
- | **安装** | + | ===== 安装 |
<code bash> | <code bash> | ||
- | yarn add --dev --exact prettier | + | npm install |
</ | </ | ||
- | **配置** | + | ===== 配置 |
- | <code bash> | + | |
- | echo {}> | + | |
- | </ | + | |
- | < | + | < |
- | # 单行代码的最大宽度 | + | module.exports = { |
- | printWidth: 80 | + | |
- | # 使用制表符 (tab) 缩进行而不是空格 (space) | + | |
- | useTabs: false | + | |
- | # 指定每个缩进级别的空格数 | + | |
- | tabWidth: 2 | + | overrides: |
- | # 在语句末尾打印分号 | + | { |
- | semi: true | + | |
- | # 使用单引号而不是双引号 | + | options: |
- | singleQuote: false | + | 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.txt · 最后更改: 2021/11/08 18:02 由 admin