use eslint auto fix
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
// @ts-nocheck
|
||||
import { cloneDeep, each, get, has, isArray, isEqual, isNumber, isObject, isString, set, unset } from "lodash";
|
||||
import * as mm from "micromatch";
|
||||
import { err, ok, Result } from "neverthrow";
|
||||
import { z, ZodError, ZodIssueCode, ZodType } from 'zod';
|
||||
import { Result, err, ok } from "neverthrow";
|
||||
import { ZodError, ZodIssueCode, ZodType, z } from 'zod';
|
||||
|
||||
import { DEFAULT_SETTINGS, PluginData, Settings } from "../settings/versions";
|
||||
import { isSettingsV0, isSettingsV1, migrateFromV0ToV1 } from "../settings/versions/migration";
|
||||
@@ -77,7 +77,7 @@ function replaceValueWithDefaultValue<V, T>(
|
||||
paths: string[],
|
||||
defaultValue: T,
|
||||
): V {
|
||||
const result = cloneDeep(value) as any;
|
||||
const result = cloneDeep(value);
|
||||
paths.forEach(path => {
|
||||
const originalValue = has(defaultValue, path) ? get(defaultValue, path) : undefined;
|
||||
set(result, path, originalValue);
|
||||
@@ -100,7 +100,7 @@ function removeUnrecognizedKeys(value: JSONObject | null | undefined, error: Zod
|
||||
// Array path will be handled separately by the value replacement function
|
||||
.filter(issue => !isAnArrayPath(issue.path))
|
||||
.flatMap(issue => {
|
||||
// @ts-ignore
|
||||
// @ts-expect-error
|
||||
const keys = issue.keys;
|
||||
return keys.map(key => [...issue.path, key].join('.'));
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ export function parseImageDataUrl(dataUrl: string): {
|
||||
mimeType: string
|
||||
base64Data: string
|
||||
} {
|
||||
const matches = dataUrl.match(/^data:([^;]+);base64,(.+)/)
|
||||
const matches = /^data:([^;]+);base64,(.+)/.exec(dataUrl)
|
||||
if (!matches) {
|
||||
throw new Error('Invalid image data URL format')
|
||||
}
|
||||
|
||||
@@ -4,55 +4,59 @@ import { calculateFileDistance } from './obsidian'
|
||||
|
||||
describe('calculateFileDistance', () => {
|
||||
// Mock TFile class
|
||||
class MockTFile {
|
||||
class MockTFile extends TFile {
|
||||
path: string
|
||||
constructor(path: string) {
|
||||
super()
|
||||
this.path = path
|
||||
}
|
||||
}
|
||||
|
||||
it('should calculate the correct distance between files in the same folder', () => {
|
||||
const file1 = new MockTFile('folder/file1.md') as TFile
|
||||
const file2 = new MockTFile('folder/file2.md') as TFile
|
||||
const file1 = new MockTFile('folder/file1.md')
|
||||
const file2 = new MockTFile('folder/file2.md')
|
||||
|
||||
const result = calculateFileDistance(file1, file2)
|
||||
expect(result).toBe(2)
|
||||
})
|
||||
|
||||
it('should calculate the correct distance between files in different subfolders', () => {
|
||||
const file1 = new MockTFile('folder1/folder2/file1.md') as TFile
|
||||
const file2 = new MockTFile('folder1/folder3/file2.md') as TFile
|
||||
const file1 = new MockTFile('folder1/folder2/file1.md')
|
||||
const file2 = new MockTFile('folder1/folder3/file2.md')
|
||||
|
||||
const result = calculateFileDistance(file1, file2)
|
||||
expect(result).toBe(4)
|
||||
})
|
||||
|
||||
it('should return null for files in different top-level folders', () => {
|
||||
const file1 = new MockTFile('folder1/file1.md') as TFile
|
||||
const file2 = new MockTFile('folder2/file2.md') as TFile
|
||||
const file1 = new MockTFile('folder1/file1.md')
|
||||
const file2 = new MockTFile('folder2/file2.md')
|
||||
|
||||
const result = calculateFileDistance(file1, file2)
|
||||
expect(result).toBeNull()
|
||||
})
|
||||
|
||||
it('should handle files at different depths', () => {
|
||||
const file1 = new MockTFile('folder1/folder2/subfolder/file1.md') as TFile
|
||||
const file2 = new MockTFile('folder1/folder3/file2.md') as TFile
|
||||
const file1 = new MockTFile('folder1/folder2/subfolder/file1.md')
|
||||
const file2 = new MockTFile('folder1/folder3/file2.md')
|
||||
|
||||
const result = calculateFileDistance(file1, file2)
|
||||
expect(result).toBe(5)
|
||||
})
|
||||
|
||||
it('should return 0 for the same file', () => {
|
||||
const file = new MockTFile('folder/file.md') as TFile
|
||||
const file = new MockTFile('folder/file.md')
|
||||
|
||||
const result = calculateFileDistance(file, file)
|
||||
expect(result).toBe(0)
|
||||
})
|
||||
|
||||
it('should calculate the correct distance between a folder and a file', () => {
|
||||
const file = new MockTFile('folder1/folder2/file1.md') as TFile
|
||||
const folder = new MockTFile('folder1/folder2') as TFolder
|
||||
const file = new MockTFile('folder1/folder2/file1.md')
|
||||
const folder = new MockTFile('folder1/folder2')
|
||||
if (!(folder instanceof TFolder)) {
|
||||
throw new Error('Expected folder to be a TFolder instance')
|
||||
}
|
||||
|
||||
const result = calculateFileDistance(file, folder)
|
||||
expect(result).toBe(1)
|
||||
|
||||
@@ -98,7 +98,7 @@ export class YoutubeTranscript {
|
||||
const videoPageBody = videoPageResponse.text
|
||||
|
||||
// Extract title using regex from <title> tags
|
||||
const titleMatch = videoPageBody.match(/<title>(.*?)<\/title>/)
|
||||
const titleMatch = /<title>(.*?)<\/title>/.exec(videoPageBody)
|
||||
const title = titleMatch
|
||||
? titleMatch[1].replace(' - YouTube', '').trim()
|
||||
: ''
|
||||
@@ -189,7 +189,7 @@ export class YoutubeTranscript {
|
||||
if (videoId.length === 11) {
|
||||
return videoId
|
||||
}
|
||||
const matchId = videoId.match(RE_YOUTUBE)
|
||||
const matchId = RE_YOUTUBE.exec(videoId)
|
||||
if (matchId?.length) {
|
||||
return matchId[1]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user