@putout/printer
Advanced tools
Comparing version 1.12.0 to 1.13.0
@@ -20,5 +20,3 @@ 'use strict'; | ||
maybe.indent(isNewLine); | ||
print(element); | ||
maybe.print(isNewLine, ',\n'); | ||
@@ -29,7 +27,4 @@ maybe.print(!isNewLine && index < n, ', '); | ||
indent.dec(); | ||
maybe.indent(elements.length && isNewLine); | ||
print(']'); | ||
}; | ||
@@ -5,3 +5,2 @@ 'use strict'; | ||
const {operator} = path.node; | ||
print('__left'); | ||
@@ -8,0 +7,0 @@ print(' '); |
@@ -10,2 +10,1 @@ 'use strict'; | ||
}; | ||
@@ -13,2 +13,1 @@ 'use strict'; | ||
} | ||
@@ -19,3 +19,2 @@ 'use strict'; | ||
const isParentCall = toLong(path) && path.parentPath.isCallExpression(); | ||
print('__callee'); | ||
@@ -60,3 +59,2 @@ | ||
module.exports.OptionalCallExpression = CallExpression; | ||
module.exports.CallExpression = CallExpression; | ||
@@ -63,0 +61,0 @@ |
'use strict'; | ||
const {entries} = Object; | ||
module.exports.ClassDeclaration = (path, {maybe, print, indent}) => { | ||
@@ -8,2 +9,11 @@ indent(); | ||
print('__id'); | ||
print('__typeParameters'); | ||
const {node} = path; | ||
if (node.implements) { | ||
print(' implements '); | ||
path.get('implements').forEach(print); | ||
} | ||
print(' {\n'); | ||
@@ -24,2 +34,1 @@ indent.inc(); | ||
}; | ||
@@ -14,2 +14,1 @@ 'use strict'; | ||
}; | ||
'use strict'; | ||
const {hasPrevNewline} = require('../mark'); | ||
const isFirst = (path) => !path.getPrevSibling().node; | ||
@@ -54,3 +53,2 @@ | ||
} | ||
module.exports.ObjectMethod = (path, {print}) => { | ||
@@ -57,0 +55,0 @@ print('__key'); |
@@ -5,3 +5,2 @@ 'use strict'; | ||
const {computed} = path.node; | ||
print('__object'); | ||
@@ -26,2 +25,1 @@ | ||
}; | ||
@@ -9,2 +9,3 @@ 'use strict'; | ||
const args = path.get('arguments'); | ||
print('('); | ||
@@ -21,2 +22,1 @@ | ||
}; | ||
@@ -62,2 +62,3 @@ 'use strict'; | ||
} = path.node; | ||
const manyLines = !isOneLine(path.parentPath); | ||
@@ -64,0 +65,0 @@ |
@@ -11,4 +11,4 @@ 'use strict'; | ||
const n = properties.length - 1; | ||
const is = !isForOf(path) && !path.parentPath.isFunction() && n && checkLength(properties); | ||
const is = !isForOf(path) && !path.parentPath.isFunction() && n && checkLength(properties); | ||
maybe.print(is, '\n'); | ||
@@ -40,2 +40,3 @@ | ||
print.newline(); | ||
continue; | ||
@@ -60,2 +61,1 @@ } | ||
} | ||
@@ -15,2 +15,1 @@ 'use strict'; | ||
}; | ||
@@ -7,2 +7,1 @@ 'use strict'; | ||
}; | ||
@@ -5,2 +5,3 @@ 'use strict'; | ||
module.exports.UpdateExpression = unaryExpression; | ||
module.exports.AwaitExpression = (path, {print}) => { | ||
@@ -11,2 +12,3 @@ printUnary(path, 'await', { | ||
}; | ||
module.exports.YieldExpression = (path, {print}) => { | ||
@@ -33,7 +35,9 @@ printUnary(path, 'yield', { | ||
} | ||
const isWord = (a) => /delete|typeof/.test(a); | ||
function unaryExpression(path, {print, maybe}) { | ||
const {prefix, operator} = path.node; | ||
const { | ||
prefix, | ||
operator, | ||
} = path.node; | ||
@@ -43,3 +47,5 @@ if (prefix) | ||
maybe.print(isWord(operator), ' '); | ||
maybe.print(isWord( | ||
operator, | ||
), ' '); | ||
print('__argument'); | ||
@@ -50,2 +56,1 @@ | ||
} | ||
@@ -11,2 +11,3 @@ 'use strict'; | ||
write(element.value.raw); | ||
const exp = expressions[i++]; | ||
@@ -23,2 +24,1 @@ | ||
}; | ||
@@ -27,3 +27,2 @@ 'use strict'; | ||
} | ||
module.exports.hasPrevNewline = (path) => { | ||
@@ -30,0 +29,0 @@ return isMarkedAfter(path.getPrevSibling()); |
@@ -7,3 +7,2 @@ 'use strict'; | ||
isLast, | ||
} = require('../is'); | ||
@@ -10,0 +9,0 @@ |
@@ -8,2 +8,1 @@ 'use strict'; | ||
}; | ||
@@ -7,2 +7,1 @@ 'use strict'; | ||
}; | ||
@@ -51,2 +51,1 @@ 'use strict'; | ||
}; | ||
@@ -20,2 +20,3 @@ 'use strict'; | ||
print('}'); | ||
continue; | ||
@@ -22,0 +23,0 @@ } |
@@ -11,3 +11,2 @@ 'use strict'; | ||
print(') {'); | ||
print.newline(); | ||
@@ -48,2 +47,1 @@ | ||
}; | ||
'use strict'; | ||
const {isNext} = require('../is'); | ||
module.exports.TryStatement = (path, {print, maybe}) => { | ||
const finalizer = path.get('finalizer'); | ||
print('try '); | ||
@@ -37,2 +37,1 @@ print('__block'); | ||
}; | ||
'use strict'; | ||
const fullstore = require('fullstore'); | ||
const isObject = (a) => a && typeof a === 'object'; | ||
@@ -10,6 +9,11 @@ const babelTraverse = require('@babel/traverse').default; | ||
const literals = require('./literals'); | ||
const typescript = require('./typescript'); | ||
const {TYPES} = require('../types'); | ||
const {maybeFile, maybePlugin} = require('./maybe'); | ||
const { | ||
maybeFile, | ||
maybePlugin, | ||
} = require('./maybe'); | ||
const { | ||
createDebug, | ||
@@ -36,2 +40,3 @@ createLog, | ||
...literals, | ||
...typescript, | ||
}; | ||
@@ -197,3 +202,2 @@ | ||
parseTrailingComments(path, printer); | ||
debug(path.type); | ||
@@ -230,2 +234,1 @@ } | ||
}; | ||
@@ -10,2 +10,1 @@ 'use strict'; | ||
}; | ||
{ | ||
"name": "@putout/printer", | ||
"version": "1.12.0", | ||
"version": "1.13.0", | ||
"type": "commonjs", | ||
@@ -5,0 +5,0 @@ "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)", |
@@ -23,6 +23,8 @@ # Printer [![NPM version][NPMIMGURL]][NPMURL] | ||
const {parse} = require('@babel/parser'); | ||
const ast = parse('const a = (b, c) => {const d = 5; return a;}'); | ||
const ast = parse('const a = (b, c) => {const d = 5; return a;}'); | ||
print(ast); | ||
// returns | ||
// returns | ||
` | ||
@@ -34,2 +36,3 @@ const a = (b, c) => { | ||
`; | ||
``` | ||
@@ -65,3 +68,5 @@ | ||
// returns | ||
// returns | ||
'const {a /* [hello world] */= 5} = b;\n'; | ||
``` | ||
@@ -68,0 +73,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55223
54
1592
74