Skip to content

Commit b77c30a

Browse files
committed
various cleaning
- unused import - foundBrand is a const now
1 parent bf818b3 commit b77c30a

File tree

11 files changed

+68
-54
lines changed

11 files changed

+68
-54
lines changed

src/command/render/pandoc-html.ts

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
} from "../../config/types.ts";
2020
import { ProjectContext } from "../../project/types.ts";
2121

22-
import { TempContext } from "../../core/temp.ts";
2322
import { cssImports, cssResources } from "../../core/css.ts";
2423
import { cleanSourceMappingUrl, compileSass } from "../../core/sass.ts";
2524

@@ -91,10 +90,12 @@ export async function resolveSassBundles(
9190
const maybeBrandBundle = bundlesWithBrand.find((bundle) =>
9291
bundle.key === "brand"
9392
);
94-
assert(!maybeBrandBundle ||
95-
!maybeBrandBundle.user?.find((v) => v === "brand") &&
96-
!maybeBrandBundle.dark?.user?.find((v) => v === "brand"));
97-
let foundBrand = {light: false, dark: false};
93+
assert(
94+
!maybeBrandBundle ||
95+
!maybeBrandBundle.user?.find((v) => v === "brand") &&
96+
!maybeBrandBundle.dark?.user?.find((v) => v === "brand"),
97+
);
98+
const foundBrand = { light: false, dark: false };
9899
const bundles: SassBundle[] = bundlesWithBrand.filter((bundle) =>
99100
bundle.key !== "brand"
100101
).map((bundle) => {
@@ -106,12 +107,18 @@ export async function resolveSassBundles(
106107
bundle.user!.splice(userBrand, 1, ...(maybeBrandBundle?.user || []));
107108
foundBrand.light = true;
108109
}
109-
const darkBrand = bundle.dark?.user?.findIndex((layer) => layer === "brand");
110+
const darkBrand = bundle.dark?.user?.findIndex((layer) =>
111+
layer === "brand"
112+
);
110113
if (darkBrand && darkBrand !== -1) {
111114
if (!cloned) {
112115
bundle = cloneDeep(bundle);
113116
}
114-
bundle.dark!.user!.splice(darkBrand, 1, ...(maybeBrandBundle?.dark?.user || []))
117+
bundle.dark!.user!.splice(
118+
darkBrand,
119+
1,
120+
...(maybeBrandBundle?.dark?.user || []),
121+
);
115122
foundBrand.dark = true;
116123
}
117124
return bundle as SassBundle;
@@ -122,18 +129,19 @@ export async function resolveSassBundles(
122129
key: "brand",
123130
user: !foundBrand.light && maybeBrandBundle?.user as SassLayer[] || [],
124131
dark: !foundBrand.dark && maybeBrandBundle?.dark?.user && {
125-
user: maybeBrandBundle.dark.user as SassLayer[],
126-
default: maybeBrandBundle.dark.default
127-
} || undefined
132+
user: maybeBrandBundle.dark.user as SassLayer[],
133+
default: maybeBrandBundle.dark.default,
134+
} || undefined,
128135
});
129136
}
130137

131138
// See if any bundles are providing dark specific css
132139
const hasDark = bundles.some((bundle) => bundle.dark !== undefined);
133-
defaultStyle =
134-
bundles.some((bundle) => bundle.dark !== undefined && bundle.dark.default)
135-
? "dark"
136-
: "light";
140+
defaultStyle = bundles.some((bundle) =>
141+
bundle.dark !== undefined && bundle.dark.default
142+
)
143+
? "dark"
144+
: "light";
137145
const targets: SassTarget[] = [{
138146
name: `${dependency}.min.css`,
139147
bundles: (bundles as any),

src/command/render/project.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ import { fileExecutionEngine } from "../../execute/engine.ts";
8181
import { projectContextForDirectory } from "../../project/project-context.ts";
8282
import { ProjectType } from "../../project/types/types.ts";
8383
import { ProjectConfig as ProjectConfig_Project } from "../../resources/types/schema-types.ts";
84-
import { Extension } from "../../extension/types.ts";
8584

8685
const noMutationValidations = (
8786
projType: ProjectType,

src/core/sass.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { existsSync } from "../deno_ral/fs.ts";
88
import { join } from "../deno_ral/path.ts";
99

1010
import { quartoCacheDir } from "./appdirs.ts";
11-
import { TempContext } from "./temp.ts";
1211

1312
import { SassBundleLayers, SassLayer } from "../config/types.ts";
1413
import { dartCompile } from "./dart-sass.ts";

src/execute/engine.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright (C) 2020-2022 Posit Software, PBC
55
*/
66

7-
import { extname, join, resolve } from "../deno_ral/path.ts";
7+
import { extname, join } from "../deno_ral/path.ts";
88

99
import * as ld from "../core/lodash.ts";
1010

@@ -23,7 +23,6 @@ import { kMdExtensions, markdownEngine } from "./markdown.ts";
2323
import { ExecutionEngine, kQmdExtensions } from "./types.ts";
2424
import { languagesInMarkdown } from "./engine-shared.ts";
2525
import { languages as handlerLanguages } from "../core/handlers/base.ts";
26-
import { MappedString } from "../core/lib/text-types.ts";
2726
import { RenderContext, RenderFlags } from "../command/render/types.ts";
2827
import { mergeConfigs } from "../core/config.ts";
2928
import { ProjectContext } from "../project/types.ts";

src/project/project-context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ import { NotebookContext } from "../render/notebook/notebook-types.ts";
102102
import { MappedString } from "../core/mapped-text.ts";
103103
import { makeTimedFunctionAsync } from "../core/performance/function-times.ts";
104104
import { createProjectCache } from "../core/cache/cache.ts";
105-
import { createTempContext, globalTempContext } from "../core/temp.ts";
105+
import { createTempContext } from "../core/temp.ts";
106106

107107
export async function projectContext(
108108
path: string,

src/project/project-shared.ts

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ import { normalizeNewlines } from "../core/lib/text.ts";
4747
import { DirectiveCell } from "../core/lib/break-quarto-md-types.ts";
4848
import { QuartoJSONSchema, readYamlFromMarkdown } from "../core/yaml.ts";
4949
import { refSchema } from "../core/lib/yaml-schema/common.ts";
50-
import { Brand as BrandJson, BrandPathBoolLightDark } from "../resources/types/schema-types.ts";
50+
import {
51+
Brand as BrandJson,
52+
BrandPathBoolLightDark,
53+
} from "../resources/types/schema-types.ts";
5154
import { Brand } from "../core/brand/brand.ts";
52-
import { warnOnce } from "../core/log.ts";
5355
import { assert } from "testing/asserts";
5456

5557
export function projectExcludeDirs(context: ProjectContext): string[] {
@@ -503,6 +505,10 @@ export const ensureFileInformationCache = (
503505
if (!project.fileInformationCache) {
504506
project.fileInformationCache = new Map();
505507
}
508+
assert(
509+
project.fileInformationCache instanceof Map,
510+
JSON.stringify(project.fileInformationCache),
511+
);
506512
if (!project.fileInformationCache.has(file)) {
507513
project.fileInformationCache.set(file, {} as FileInformation);
508514
}
@@ -512,16 +518,19 @@ export const ensureFileInformationCache = (
512518
export async function projectResolveBrand(
513519
project: ProjectContext,
514520
fileName?: string,
515-
) : Promise<{light?: Brand, dark?: Brand} | undefined> {
516-
async function loadBrand(brandPath: string) : Promise<Brand> {
521+
): Promise<{ light?: Brand; dark?: Brand } | undefined> {
522+
async function loadBrand(brandPath: string): Promise<Brand> {
517523
const brand = await readAndValidateYamlFromFile(
518524
brandPath,
519525
refSchema("brand", "Format-independent brand configuration."),
520526
"Brand validation failed for " + brandPath + ".",
521527
) as BrandJson;
522528
return new Brand(brand, dirname(brandPath), project.dir);
523529
}
524-
async function loadRelativeBrand(brandPath: string, dir: string = dirname(fileName!)) : Promise<Brand> {
530+
async function loadRelativeBrand(
531+
brandPath: string,
532+
dir: string = dirname(fileName!),
533+
): Promise<Brand> {
525534
let resolved: string = "";
526535
if (brandPath.startsWith("/")) {
527536
resolved = join(project.dir, brandPath);
@@ -538,18 +547,27 @@ export async function projectResolveBrand(
538547
let fileNames = ["_brand.yml", "_brand.yaml"].map((file) =>
539548
join(project.dir, file)
540549
);
541-
let brand = project?.config?.brand as Boolean | string | {light?: string, dark?: string};
550+
let brand = project?.config?.brand as Boolean | string | {
551+
light?: string;
552+
dark?: string;
553+
};
542554
if (brand === false) {
543555
project.brandCache.brand = undefined;
544556
return project.brandCache.brand;
545557
}
546-
if (typeof brand === "object" && brand &&
547-
("light" in brand || "dark" in brand)) {
558+
if (
559+
typeof brand === "object" && brand &&
560+
("light" in brand || "dark" in brand)
561+
) {
548562
project.brandCache.brand = {
549-
light: brand.light ? await loadRelativeBrand(brand.light, project.dir) : undefined,
550-
dark: brand.dark ? await loadRelativeBrand(brand.dark, project.dir) : undefined,
563+
light: brand.light
564+
? await loadRelativeBrand(brand.light, project.dir)
565+
: undefined,
566+
dark: brand.dark
567+
? await loadRelativeBrand(brand.dark, project.dir)
568+
: undefined,
551569
};
552-
return project.brandCache.brand;
570+
return project.brandCache.brand;
553571
}
554572
if (typeof brand === "string") {
555573
fileNames = [join(project.dir, brand)];
@@ -559,7 +577,7 @@ export async function projectResolveBrand(
559577
if (!existsSync(brandPath)) {
560578
continue;
561579
}
562-
project.brandCache.brand = {light: await loadBrand(brandPath)};
580+
project.brandCache.brand = { light: await loadBrand(brandPath) };
563581
}
564582
return project.brandCache.brand;
565583
} else {
@@ -576,37 +594,39 @@ export async function projectResolveBrand(
576594
return fileInformation.brand;
577595
}
578596
if (typeof brand === "string") {
579-
fileInformation.brand = {light: await loadRelativeBrand(brand)};
597+
fileInformation.brand = { light: await loadRelativeBrand(brand) };
580598
return fileInformation.brand;
581599
} else {
582600
assert(typeof brand === "object");
583601
if ("light" in brand || "dark" in brand) {
584602
let light, dark;
585603
if (typeof brand.light === "string") {
586-
light = await loadRelativeBrand(brand.light)
604+
light = await loadRelativeBrand(brand.light);
587605
} else {
588606
light = new Brand(
589607
brand.light!,
590608
dirname(fileName),
591-
project.dir
609+
project.dir,
592610
);
593611
}
594612
if (typeof brand.dark === "string") {
595-
dark = await loadRelativeBrand(brand.dark)
613+
dark = await loadRelativeBrand(brand.dark);
596614
} else {
597615
dark = new Brand(
598616
brand.dark!,
599617
dirname(fileName),
600-
project.dir
618+
project.dir,
601619
);
602620
}
603-
fileInformation.brand = {light, dark};
621+
fileInformation.brand = { light, dark };
604622
} else {
605-
fileInformation.brand = {light: new Brand(
606-
brand as BrandJson,
607-
dirname(fileName),
608-
project.dir,
609-
)};
623+
fileInformation.brand = {
624+
light: new Brand(
625+
brand as BrandJson,
626+
dirname(fileName),
627+
project.dir,
628+
),
629+
};
610630
}
611631
return fileInformation.brand;
612632
}

src/project/types/website/listing/website-listing-template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*/
88
import { Document, Element } from "deno_dom/deno-dom-wasm-noinit.ts";
9-
import { cloneDeep, escape } from "../../../../core/lodash.ts";
9+
import { escape } from "../../../../core/lodash.ts";
1010
import {
1111
kListingPageMinutesCompact,
1212
kListingPageOrderByDateAsc,

src/render/notebook/notebook-contributor-html.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ import {
3939
NotebookTemplateMetadata,
4040
} from "./notebook-types.ts";
4141

42-
import * as ld from "../../core/lodash.ts";
43-
4442
import { error } from "../../deno_ral/log.ts";
4543
import { formatResourcePath } from "../../core/resources.ts";
4644
import { kNotebookViewStyleNotebook } from "../../format/html/format-html-constants.ts";

src/render/notebook/notebook-contributor-ipynb.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ import { InternalError } from "../../core/lib/error.ts";
2525
import { dirAndStem } from "../../core/path.ts";
2626
import { ProjectContext } from "../../project/types.ts";
2727
import { NotebookContributor, NotebookMetadata } from "./notebook-types.ts";
28-
29-
import * as ld from "../../core/lodash.ts";
30-
3128
import { error } from "../../deno_ral/log.ts";
3229
import { Format } from "../../config/types.ts";
3330
import { ipynbTitleTemplatePath } from "../../format/ipynb/format-ipynb.ts";

src/render/notebook/notebook-contributor-jats.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ import {
3232
import { subarticleTemplatePath } from "../../format/jats/format-jats-paths.ts";
3333
import { ProjectContext } from "../../project/types.ts";
3434
import { NotebookContributor, NotebookMetadata } from "./notebook-types.ts";
35-
36-
import * as ld from "../../core/lodash.ts";
37-
3835
import { error } from "../../deno_ral/log.ts";
3936
import { Format } from "../../config/types.ts";
4037
import { safeCloneDeep } from "../../core/safe-clone-deep.ts";

0 commit comments

Comments
 (0)