MCPcopy Index your code
hub / github.com/code-pushup/cli / formatImport

Function formatImport

packages/create-cli/src/lib/setup/codegen.ts:96–107  ·  view source on GitHub ↗
({
  moduleSpecifier,
  defaultImport,
  namedImports,
  isTypeOnly,
}: ImportDeclarationStructure)

Source from the content-addressed store, hash-verified

94}
95
96function formatImport({
97 moduleSpecifier,
98 defaultImport,
99 namedImports,
100 isTypeOnly,
101}: ImportDeclarationStructure): string {
102 const named = namedImports?.length ? `{ ${namedImports.join(', ')} }` : '';
103 const bindings = [defaultImport, named].filter(Boolean).join(', ');
104 const from = bindings ? `${bindings} from ` : '';
105 const type = isTypeOnly ? 'type ' : '';
106 return `import ${type}${from}'${moduleSpecifier}';`;
107}
108
109function sortImports(
110 imports: ImportDeclarationStructure[],

Callers 1

generateProjectSourceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected