prettier配置

1,346 阅读1分钟
module.exports = {
    // 一行的字符数,如果超过会进行换行,默认为80
    printWidth: 80,
    // 一个tab代表几个空格数
    tabWidth: 4,
    // 是否使用tab进行缩进,默认为false,表示用空格进行缩减
    useTabs: false,
    // 行尾是否使用分号,默认为true
    semi: true,
    // 字符串是否使用单引号,默认为false(在jsx中配置无效, 默认都是双引号)
    singleQuote: true,
    // jsx 不使用单引号,而使用双引号
    jsxSingleQuote: false,
    // 对象的 key 仅在必要时用引号
    quoteProps: 'as-needed',
    // 是否使用尾逗号,默认none,可选 none|es5|all
    // es5 包括es5中的数组、对象
    // all 包括函数对象等所有可选
    trailingComma: 'es5',
    // 对象大括号直接是否有空格,默认为true
    // true: { foo: bar }
    // false: {foo: bar}
    bracketSpacing: true,
    // JSX标签闭合位置 默认false, 标签的反尖括号需要换行
    // false: <div
    //          className=""
    //          style={{}}
    //       >
    // true: <div
    //          className=""
    //          style={{}} >
    jsxBracketSameLine: false,
    // 使用默认的折行标准 always
    proseWrap: 'preserve',
    // 箭头函数参数括号, 只有一个参数的时候,也需要括号, 默认avoid 可选 avoid| always
    // avoid 能省略括号的时候就省略 例如x => x
    // always 总是有括号
    arrowParens: 'always',
    // 换行符使用 lf auto
    endOfLine: 'lf',
    // 根据显示样式决定 html 要不要折行
    htmlWhitespaceSensitivity: 'ignore',
    // 不使用prettier格式化的文件填写在项目的.prettierignore文件中
    ignorePath: '.prettierignore',
    // Require a "prettierconfig" to format prettier
    requireConfig: true,
    // 不让prettier使用eslint的代码格式进行校验
    eslintIntegration: false,
    // 不让prettier使用stylelint的代码格式进行校验
    stylelintIntegration: false,
    // 不让prettier使用tslint的代码格式进行校验
    tslintIntegration: false,
    // 代码的解析引擎,默认为babylon,与babel相同
    parser: 'babylon'
};