chore(prettier): fix all files

This commit is contained in:
Elian Doran
2025-01-09 18:07:02 +02:00
parent 19ee861699
commit 4cbb529fd4
571 changed files with 23226 additions and 23940 deletions

View File

@@ -7,12 +7,12 @@ import BAttribute from "../becca/entities/battribute.js";
import attributeFormatter from "./attribute_formatter.js";
import BUILTIN_ATTRIBUTES from "./builtin_attributes.js";
import BNote from "../becca/entities/bnote.js";
import { AttributeRow } from '../becca/entities/rows.js';
import { AttributeRow } from "../becca/entities/rows.js";
const ATTRIBUTE_TYPES = new Set(['label', 'relation']);
const ATTRIBUTE_TYPES = new Set(["label", "relation"]);
function getNotesWithLabel(name: string, value?: string): BNote[] {
const query = attributeFormatter.formatAttrForSearch({type: 'label', name, value}, value !== undefined);
const query = attributeFormatter.formatAttrForSearch({ type: "label", name, value }, value !== undefined);
return searchService.searchNotes(query, {
includeArchivedNotes: true,
ignoreHoistedNote: true
@@ -22,7 +22,7 @@ function getNotesWithLabel(name: string, value?: string): BNote[] {
// TODO: should be in search service
function getNoteWithLabel(name: string, value?: string): BNote | null {
// optimized version (~20 times faster) without using normal search, useful for e.g., finding date notes
const attrs = becca.findAttributes('label', name);
const attrs = becca.findAttributes("label", name);
if (value === undefined) {
return attrs[0]?.getNote();
@@ -42,7 +42,7 @@ function getNoteWithLabel(name: string, value?: string): BNote | null {
function createLabel(noteId: string, name: string, value: string = "") {
return createAttribute({
noteId: noteId,
type: 'label',
type: "label",
name: name,
value: value
});
@@ -51,7 +51,7 @@ function createLabel(noteId: string, name: string, value: string = "") {
function createRelation(noteId: string, name: string, targetNoteId: string) {
return createAttribute({
noteId: noteId,
type: 'relation',
type: "relation",
name: name,
value: targetNoteId
});
@@ -69,7 +69,9 @@ function getAttributeNames(type: string, nameLike: string) {
FROM attributes
WHERE isDeleted = 0
AND type = ?
AND name LIKE ?`, [type, `%${nameLike}%`]);
AND name LIKE ?`,
[type, `%${nameLike}%`]
);
for (const attr of BUILTIN_ATTRIBUTES) {
if (attr.type === type && attr.name.toLowerCase().includes(nameLike) && !names.includes(attr.name)) {
@@ -77,12 +79,7 @@ function getAttributeNames(type: string, nameLike: string) {
}
}
names = names.filter(name => ![
'internalLink',
'imageLink',
'includeNoteLink',
'relationMapLink'
].includes(name));
names = names.filter((name) => !["internalLink", "imageLink", "includeNoteLink", "relationMapLink"].includes(name));
names.sort((a, b) => {
const aPrefix = a.toLowerCase().startsWith(nameLike);
@@ -103,11 +100,7 @@ function isAttributeType(type: string): boolean {
}
function isAttributeDangerous(type: string, name: string): boolean {
return BUILTIN_ATTRIBUTES.some(attr =>
attr.type === type &&
attr.name.toLowerCase() === name.trim().toLowerCase() &&
attr.isDangerous
);
return BUILTIN_ATTRIBUTES.some((attr) => attr.type === type && attr.name.toLowerCase() === name.trim().toLowerCase() && attr.isDangerous);
}
export default {