package
A JavaScript formatter
npm install jformatterGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
A JavaScript formatter
The easiest way to use JFormatter is to install it as a Node program.
npm -g install jformatterAfter you've done that you should be able to use the jformatter program.
jformatter file.js Usage: jformatter [options] <file>
Options:
-h, --help output usage information
-v, --version output the version number
-d, --diff Show difference between source and formattedWhen use jformatter in terminal, it will try to load .jformatterrc.
JFormatter will start looking for this file in the same directory as the file that's being formatted. If not found, it will move one level up the directory tree all the way up to the filesystem root.
zttonly
zttonly@gmail.com
100pah
sushuang0322@gmail.com
ecomfe-core
ecomfe@gmail.com
ecomfe-admin
ecomfe@gmail.com
otakustay
otakustay@gmail.com
leeight
leeight@gmail.com
justineo
justice360@gmail.com
gdjinbo
wfsr@foxmail.com
luyuan
luyuan.china@gmail.com
errorrik
errorrik@gmail.com
ksky521
ksky521@gmail.com
lang
shenyi.914@gmail.com
jinzhan
steinitz@qq.com
ishowshao
me@ishowshao.com
Default config, developing, not stable.
{
lineSeparator: '\n', // done
maxLength: 120, // TODO
wrapIfLong: false, // TODO
indent: 4, // done
useTabIndent: false, // 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: {
// function call, function declaration, if, for, while, switch, catch
parentheses: false // done
},
other: {
beforePropertyNameValueSeparator: false, // done {key: value} {key : value} {key:value}
afterPropertyNameValueSeparator: true // done
}
},
bracesPlacement: { // 1. same line 2. next line
functionDeclaration: 1, // TODO
other: 1 // TODO
},
blankLines: {
keepMaxBlankLines: 1, // done
atEndOfFile: true // done
},
other: {
keepArraySingleLine: false // TODO default formatted array multi line
},
fix: {
prefixSpaceToLineComment: false, // done
alterCommonBlockCommentToLineComment: false, // done
singleVariableDeclarator: false, // done
fixInvalidTypeof: false, // done
removeEmptyStatement: false, // done
autoSemicolon: false, // done
singleQuotes: false, // done
eqeqeq: false, // done
invalidConstructor: false, // done
addCurly: false, // done
removeDebugger: false // done
}
}require('jformatter').format(code, [configObj]) : string
require('jformatter').formatFile(filePath, [configObj]) : string
require('jformatter').version() : string
require('jformatter').getDefaultConfig() : configObjplease update to >=v1.0.5, see version change log
instanceofconfig.fix},voidtypeofEstimated unpacked size across 13 packages.
1003.4 kB
Includes dependencies.
3 direct · 3 outdated