Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 committed Jul 30, 2024
1 parent 2a66b6b commit 7ae844e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/core_docs/scripts/validate_notebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ export function extract(filepath: string) {
const importDeclarations = sourceFile.getImportDeclarations();
const uniqueImports = new Map<string, Set<string>>();

importDeclarations.forEach(importDecl => {
importDeclarations.forEach((importDecl) => {
const moduleSpecifier = importDecl.getModuleSpecifierValue();
if (!uniqueImports.has(moduleSpecifier)) {
uniqueImports.set(moduleSpecifier, new Set());
}
importDecl.getNamedImports().forEach(namedImport => {
importDecl.getNamedImports().forEach((namedImport) => {
uniqueImports.get(moduleSpecifier)!.add(namedImport.getText());
});
});

// Remove all existing imports
importDeclarations.forEach(importDecl => importDecl.remove());
importDeclarations.forEach((importDecl) => importDecl.remove());

// Add deduplicated imports at the top
uniqueImports.forEach((namedImports, moduleSpecifier) => {
Expand Down

0 comments on commit 7ae844e

Please sign in to comment.