Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 committed Jul 31, 2024
1 parent 11eb885 commit ff216e6
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions docs/core_docs/scripts/validate_notebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export function extract(filepath: string) {

// Deduplicate imports
const importDeclarations = sourceFile.getImportDeclarations();
const uniqueImports = new Map<string, { default?: string; named: Set<string> }>();
const uniqueImports = new Map<
string,
{ default?: string; named: Set<string> }
>();

importDeclarations.forEach((importDecl) => {
const moduleSpecifier = importDecl.getModuleSpecifierValue();
Expand All @@ -35,13 +38,15 @@ export function extract(filepath: string) {
importDeclarations.forEach((importDecl) => importDecl.remove());

// Add deduplicated imports at the top
uniqueImports.forEach(({ default: defaultImport, named }, moduleSpecifier) => {
sourceFile.addImportDeclaration({
moduleSpecifier,
defaultImport,
namedImports: Array.from(named),
});
});
uniqueImports.forEach(
({ default: defaultImport, named }, moduleSpecifier) => {
sourceFile.addImportDeclaration({
moduleSpecifier,
defaultImport,
namedImports: Array.from(named),
});
}
);

return sourceFile.getFullText();
}
Expand Down

0 comments on commit ff216e6

Please sign in to comment.