use eslint auto fix
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import * as Handlebars from "handlebars";
|
||||
import { err, ok, Result } from "neverthrow";
|
||||
import { Result, err, ok } from "neverthrow";
|
||||
|
||||
import { FewShotExample } from "../../settings/versions";
|
||||
import { CustomLLMModel } from "../../types/llm/model";
|
||||
|
||||
@@ -90,7 +90,7 @@ function startLocationOfEachWord(text: string): number[] {
|
||||
}
|
||||
|
||||
function isWhiteSpaceChar(char: string | undefined): boolean {
|
||||
return char !== undefined && char.match(/\s/) !== null;
|
||||
return char !== undefined && (/\s/.exec(char)) !== null;
|
||||
}
|
||||
|
||||
export default RemoveOverlap;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { generateRandomString } from "../utils";
|
||||
import Context from "../context-detection";
|
||||
import { PrefixAndSuffix, PreProcessor } from "../types";
|
||||
import { PreProcessor, PrefixAndSuffix } from "../types";
|
||||
import { generateRandomString } from "../utils";
|
||||
|
||||
const DATA_VIEW_REGEX = /```dataview(js){0,1}(.|\n)*?```/gm;
|
||||
const UNIQUE_CURSOR = `${generateRandomString(16)}`;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Context from "../context-detection";
|
||||
import { PrefixAndSuffix, PreProcessor } from "../types";
|
||||
import { PreProcessor, PrefixAndSuffix } from "../types";
|
||||
|
||||
class LengthLimiter implements PreProcessor {
|
||||
private readonly maxPrefixChars: number;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { TFile } from "obsidian";
|
||||
|
||||
import { InfioSettings } from "../../../types/settings";
|
||||
import { DocumentChanges } from "../../../render-plugin/document-changes-listener";
|
||||
import { InfioSettings } from "../../../types/settings";
|
||||
|
||||
import { EventHandler } from "./types";
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Notice } from "obsidian";
|
||||
|
||||
import Context from "../context-detection";
|
||||
import EventListener from "../../../event-listener";
|
||||
import { DocumentChanges } from "../../../render-plugin/document-changes-listener";
|
||||
import Context from "../context-detection";
|
||||
|
||||
import State from "./state";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Context from "../context-detection";
|
||||
import EventListener from "../../../event-listener";
|
||||
import { DocumentChanges } from "../../../render-plugin/document-changes-listener";
|
||||
import Context from "../context-detection";
|
||||
|
||||
import State from "./state";
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
|
||||
import { TFile } from "obsidian";
|
||||
|
||||
import { InfioSettings } from "../../../types/settings";
|
||||
import { DocumentChanges } from "../../../render-plugin/document-changes-listener";
|
||||
import { InfioSettings } from "../../../types/settings";
|
||||
|
||||
export interface EventHandler {
|
||||
export type EventHandler = {
|
||||
handleSettingChanged(settings: InfioSettings): void;
|
||||
|
||||
handleDocumentChange(documentChanges: DocumentChanges): Promise<void>;
|
||||
|
||||
@@ -2,14 +2,14 @@ import { Result } from "neverthrow";
|
||||
|
||||
import Context from "./context-detection";
|
||||
|
||||
export interface AutocompleteService {
|
||||
export type AutocompleteService = {
|
||||
fetchPredictions(
|
||||
prefix: string,
|
||||
suffix: string
|
||||
): Promise<Result<string, Error>>;
|
||||
}
|
||||
|
||||
export interface PostProcessor {
|
||||
export type PostProcessor = {
|
||||
process(
|
||||
prefix: string,
|
||||
suffix: string,
|
||||
@@ -18,23 +18,23 @@ export interface PostProcessor {
|
||||
): string;
|
||||
}
|
||||
|
||||
export interface PreProcessor {
|
||||
export type PreProcessor = {
|
||||
process(prefix: string, suffix: string, context: Context): PrefixAndSuffix;
|
||||
removesCursor(prefix: string, suffix: string): boolean;
|
||||
}
|
||||
|
||||
export interface PrefixAndSuffix {
|
||||
export type PrefixAndSuffix = {
|
||||
prefix: string;
|
||||
suffix: string;
|
||||
}
|
||||
|
||||
export interface ChatMessage {
|
||||
export type ChatMessage = {
|
||||
content: string;
|
||||
role: "user" | "assistant" | "system";
|
||||
}
|
||||
|
||||
|
||||
export interface UserMessageFormattingInputs {
|
||||
export type UserMessageFormattingInputs = {
|
||||
prefix: string;
|
||||
suffix: string;
|
||||
}
|
||||
@@ -43,12 +43,12 @@ export type UserMessageFormatter = (
|
||||
inputs: UserMessageFormattingInputs
|
||||
) => string;
|
||||
|
||||
export interface ApiClient {
|
||||
export type ApiClient = {
|
||||
queryChatModel(messages: ChatMessage[]): Promise<Result<string, Error>>;
|
||||
checkIfConfiguredCorrectly?(): Promise<string[]>;
|
||||
}
|
||||
|
||||
export interface ModelOptions {
|
||||
export type ModelOptions = {
|
||||
temperature: number;
|
||||
top_p: number;
|
||||
frequency_penalty: number;
|
||||
|
||||
@@ -40,7 +40,7 @@ export function isMatchBetweenPathAndPatterns(
|
||||
}
|
||||
|
||||
export function extractNextWordAndRemaining(suggestion: string): [string | undefined, string | undefined] {
|
||||
const leadingWhitespacesMatch = suggestion.match(/^(\s*)/);
|
||||
const leadingWhitespacesMatch = /^(\s*)/.exec(suggestion);
|
||||
const leadingWhitespaces = leadingWhitespacesMatch ? leadingWhitespacesMatch[0] : '';
|
||||
const trimmedSuggestion = suggestion.slice(leadingWhitespaces.length);
|
||||
|
||||
@@ -48,11 +48,11 @@ export function extractNextWordAndRemaining(suggestion: string): [string | undef
|
||||
let nextWord: string | undefined;
|
||||
let remaining: string | undefined = undefined;
|
||||
|
||||
const whitespaceAfterNextWordMatch = trimmedSuggestion.match(/\s+/);
|
||||
const whitespaceAfterNextWordMatch = /\s+/.exec(trimmedSuggestion);
|
||||
if (!whitespaceAfterNextWordMatch) {
|
||||
nextWord = trimmedSuggestion || undefined;
|
||||
} else {
|
||||
const whitespaceAfterNextWordStartingIndex = whitespaceAfterNextWordMatch.index!;
|
||||
const whitespaceAfterNextWordStartingIndex = whitespaceAfterNextWordMatch.index;
|
||||
const whitespaceAfterNextWord = whitespaceAfterNextWordMatch[0];
|
||||
const whitespaceLength = whitespaceAfterNextWord.length;
|
||||
const startOfWhitespaceAfterNextWordIndex = whitespaceAfterNextWordStartingIndex + whitespaceLength;
|
||||
|
||||
Reference in New Issue
Block a user