@putout/printer
Advanced tools
Comparing version 1.70.1 to 1.70.2
'use strict'; | ||
const {isNewlineBetweenStatements} = require('../is'); | ||
const { | ||
markAfter, | ||
isMarkedAfter, | ||
} = require('../mark'); | ||
const isDeclarationNewline = (path) => isMarkedAfter(path.get('declaration')); | ||
module.exports.ExportSpecifier = (path, {print}) => { | ||
@@ -22,35 +30,47 @@ const { | ||
module.exports.ExportNamedDeclaration = (path, {print, traverse, write, indent}) => { | ||
const {exportKind} = path.node; | ||
const specifiers = path.get('specifiers'); | ||
write('export '); | ||
if (exportKind === 'type' && specifiers.length) { | ||
print('type'); | ||
print(specifiers[0]); | ||
print(' from '); | ||
print('__source'); | ||
print(';'); | ||
module.exports.ExportNamedDeclaration = { | ||
print(path, {print, traverse, write, indent}) { | ||
const {exportKind} = path.node; | ||
const specifiers = path.get('specifiers'); | ||
return; | ||
} | ||
if (specifiers.length) { | ||
write('{'); | ||
indent.inc(); | ||
write.newline(); | ||
write('export '); | ||
for (const spec of specifiers) { | ||
indent(); | ||
traverse(spec); | ||
write(','); | ||
if (exportKind === 'type' && specifiers.length) { | ||
print('type'); | ||
print(specifiers[0]); | ||
print(' from '); | ||
print('__source'); | ||
print(';'); | ||
return; | ||
} | ||
if (specifiers.length) { | ||
write('{'); | ||
indent.inc(); | ||
write.newline(); | ||
for (const spec of specifiers) { | ||
indent(); | ||
traverse(spec); | ||
write(','); | ||
write.newline(); | ||
} | ||
indent.dec(); | ||
write('}'); | ||
} | ||
indent.dec(); | ||
write('}'); | ||
} | ||
print('__declaration'); | ||
print('__declaration'); | ||
}, | ||
afterIf(path) { | ||
if (isDeclarationNewline(path)) | ||
return false; | ||
return isNewlineBetweenStatements(path); | ||
}, | ||
after(path, {print}) { | ||
print.newline(); | ||
markAfter(path); | ||
}, | ||
}; |
@@ -9,6 +9,3 @@ 'use strict'; | ||
const { | ||
hasPrevNewline, | ||
markAfter, | ||
} = require('../mark'); | ||
const {hasPrevNewline} = require('../mark'); | ||
@@ -56,3 +53,3 @@ const {isExportDeclaration} = require('@babel/types'); | ||
maybe.print.newline(!wasNewline); | ||
markAfter(path); | ||
maybe.markAfter(wasNewline, path); | ||
}, | ||
@@ -59,0 +56,0 @@ }; |
{ | ||
"name": "@putout/printer", | ||
"version": "1.70.1", | ||
"version": "1.70.2", | ||
"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
100682
2652