Common configuration
"tabWidth": 2,
"printWidth": 100,
"semi": true,
"singleQuote": true,
"arrowParens": "always",
"bracketSpacing": true,
"trailingComma": "all"
Detailed explanation of configuration items
configuration item |
value |
describe |
tabWidth |
2 |
indentation bytes (2 spaces instead of tabs) |
printWidth |
100 |
Screen display width (the number of bytes that can be accommodated in one line exceeds the automatic line break) |
semi |
true |
add a semicolon at the end of the sentence |
singleQuote |
false |
Enable single quotes |
arrowParens |
always/avoid |
Whether the single parameter of the arrow function omits parentheses |
bracketSpacing |
true |
Objects, add spaces between array brackets and literals { foo: bar } |
trailingComma |
all |
Add a comma at the end of the object or array |
.prettierrc.js configuration
module.exports = {
printWidth: 100,
tabWidth: 2,
semi: true,
singleQuote: true,
trailingComma: 'all',
arrowParens: 'always',
bracketSpacing: true,
};
.prettierignore configuration
# 忽略的文件夹:
build/
coverage/
.vscode/
docker/
node_modules/
.temp/
# 忽略的文件
*.html
*.js