@putout/printer
Advanced tools
Comparing version 1.16.0 to 1.16.1
@@ -5,38 +5,43 @@ 'use strict'; | ||
module.exports.ImportDeclaration = (path, {print, maybe}) => { | ||
const specifiers = path.get('specifiers'); | ||
print('import '); | ||
for (const [index, spec] of specifiers.entries()) { | ||
if (spec.isImportDefaultSpecifier()) { | ||
print(spec.get('local')); | ||
continue; | ||
} | ||
module.exports.ImportDeclaration = { | ||
print(path, {print, maybe}) { | ||
const specifiers = path.get('specifiers'); | ||
print('import '); | ||
if (spec.isImportSpecifier()) { | ||
maybe.print(index, ', '); | ||
print('{'); | ||
print(spec.get('imported')); | ||
print('}'); | ||
let wasSpecifier = false; | ||
const n = specifiers.length - 1; | ||
for (const [index, spec] of specifiers.entries()) { | ||
if (spec.isImportDefaultSpecifier()) { | ||
print(spec.get('local')); | ||
continue; | ||
} | ||
continue; | ||
if (spec.isImportSpecifier()) { | ||
maybe.print(index, ', '); | ||
maybe.print(!wasSpecifier, '{'); | ||
wasSpecifier = true; | ||
print(spec.get('imported')); | ||
maybe.print(index === n, '}'); | ||
continue; | ||
} | ||
} | ||
} | ||
if (specifiers.length) { | ||
print.space(); | ||
print('from'); | ||
print.space(); | ||
} | ||
print('__source'); | ||
print(';'); | ||
print.newline(); | ||
if (shouldAddNewlineAfter(path)) { | ||
if (specifiers.length) { | ||
print.space(); | ||
print('from'); | ||
print.space(); | ||
} | ||
print('__source'); | ||
print(';'); | ||
print.newline(); | ||
}, | ||
afterIf: shouldAddNewlineAfter, | ||
after(path, {print}) { | ||
print.newline(); | ||
markAfter(path); | ||
} | ||
}, | ||
}; | ||
function shouldAddNewlineAfter(path) { | ||
@@ -43,0 +48,0 @@ if (path.getNextSibling().isImportDeclaration()) |
{ | ||
"name": "@putout/printer", | ||
"version": "1.16.0", | ||
"version": "1.16.1", | ||
"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
60992
1724