JSPM

  • Created
  • Published
  • Downloads 167
  • Score
    100M100P100Q92449F
  • License BSD-2-Clause

A JavaScript formatter

Package Exports

  • jformatter

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jformatter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

jformatter

A JavaScript formatter

Install:
    npm -g install jformatter

Usage:
    jformatter yourFile.js

Github: https://github.com/ishowshao/jformatter

Default config, developing, not stable

{
    lineSeparator: '\n', //done
    maxLength: 120, //todo
    wrapIfLong: false, //todo
    indents: '    ', //done
    spaces: {
        around: {
            unaryOperators: false, //todo
            binaryOperators: true, //done
            ternaryOperators: true //done
        },
        before: {
            functionDeclarationParentheses: false, //done function foo() {
            functionExpressionParentheses: true, //done var foo = function () {
            parentheses: true, //done if (), for (), while (), ...
            leftBrace: true, //done function () {, if () {, do {, try { ...
            keywords: true //done if {} else {}, do {} while (), try {} catch () {} finally
        },
        within: {
            parentheses: false //todo 这个配置比较麻烦( a, b, c ) , if ( true ) or (a, b, c) , if (true)
        },
        other: {
            beforePropertyNameValueSeparator: false, // {key: value} {key : value} {key:value}
            afterPropertyNameValueSeparator: true //done
        }
    },
    bracesPlacement: { //1. same line 2. next line
        functionDeclaration: 1,
        other: 1
    },
    other: {
    }
}