Skip to content

Commit

Permalink
fix(core): remove eslint config and fix errors (#1457)
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick-Erichsen authored Jun 10, 2024
1 parent cf88f31 commit 3e1c06b
Show file tree
Hide file tree
Showing 20 changed files with 61 additions and 84 deletions.
14 changes: 2 additions & 12 deletions core/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,10 @@
"ecmaVersion": 6,
"sourceType": "module"
},
"extends": ["plugin:require-extensions/recommended"],
"plugins": ["@typescript-eslint", "import", "require-extensions"],
"plugins": ["@typescript-eslint", "import"],
"rules": {
"quotes": ["warn", "double", {}],
"import/extensions": [
"error",
"always",
{
"js": "never",
"jsx": "never",
"ts": "never",
"tsx": "never"
}
],
"import/extensions": ["error", "ignorePackages"],
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/semi": "warn",
"curly": "warn",
Expand Down
2 changes: 1 addition & 1 deletion core/autocomplete/languages.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LineFilter } from "./lineStream";
import type { LineFilter } from "./lineStream";

export interface AutocompleteLanguageInfo {
topLevelKeywords: string[];
Expand Down
2 changes: 1 addition & 1 deletion core/autocomplete/postprocessing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ILLM } from "..";
import type { ILLM } from "..";

export function postprocessCompletion({
completion,
Expand Down
8 changes: 4 additions & 4 deletions core/config/promptFile.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { IDE, SlashCommand } from "..";
import * as YAML from "yaml";
import { IDE, SlashCommand } from "..";
import { stripImages } from "../llm/countTokens";
import { renderTemplatedString } from "../llm/llms";
import { getBasename } from "../util";
import { stripImages } from "../llm/countTokens.js";
import { renderTemplatedString } from "../llm/llms/index.js";
import { getBasename } from "../util/index.js";

export async function getPromptFiles(
ide: IDE,
Expand Down
4 changes: 2 additions & 2 deletions core/context/providers/DocsContextProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DocsContextProvider extends BaseContextProvider {
);
}

const { retrieveDocs } = await import("../../indexing/docs/db");
const { retrieveDocs } = await import("../../indexing/docs/db.js");
const embeddingsProvider = new TransformersJsEmbeddingsProvider();
const [vector] = await embeddingsProvider.embed([extras.fullInput]);

Expand Down Expand Up @@ -88,7 +88,7 @@ class DocsContextProvider extends BaseContextProvider {
async loadSubmenuItems(
args: LoadSubmenuItemsArgs,
): Promise<ContextSubmenuItem[]> {
const { listDocs } = await import("../../indexing/docs/db");
const { listDocs } = await import("../../indexing/docs/db.js");
const docs = await listDocs();
const submenuItems = docs.map((doc) => ({
title: doc.title,
Expand Down
2 changes: 1 addition & 1 deletion core/context/providers/FolderContextProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FolderContextProvider extends BaseContextProvider {
extras: ContextProviderExtras,
): Promise<ContextItem[]> {
const { retrieveContextItemsFromEmbeddings } = await import(
"../retrieval/retrieval"
"../retrieval/retrieval.js"
);
return retrieveContextItemsFromEmbeddings(extras, this.options, query);
}
Expand Down
58 changes: 30 additions & 28 deletions core/core.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import { v4 as uuidv4 } from "uuid";
import {
import type {
ContextItemId,
IDE,
IndexingProgressUpdate,
SiteIndexingConfig,
} from ".";
import { CompletionProvider } from "./autocomplete/completionProvider";
import { ConfigHandler } from "./config/handler";
import type { FromCoreProtocol, ToCoreProtocol } from "./protocol";
import type { IMessenger, Message } from "./util/messenger";
import { v4 as uuidv4 } from "uuid";
import { CompletionProvider } from "./autocomplete/completionProvider.js";
import { ConfigHandler } from "./config/handler.js";
import {
setupApiKeysMode,
setupFreeTrialMode,
setupLocalAfterFreeTrial,
setupLocalMode,
setupOptimizedExistingUserMode,
} from "./config/onboarding";
import { addModel, addOpenAIKey, deleteModel } from "./config/util";
import { ContinueServerClient } from "./continueServer/stubs/client";
import { indexDocs } from "./indexing/docs";
import TransformersJsEmbeddingsProvider from "./indexing/embeddings/TransformersJsEmbeddingsProvider";
import { CodebaseIndexer, PauseToken } from "./indexing/indexCodebase";
import Ollama from "./llm/llms/Ollama";
import { FromCoreProtocol, ToCoreProtocol } from "./protocol";
import { GlobalContext } from "./util/GlobalContext";
import { logDevData } from "./util/devdata";
import { DevDataSqliteDb } from "./util/devdataSqlite";
import { fetchwithRequestOptions } from "./util/fetchWithOptions";
import historyManager from "./util/history";
import type { IMessenger, Message } from "./util/messenger";
import { editConfigJson, getConfigJsonPath } from "./util/paths";
import { Telemetry } from "./util/posthog";
import { streamDiffLines } from "./util/verticalEdit";
} from "./config/onboarding.js";
import { addModel, addOpenAIKey, deleteModel } from "./config/util.js";
import { ContinueServerClient } from "./continueServer/stubs/client.js";
import { indexDocs } from "./indexing/docs/index.js";
import TransformersJsEmbeddingsProvider from "./indexing/embeddings/TransformersJsEmbeddingsProvider.js";
import { CodebaseIndexer, PauseToken } from "./indexing/indexCodebase.js";
import Ollama from "./llm/llms/Ollama.js";
import { GlobalContext } from "./util/GlobalContext.js";
import { logDevData } from "./util/devdata.js";
import { DevDataSqliteDb } from "./util/devdataSqlite.js";
import { fetchwithRequestOptions } from "./util/fetchWithOptions.js";
import historyManager from "./util/history.js";
import { editConfigJson, getConfigJsonPath } from "./util/paths.js";
import { Telemetry } from "./util/posthog.js";
import { streamDiffLines } from "./util/verticalEdit.js";

export class Core {
// implements IMessenger<ToCoreProtocol, FromCoreProtocol>
Expand Down Expand Up @@ -251,7 +251,9 @@ export class Core {
const provider = config.contextProviders?.find(
(provider) => provider.description.title === name,
);
if (!provider) return [];
if (!provider) {
return [];
}

try {
const id: ContextItemId = {
Expand Down Expand Up @@ -496,12 +498,12 @@ export class Core {
mode === "local"
? setupLocalMode
: mode === "freeTrial"
? setupFreeTrialMode
: mode === "localAfterFreeTrial"
? setupLocalAfterFreeTrial
: mode === "apiKeys"
? setupApiKeysMode
: setupOptimizedExistingUserMode,
? setupFreeTrialMode
: mode === "localAfterFreeTrial"
? setupLocalAfterFreeTrial
: mode === "apiKeys"
? setupApiKeysMode
: setupOptimizedExistingUserMode,
);
this.configHandler.reloadConfig();
});
Expand Down
2 changes: 1 addition & 1 deletion core/llm/llms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Replicate from "./Replicate.js";
import TextGenWebUI from "./TextGenWebUI.js";
import Together from "./Together.js";
import ContinueProxy from "./stubs/ContinueProxy.js";
import Cloudflare from "./Cloudflare";
import Cloudflare from "./Cloudflare.js";

function convertToLetter(num: number): string {
let result = "";
Expand Down
4 changes: 2 additions & 2 deletions core/llm/llms/stubs/ContinueProxy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LLMOptions, ModelProvider } from "../../..";
import OpenAI from "../OpenAI";
import type { LLMOptions, ModelProvider } from "../../..";
import OpenAI from "../OpenAI.js";

class ContinueProxy extends OpenAI {
static providerName: ModelProvider = "continue-proxy";
Expand Down
13 changes: 0 additions & 13 deletions core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"esbuild": "0.17.19",
"eslint": "^8",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-require-extensions": "^0.1.3",
"jest": "^29.7.0",
"onnxruntime-common": "1.14.0",
"onnxruntime-web": "1.14.0",
Expand Down
6 changes: 3 additions & 3 deletions core/protocol/core.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
BrowserSerializedContinueConfig,
ChatMessage,
ContextItemWithId,
Expand All @@ -13,8 +13,8 @@ import {
SessionInfo,
SiteIndexingConfig,
} from "..";
import { AutocompleteInput } from "../autocomplete/completionProvider";
import { IdeSettings } from "./ideWebview";
import type { AutocompleteInput } from "../autocomplete/completionProvider";
import type { IdeSettings } from "./ideWebview";

export type ProtocolGeneratorType<T> = AsyncGenerator<{
done?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions core/protocol/coreWebview.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ToCoreFromIdeOrWebviewProtocol } from "./core";
import { ToWebviewFromIdeOrCoreProtocol } from "./webview";
import { ToCoreFromIdeOrWebviewProtocol } from "./core.js";
import { ToWebviewFromIdeOrCoreProtocol } from "./webview.js";

export type ToCoreFromWebviewProtocol = ToCoreFromIdeOrWebviewProtocol;
export type ToWebviewFromCoreProtocol = ToWebviewFromIdeOrCoreProtocol;
4 changes: 2 additions & 2 deletions core/protocol/ide.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
ContinueRcJson,
DiffLine,
FileType,
Expand All @@ -8,7 +8,7 @@ import {
Range,
Thread,
} from "..";
import { IdeSettings } from "./ideWebview";
import type { IdeSettings } from "./ideWebview";

export type ToIdeFromWebviewOrCoreProtocol = {
// Methods from IDE type
Expand Down
4 changes: 2 additions & 2 deletions core/protocol/ideCore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ToCoreFromIdeOrWebviewProtocol } from "./core";
import { ToIdeFromWebviewOrCoreProtocol } from "./ide";
import { ToCoreFromIdeOrWebviewProtocol } from "./core.js";
import { ToIdeFromWebviewOrCoreProtocol } from "./ide.js";

export type ToIdeFromCoreProtocol = ToIdeFromWebviewOrCoreProtocol;
export type ToCoreFromIdeProtocol = ToCoreFromIdeOrWebviewProtocol;
4 changes: 2 additions & 2 deletions core/protocol/ideWebview.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ContextItemWithId, ContextSubmenuItem } from "..";
import type { RangeInFileWithContents } from "../commands/util";
import { ToIdeFromWebviewOrCoreProtocol } from "./ide";
import { ToWebviewFromIdeOrCoreProtocol } from "./webview";
import { ToIdeFromWebviewOrCoreProtocol } from "./ide.js";
import { ToWebviewFromIdeOrCoreProtocol } from "./webview.js";

export interface IdeSettings {
remoteConfigServerUrl: string | undefined;
Expand Down
6 changes: 3 additions & 3 deletions core/protocol/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
ToCoreFromWebviewProtocol,
ToWebviewFromCoreProtocol,
} from "./coreWebview";
import { ToCoreFromIdeProtocol, ToIdeFromCoreProtocol } from "./ideCore";
} from "./coreWebview.js";
import { ToCoreFromIdeProtocol, ToIdeFromCoreProtocol } from "./ideCore.js";
import {
ToIdeFromWebviewProtocol,
ToWebviewFromIdeProtocol,
} from "./ideWebview";
} from "./ideWebview.js";

export type IProtocol = Record<string, [any, any]>;

Expand Down
2 changes: 1 addition & 1 deletion core/protocol/passThrough.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
ToCoreFromWebviewProtocol,
ToWebviewFromCoreProtocol,
} from "./coreWebview";
} from "./coreWebview.js";

// Message types to pass through from webview to core
export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
Expand Down
2 changes: 1 addition & 1 deletion core/protocol/webview.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IndexingProgressUpdate } from "..";
import type { IndexingProgressUpdate } from "..";

export type ToWebviewFromIdeOrCoreProtocol = {
configUpdate: [undefined, void];
Expand Down
3 changes: 1 addition & 2 deletions core/util/GlobalContext.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import fs from "node:fs";
import { getGlobalContextFilePath } from "./paths";
import { IndexingProgressUpdate } from "..";
import { getGlobalContextFilePath } from "./paths.js";

export type GlobalContextType = {
indexingPaused: boolean;
Expand Down

0 comments on commit 3e1c06b

Please sign in to comment.