Skip to content

Commit

Permalink
applying prettier via npm run format (#2269)
Browse files Browse the repository at this point in the history
hand checked each change through my git client, built it, and ran it inside obsidian.
  • Loading branch information
GottZ committed Mar 17, 2024
1 parent cc2626a commit 15f3fa0
Show file tree
Hide file tree
Showing 41 changed files with 320 additions and 310 deletions.
10 changes: 5 additions & 5 deletions src/api/data-array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ class DataArrayImpl<T> implements DataArray<T> {
public static wrap<T>(
arr: T[],
settings: QuerySettings,
defaultComparator: ArrayComparator<any> = Values.compareValue
defaultComparator: ArrayComparator<any> = Values.compareValue,
): DataArray<T> {
return new Proxy<DataArrayImpl<T>>(
new DataArrayImpl<T>(arr, settings, defaultComparator),
DataArrayImpl.ARRAY_PROXY
DataArrayImpl.ARRAY_PROXY,
);
}

Expand All @@ -195,7 +195,7 @@ class DataArrayImpl<T> implements DataArray<T> {
private constructor(
public values: any[],
public settings: QuerySettings,
public defaultComparator: ArrayComparator<any> = Values.compareValue
public defaultComparator: ArrayComparator<any> = Values.compareValue,
) {
this.length = values.length;
}
Expand Down Expand Up @@ -299,7 +299,7 @@ class DataArrayImpl<T> implements DataArray<T> {
public sortInPlace<U>(
key?: (value: T) => U,
direction?: "asc" | "desc",
comparator?: ArrayComparator<U>
comparator?: ArrayComparator<U>,
): DataArray<T> {
if (this.values.length == 0) return this;
let realComparator = comparator ?? this.defaultComparator;
Expand All @@ -317,7 +317,7 @@ class DataArrayImpl<T> implements DataArray<T> {

public groupBy<U>(
key: ArrayFunc<T, U>,
comparator?: ArrayComparator<U>
comparator?: ArrayComparator<U>,
): DataArray<{ key: U; rows: DataArray<T> }> {
if (this.values.length == 0) return this.lwrap([]);

Expand Down
12 changes: 6 additions & 6 deletions src/api/inline-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class DataviewInlineApi {
public async query(
source: string,
originFile?: string,
settings?: QueryApiSettings
settings?: QueryApiSettings,
): Promise<Result<QueryResult, string>> {
return this.api.query(source, originFile ?? this.currentFilePath, settings);
}
Expand All @@ -149,7 +149,7 @@ export class DataviewInlineApi {
public async queryMarkdown(
source: string,
originFile?: string,
settings?: QueryApiSettings
settings?: QueryApiSettings,
): Promise<Result<string, string>> {
return this.api.queryMarkdown(source, originFile ?? this.currentFilePath, settings);
}
Expand Down Expand Up @@ -279,7 +279,7 @@ export class DataviewInlineApi {
public el<K extends keyof HTMLElementTagNameMap>(
el: K,
text: any,
{ container = this.container, ...options }: DomElementInfo & { container?: HTMLElement } = {}
{ container = this.container, ...options }: DomElementInfo & { container?: HTMLElement } = {},
): HTMLElementTagNameMap[K] {
let wrapped = Values.wrapValue(text);

Expand Down Expand Up @@ -329,7 +329,7 @@ export class DataviewInlineApi {
if (!viewFile) {
renderErrorPre(
this.container,
`Dataview: custom view not found for '${simpleViewPath}' or '${complexViewPath}'.`
`Dataview: custom view not found for '${simpleViewPath}' or '${complexViewPath}'.`,
);
return;
}
Expand Down Expand Up @@ -360,7 +360,7 @@ export class DataviewInlineApi {
this.currentFilePath,
this.component,
this.settings,
true
true,
);
} catch (ex) {
if (cssElement) this.container.removeChild(cssElement);
Expand Down Expand Up @@ -391,7 +391,7 @@ export class DataviewInlineApi {
public markdownTable(
headers: string[],
values?: any[][] | DataArray<any>,
settings?: Partial<ExportSettings>
settings?: Partial<ExportSettings>,
): string {
return this.api.markdownTable(headers, values, settings);
}
Expand Down
36 changes: 18 additions & 18 deletions src/api/plugin-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class DataviewApi {
public app: App,
public index: FullIndex,
public settings: DataviewSettings,
private verNum: string
private verNum: string,
) {
this.evaluationContext = new Context(defaultLinkHandler(index, ""), settings);
this.func = Functions.bindAll(DEFAULT_FUNCTIONS, this.evaluationContext);
Expand Down Expand Up @@ -265,7 +265,7 @@ export class DataviewApi {
public async query(
source: string | Query,
originFile?: string,
settings?: QueryApiSettings
settings?: QueryApiSettings,
): Promise<Result<QueryResult, string>> {
const query = typeof source === "string" ? parseQuery(source) : Result.success<Query, string>(source);
if (!query.successful) return query.cast();
Expand Down Expand Up @@ -320,7 +320,7 @@ export class DataviewApi {
public async queryMarkdown(
source: string | Query,
originFile?: string,
settings?: Partial<QueryApiSettings & ExportSettings>
settings?: Partial<QueryApiSettings & ExportSettings>,
): Promise<Result<string, string>> {
const result = await this.query(source, originFile, settings);
if (!result.successful) return result.cast();
Expand All @@ -341,7 +341,7 @@ export class DataviewApi {
public async tryQueryMarkdown(
source: string | Query,
originFile?: string,
settings?: Partial<QueryApiSettings & ExportSettings>
settings?: Partial<QueryApiSettings & ExportSettings>,
): Promise<string> {
return (await this.queryMarkdown(source, originFile, settings)).orElseThrow();
}
Expand Down Expand Up @@ -399,7 +399,7 @@ export class DataviewApi {
source: string,
container: HTMLElement,
component: Component | MarkdownPostProcessorContext,
filePath: string
filePath: string,
) {
if (isDataviewDisabled(filePath)) {
renderCodeBlock(container, source);
Expand Down Expand Up @@ -439,7 +439,7 @@ export class DataviewApi {
this.index,
filePath,
this.settings,
this.app
this.app,
);

component.addChild(childComponent);
Expand All @@ -456,7 +456,7 @@ export class DataviewApi {
code: string,
container: HTMLElement,
component: Component | MarkdownPostProcessorContext,
filePath: string
filePath: string,
) {
if (isDataviewDisabled(filePath)) {
renderCodeBlock(container, code, "javascript");
Expand All @@ -472,7 +472,7 @@ export class DataviewApi {
values: any[] | DataArray<any> | undefined,
container: HTMLElement,
component: Component,
filePath: string
filePath: string,
) {
if (!values) return;
if (values !== undefined && values !== null && !Array.isArray(values) && !DataArray.isDataArray(values))
Expand All @@ -484,8 +484,8 @@ export class DataviewApi {
createFixedListView(
{ app: this.app, settings: this.settings, index: this.index, container: subcontainer },
values as Literal[],
filePath
)
filePath,
),
);
}

Expand All @@ -495,7 +495,7 @@ export class DataviewApi {
values: any[][] | DataArray<any> | undefined,
container: HTMLElement,
component: Component,
filePath: string
filePath: string,
) {
if (!headers) headers = [];
if (!values) values = [];
Expand All @@ -508,8 +508,8 @@ export class DataviewApi {
{ app: this.app, settings: this.settings, index: this.index, container: subcontainer },
headers,
values as Literal[][],
filePath
)
filePath,
),
);
}

Expand All @@ -519,7 +519,7 @@ export class DataviewApi {
groupByFile: boolean = true,
container: HTMLElement,
component: Component,
filePath: string = ""
filePath: string = "",
) {
let groupedTasks =
!Groupings.isGrouping(tasks) && groupByFile ? this.array(tasks).groupBy(t => Link.file(t.path)) : tasks;
Expand All @@ -530,8 +530,8 @@ export class DataviewApi {
createFixedTaskView(
{ app: this.app, settings: this.settings, index: this.index, container: taskContainer },
groupedTasks as Grouping<SListItem>,
filePath
)
filePath,
),
);
}

Expand All @@ -541,7 +541,7 @@ export class DataviewApi {
container: HTMLElement,
component: Component,
filePath: string,
inline: boolean = false
inline: boolean = false,
) {
return renderValue(this.app, value as Literal, container, filePath, component, this.settings, inline);
}
Expand All @@ -554,7 +554,7 @@ export class DataviewApi {
public markdownTable(
headers: string[] | undefined,
values: any[][] | DataArray<any> | undefined,
settings?: Partial<ExportSettings>
settings?: Partial<ExportSettings>,
): string {
if (!headers) headers = [];
if (!values) values = [];
Expand Down
4 changes: 2 additions & 2 deletions src/api/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export namespace Result {
export function flatMap2<T1, T2, O, E>(
first: Result<T1, E>,
second: Result<T2, E>,
f: (a: T1, b: T2) => Result<O, E>
f: (a: T1, b: T2) => Result<O, E>,
): Result<O, E> {
if (first.successful) {
if (second.successful) return f(first.value, second.value);
Expand All @@ -105,7 +105,7 @@ export namespace Result {
export function map2<T1, T2, O, E>(
first: Result<T1, E>,
second: Result<T2, E>,
f: (a: T1, b: T2) => O
f: (a: T1, b: T2) => O,
): Result<O, E> {
return flatMap2(first, second, (a, b) => success(f(a, b)));
}
Expand Down
4 changes: 2 additions & 2 deletions src/data-import/inline-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function findClosing(
line: string,
start: number,
open: string,
close: string
close: string,
): { value: string; endIndex: number } | undefined {
let nesting = 0;
let escaped = false;
Expand Down Expand Up @@ -151,7 +151,7 @@ export function extractInlineFields(line: string, includeTaskFields: boolean = f
/** Validates that a raw field name has a valid form. */
const FULL_LINE_KEY_PART: P.Parser<string> = P.alt(
P.regexp(new RegExp(emojiRegex(), "u")),
P.regexp(/[0-9\p{Letter}\w\s_/-]+/u)
P.regexp(/[0-9\p{Letter}\w\s_/-]+/u),
)
.many()
.map(parts => parts.join(""));
Expand Down
6 changes: 3 additions & 3 deletions src/data-import/markdown-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function parseMarkdown(
path: string,
contents: string[],
metadata: CachedMetadata,
linksByLine: Record<number, Link[]>
linksByLine: Record<number, Link[]>,
): { fields: Map<string, Literal[]>; lists: ListItem[] } {
let fields: Map<string, Literal[]> = new Map();

Expand Down Expand Up @@ -190,7 +190,7 @@ export function parseLists(
path: string,
content: string[],
metadata: CachedMetadata,
linksByLine: Record<number, Link[]>
linksByLine: Record<number, Link[]>,
): [ListItem[], Map<string, Literal[]>] {
let cache: Record<number, ListItem> = {};

Expand All @@ -212,7 +212,7 @@ export function parseLists(
s =>
s.type == "list" &&
s.position.start.line <= rawElement.position.start.line &&
s.position.end.line >= rawElement.position.start.line
s.position.end.line >= rawElement.position.start.line,
);

// Find the section we belong to as well.
Expand Down
2 changes: 1 addition & 1 deletion src/data-import/web-worker/import-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function runImport(
path: string,
contents: string,
stats: FileStats,
metadata: CachedMetadata
metadata: CachedMetadata,
): Partial<PageMetadata> {
return parsePage(path, contents, stats, metadata);
}
2 changes: 1 addition & 1 deletion src/data-import/web-worker/import-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class FileImporter extends Component {
contents: c,
stat: file.stat,
metadata: this.metadataCache.getFileCache(file),
})
}),
);
}

Expand Down
10 changes: 5 additions & 5 deletions src/data-index/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class FullIndex extends Component {

this.touch();
this.trigger("delete", file);
})
}),
);

// Asynchronously initialize actual content in the background.
Expand Down Expand Up @@ -153,7 +153,7 @@ export class FullIndex extends Component {
console.log(
`Dataview: all ${files.length} files have been indexed in ${
(Date.now() - reloadStart) / 1000.0
}s (${cached} cached, ${skipped} skipped).`
}s (${cached} cached, ${skipped} skipped).`,
);

// Drop keys for files which do not exist anymore.
Expand Down Expand Up @@ -320,13 +320,13 @@ export class CsvCache extends Component {
this.registerEvent(
this.vault.on("modify", file => {
if (file instanceof TFile && PathFilters.csv(file.path)) this.cache.delete(file.path);
})
}),
);

this.registerEvent(
this.vault.on("delete", file => {
if (file instanceof TFile && PathFilters.csv(file.path)) this.cache.delete(file.path);
})
}),
);
}

Expand Down Expand Up @@ -444,7 +444,7 @@ export class StarredCache extends Component {
items = flattenItems(items);

return new Set(
items.filter((l): l is { type: "file"; path: string; title: string } => l.type === "file").map(l => l.path)
items.filter((l): l is { type: "file"; path: string; title: string } => l.type === "file").map(l => l.path),
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/data-index/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type Datarow<T> = { id: Literal; data: T };
export function matchingSourcePaths(
source: Source,
index: FullIndex,
originFile: string = ""
originFile: string = "",
): Result<Set<string>, string> {
switch (source.type) {
case "empty":
Expand Down Expand Up @@ -77,7 +77,7 @@ export function matchingSourcePaths(
} else {
return Result.failure(`Unrecognized operator '${source.op}'.`);
}
}
},
);
case "negate":
return matchingSourcePaths(source.child, index, originFile).map(child => {
Expand Down Expand Up @@ -127,7 +127,7 @@ export function resolveMarkdownData(path: string, index: FullIndex): Result<Data
export async function resolveSource(
source: Source,
index: FullIndex,
originFile: string = ""
originFile: string = "",
): Promise<Result<Datarow<DataObject>[], string>> {
let paths = matchingSourcePaths(source, index, originFile);
if (!paths.successful) return Result.failure(paths.error);
Expand Down
Loading

0 comments on commit 15f3fa0

Please sign in to comment.