@putout/printer
Advanced tools
Comparing version 1.23.0 to 1.24.0
'use strict'; | ||
module.exports.MemberExpression = (path, {print}) => { | ||
const {isIfStatement} = require('@babel/types'); | ||
const isInnerCall = (path) => path.get('object').isCallExpression(); | ||
const isOuterCall = (path) => path.parentPath.isCallExpression(); | ||
module.exports.MemberExpression = (path, {print, indent, maybe}) => { | ||
const {computed} = path.node; | ||
@@ -15,4 +19,13 @@ print('__object'); | ||
const isChain = looksLikeChain(path); | ||
maybe.indent.inc(isChain); | ||
if (isChain) { | ||
print.newline(); | ||
indent(isChain); | ||
} | ||
print('.'); | ||
print('__property'); | ||
maybe.indent.dec(isChain); | ||
}; | ||
@@ -35,1 +48,16 @@ | ||
}; | ||
function looksLikeChain(path) { | ||
const {parentPath} = path; | ||
if (parentPath.parentPath.isStatement() && !parentPath.parentPath.isExpressionStatement()) | ||
return false; | ||
if (path.find(isIfStatement)) | ||
return false; | ||
if (isInnerCall(path) && isOuterCall(path)) | ||
return true; | ||
return false; | ||
} |
{ | ||
"name": "@putout/printer", | ||
"version": "1.23.0", | ||
"version": "1.24.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
66123
1833