@putout/printer
Advanced tools
Comparing version 11.2.1 to 11.3.0
'use strict'; | ||
const {isParens} = require('../../maybe/maybe-parens'); | ||
module.exports.maybePrintLeftBrace = (path, printer, semantics) => { | ||
@@ -5,0 +6,0 @@ maybeWriteBrace(path, printer, semantics, { |
@@ -9,54 +9,31 @@ 'use strict'; | ||
const {maybeSpace} = require('./maybe-space'); | ||
const {isParens} = require('../../maybe/maybe-parens'); | ||
const {maybeParens} = require('../../maybe/maybe-parens'); | ||
const BinaryExpression = { | ||
condition(path) { | ||
if (isParens(path)) | ||
return true; | ||
module.exports.BinaryExpression = maybeParens((path, {print, indent, maybe}) => { | ||
const {operator} = path.node; | ||
if (operator === 'in' || operator === 'instanceof') { | ||
print('__left'); | ||
print(' '); | ||
print(operator); | ||
print(' '); | ||
print('__right'); | ||
return path.parentPath.isAwaitExpression(); | ||
}, | ||
before(path, {print}) { | ||
print('('); | ||
}, | ||
print(path, {print, indent, maybe}) { | ||
const {operator} = path.node; | ||
if (operator === 'instanceof') { | ||
print('__left'); | ||
print(' instanceof '); | ||
print('__right'); | ||
return; | ||
} | ||
if (operator === 'in') { | ||
print('__left'); | ||
print(' in '); | ||
print('__right'); | ||
return; | ||
} | ||
if (isConcatenation(path)) | ||
return concatenate(path, { | ||
print, | ||
indent, | ||
maybe, | ||
}); | ||
print('__left'); | ||
print.space(); | ||
print(path.node.operator); | ||
maybeSpace(path, { | ||
return; | ||
} | ||
if (isConcatenation(path)) | ||
return concatenate(path, { | ||
print, | ||
indent, | ||
maybe, | ||
}); | ||
print('__right'); | ||
}, | ||
after(path, {print}) { | ||
print(')'); | ||
}, | ||
}; | ||
module.exports.BinaryExpression = BinaryExpression; | ||
module.exports.LogicalExpression = BinaryExpression; | ||
print('__left'); | ||
print.space(); | ||
print(path.node.operator); | ||
maybeSpace(path, { | ||
print, | ||
}); | ||
print('__right'); | ||
}); |
@@ -20,2 +20,5 @@ 'use strict'; | ||
if (operator !== '+') | ||
return false; | ||
const startLine = path.node.loc?.start.line; | ||
@@ -30,5 +33,2 @@ const endLine = path.node.loc?.end.line; | ||
if (operator !== '+') | ||
return false; | ||
if (isStringLike(left) && isStringLike(right) && isBinaryExpression(parentPath)) | ||
@@ -35,0 +35,0 @@ return true; |
@@ -38,8 +38,4 @@ 'use strict'; | ||
const {TaggedTemplateExpression} = require('./tagged-template-expression'); | ||
const { | ||
BinaryExpression, | ||
LogicalExpression, | ||
} = require('./binary-expression/binary-expression'); | ||
const {BinaryExpression} = require('./binary-expression/binary-expression'); | ||
const {LogicalExpression} = require('./logical-expression/logical-expression'); | ||
const {ConditionalExpression} = require('./conditional-expression'); | ||
@@ -46,0 +42,0 @@ const {StaticBlock} = require('./class/static-block'); |
{ | ||
"name": "@putout/printer", | ||
"version": "11.2.1", | ||
"version": "11.3.0", | ||
"type": "commonjs", | ||
@@ -5,0 +5,0 @@ "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)", |
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
240599
144
5266
10350