Skip to content

Instantly share code, notes, and snippets.

@Rabbitzzc
Created September 1, 2020 09:02
Show Gist options
  • Save Rabbitzzc/a97c2f78aa5fb63db2c78dc9d698ca30 to your computer and use it in GitHub Desktop.
Save Rabbitzzc/a97c2f78aa5fb63db2c78dc9d698ca30 to your computer and use it in GitHub Desktop.
Prettier 配置文件
# editor 是提供编辑器去约束配置,prettier 是给开发者的代码进行风格约束的,可以使用命令格式化代码,如果需要约束,则需要使用 eslint 强约束
# tps://prettier.io/docs/en/options.html#html-whitespace-sensitivity
module.exports = {
printWidth: 120, // 单行最长,超过设置,将自动换行
tabWidth: 4, // tab 间隔 -- 与 editorconfig 相似
useTabs: false,// space / tabs
singleQuote: true, // 单引号还是双引号
semi: true, // 是否需要分号
// 行尾逗号,默认none,可选 none|es5|all
// es5 包括es5中的数组、对象
// all 包括函数对象等所有可选
TrailingCooma: "none",
// 对象中的空格 默认true
// true: { foo: bar }
// false: {foo: bar}
bracketSpacing: true,
// 箭头函数参数括号 默认avoid 可选 avoid| always
// avoid 能省略括号的时候就省略 例如x => x
// always 总是有括号
arrowParens: 'always',
mlWhitespaceSensitivity: 'ignore'
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment