Skip to content

Commit

Permalink
Turned single quote to false in prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Marius Svarverud committed Sep 5, 2024
1 parent 49f96a2 commit d8605af
Show file tree
Hide file tree
Showing 46 changed files with 626 additions and 626 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Bug report
about: Create a report to help us identify and fix bugs
title: ''
title: ""
labels: bug, enhancement
assignees: Rudtrack
---
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/documentation.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Documentation
about: Report if documentation has errors, is lacking or missing for a feature
title: ''
title: ""
labels: documentation
assignees: Rudtrack
---
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Feature request
about: Suggest a new feature or idea for the plugin
title: ''
title: ""
labels: enhancement
assignees: Rudtrack
---
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release Obsidian plugin
on:
push:
tags:
- '*'
- "*"

jobs:
build:
Expand All @@ -15,7 +15,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
node-version: "18.x"

- name: Build plugin
run: |
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"semi": true,
"tabWidth": 2,
"printWidth": 100,
"singleQuote": true,
"singleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true,
"bracketSameLine": false,
Expand Down
2 changes: 1 addition & 1 deletion __mocks__/nanoid.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function customAlphabet(alphabet: string, defaultSize?: number): (size?: number) => string {
return () => '';
return () => "";
}
2 changes: 1 addition & 1 deletion __mocks__/obsidian.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is required to exclude obsidian package dependency from jest unit tests
import moment from 'moment';
import moment from "moment";

export { moment as moment };
50 changes: 25 additions & 25 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
import esbuild from 'esbuild';
import process from 'process';
import builtins from 'builtin-modules';
import esbuildSvelte from 'esbuild-svelte';
import sveltePreprocess from 'svelte-preprocess';
import esbuild from "esbuild";
import process from "process";
import builtins from "builtin-modules";
import esbuildSvelte from "esbuild-svelte";
import sveltePreprocess from "svelte-preprocess";

const banner = `/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
`;

const prod = process.argv[2] === 'production';
const prod = process.argv[2] === "production";

const context = await esbuild.context({
banner: {
js: banner,
},
entryPoints: ['./src/main.ts'],
entryPoints: ["./src/main.ts"],
bundle: true,
external: [
'obsidian',
'electron',
'@codemirror/autocomplete',
'@codemirror/collab',
'@codemirror/commands',
'@codemirror/language',
'@codemirror/lint',
'@codemirror/search',
'@codemirror/state',
'@codemirror/view',
'@lezer/common',
'@lezer/highlight',
'@lezer/lr',
"obsidian",
"electron",
"@codemirror/autocomplete",
"@codemirror/collab",
"@codemirror/commands",
"@codemirror/language",
"@codemirror/lint",
"@codemirror/search",
"@codemirror/state",
"@codemirror/view",
"@lezer/common",
"@lezer/highlight",
"@lezer/lr",
...builtins,
],
format: 'cjs',
target: 'es2018',
logLevel: 'info',
sourcemap: prod ? false : 'inline',
format: "cjs",
target: "es2018",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
plugins: [
esbuildSvelte({
compilerOptions: { css: true },
preprocess: sveltePreprocess(),
}),
],
outfile: 'main.js',
outfile: "main.js",
});

if (prod) {
Expand Down
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
preset: "ts-jest",
testEnvironment: "node",
};
72 changes: 36 additions & 36 deletions src/custom-graph/data-engine-render.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { App, GraphEngine, TFile } from 'obsidian';
import { Note } from 'src/engine/note';
import { StructuredVault } from 'src/engine/structuredVault';
import { StructuredWorkspace } from 'src/engine/structuredWorkspace';
import { isLocalGraphView } from './utils';
import { App, GraphEngine, TFile } from "obsidian";
import { Note } from "src/engine/note";
import { StructuredVault } from "src/engine/structuredVault";
import { StructuredWorkspace } from "src/engine/structuredWorkspace";
import { isLocalGraphView } from "./utils";

type StructuredGraphNode = {
file: TFile;
} & (
| {
type: 'note';
type: "note";
vault: StructuredVault;
note: Note;
}
| {
type: 'file';
type: "file";
}
);

function getGlobalNodes(
app: App,
workspace: StructuredWorkspace,
options: GraphEngine['options'],
options: GraphEngine["options"],
filterFile: (file: string, type: string) => boolean,
progression: number
) {
Expand All @@ -32,7 +32,7 @@ function getGlobalNodes(
.flatten()
.filter((note) => note.file)
.map((note) => ({
type: 'note',
type: "note",
vault,
file: note.file!,
note,
Expand All @@ -44,24 +44,24 @@ function getGlobalNodes(
...app.vault
.getFiles()
.filter((file) =>
file.extension === 'md' && file.parent ? !workspace.findVaultByParent(file.parent) : true
file.extension === "md" && file.parent ? !workspace.findVaultByParent(file.parent) : true
)
.map((file) => ({
type: 'file' as const,
type: "file" as const,
file,
}))
);

if (progression) {
const map = new Map<StructuredGraphNode, number>();
for (const structuredNode of structuredNodeList) {
if (structuredNode.type === 'file') {
if (structuredNode.type === "file") {
map.set(
structuredNode,
Math.min(structuredNode.file.stat.ctime, structuredNode.file.stat.mtime)
);
continue;
} else if (structuredNode.type === 'note') {
} else if (structuredNode.type === "note") {
const file = structuredNode.note.file;
if (!file) {
map.set(structuredNode, Infinity);
Expand All @@ -70,7 +70,7 @@ function getGlobalNodes(

if (!metadata) map.set(structuredNode, Infinity);
else {
const created = parseInt(metadata['created']);
const created = parseInt(metadata["created"]);
map.set(structuredNode, isNaN(created) ? Infinity : created);
}
}
Expand All @@ -81,12 +81,12 @@ function getGlobalNodes(

let stopFile: TFile | undefined = undefined;
for (const structuredNode of structuredNodeList) {
if (structuredNode.type === 'note') {
if (structuredNode.type === "note") {
const { note, vault } = structuredNode;
if (!filterFile(note.file?.path ?? '', '')) continue;
if (!filterFile(note.file?.path ?? "", "")) continue;

const node: any = {
type: '',
type: "",
links: {},
};
nodes[`structured://${vault.config.name}/${note.getPath()}`] = node;
Expand All @@ -105,22 +105,22 @@ function getGlobalNodes(
const listOfLinks = (meta.links ?? []).concat(meta.embeds ?? []);

for (const link of listOfLinks) {
const href = link.original.startsWith('[[')
? link.original.substring(2, link.original.length - 2).split('|', 2)[0]
const href = link.original.startsWith("[[")
? link.original.substring(2, link.original.length - 2).split("|", 2)[0]
: link.link;
const target = workspace.resolveRef(note.file.path, href);
if (target?.type === 'maybe-note') {
if (target?.type === "maybe-note") {
const linkName = `structured://${target.vaultName}/${target.path}`.toLowerCase();
if (!progression || numLinks < progression) {
if (!target.note?.file) {
if (!filterFile(target.note?.file?.path ?? '', 'unresolved')) continue;
if (!filterFile(target.note?.file?.path ?? "", "unresolved")) continue;
if (options.hideUnresolved) continue;
nodes[linkName] = {
type: 'unresolved',
type: "unresolved",
links: {},
};
} else {
if (!filterFile(target.note?.file?.path ?? '', '')) continue;
if (!filterFile(target.note?.file?.path ?? "", "")) continue;
}

node.links[linkName] = true;
Expand All @@ -144,7 +144,7 @@ function getGlobalNodes(
numLinks++;
}
}
} else if (structuredNode.type === 'file') {
} else if (structuredNode.type === "file") {
const linkName = structuredNode.file.path;
if (options.showOrphans) {
if (progression && progression === numLinks) {
Expand All @@ -154,11 +154,11 @@ function getGlobalNodes(
}

const node: any = {
type: 'attachment',
type: "attachment",
links: {},
};

if (!filterFile(linkName, 'attachment')) continue;
if (!filterFile(linkName, "attachment")) continue;
nodes[linkName] = node;
}
}
Expand All @@ -170,7 +170,7 @@ function getGlobalNodes(
const structuredNode = structuredNodeList[i];

const p =
structuredNode.type === 'note'
structuredNode.type === "note"
? `structured://${structuredNode.vault.config.name}/${structuredNode.note.getPath()}`
: structuredNode.file.path;
if (!nodes[p]) {
Expand All @@ -190,8 +190,8 @@ function getGlobalNodes(
function getLocalNodes(
app: App,
workspace: StructuredWorkspace,
options: GraphEngine['options'],
globalNodes: ReturnType<typeof getGlobalNodes>['nodes']
options: GraphEngine["options"],
globalNodes: ReturnType<typeof getGlobalNodes>["nodes"]
) {
const localNodes: Record<string, any> = {};
const localWeights: Record<string, number> = {};
Expand All @@ -203,14 +203,14 @@ function getLocalNodes(
const file = app.vault.getAbstractFileByPath(options.localFile);

if (!(file instanceof TFile) || !file.parent) {
console.log('error');
console.log("error");
return result;
}

const vault = workspace.findVaultByParent(file.parent);

if (!vault) {
console.log('error vault not found');
console.log("error vault not found");
return result;
}

Expand All @@ -220,7 +220,7 @@ function getLocalNodes(
if (!globalNodes[localFileDPath]) {
localNodes[localFileDPath] = {
links: {},
type: '',
type: "",
};
return result;
}
Expand All @@ -235,7 +235,7 @@ function getLocalNodes(
const t: Record<string, any> = {};
for (const nodeName of Object.keys(globalNodes)) {
const node = globalNodes[nodeName];
if ('tag' === node.type) continue;
if ("tag" === node.type) continue;

for (const linkName of Object.keys(node.links)) {
if (options.localForelinks && localNodes[nodeName] && !localNodes[linkName]) {
Expand Down Expand Up @@ -284,7 +284,7 @@ function getLocalNodes(
export function createDataEngineRender(
app: App,
workspace: StructuredWorkspace
): GraphEngine['render'] {
): GraphEngine["render"] {
return function (this: GraphEngine) {
const isLocalGraph = isLocalGraphView(this.view);
if (isLocalGraph && !this.options.localFile) {
Expand All @@ -299,10 +299,10 @@ export function createDataEngineRender(
if (!this.searchQueries) {
return true;
}
if ('' === nodeType) {
if ("" === nodeType) {
return this.fileFilter.hasOwnProperty(file) ? this.fileFilter[file] : !this.hasFilter;
}
if ('attachment' !== nodeType) return true;
if ("attachment" !== nodeType) return true;
return this.searchQueries.every(function (query) {
return !!query.color || !!query.query.matchFilepath(file);
});
Expand Down
Loading

0 comments on commit d8605af

Please sign in to comment.