Skip to content

Commit 6374b4d

Browse files
Merge pull request #2027 from continuedev/pe/core-eslint-fixes
chore: turn off `naming-convention`
2 parents ac68bec + e94c399 commit 6374b4d

21 files changed

+51
-41
lines changed

core/.eslintrc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"plugins": ["@typescript-eslint", "import"],
99
"rules": {
1010
"quotes": ["warn", "double", {}],
11-
"@typescript-eslint/naming-convention": "warn",
11+
"@typescript-eslint/naming-convention": "off",
1212
"@typescript-eslint/semi": "warn",
1313
"curly": "warn",
1414
"eqeqeq": "warn",

core/autocomplete/brackets.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ export class BracketMatchingService {
8484
// Add corresponding open brackets from suffix to stack
8585
// because we overwrite them and the diff is displayed, and this allows something to be edited after that
8686
for (let i = 0; i < suffix.length; i++) {
87-
if (suffix[i] === " ") continue;
87+
if (suffix[i] === " ") {continue;}
8888
const openBracket = BracketMatchingService.BRACKETS_REVERSE[suffix[i]];
89-
if (!openBracket) break;
89+
if (!openBracket) {break;}
9090
stack.unshift(openBracket);
9191
}
9292

core/autocomplete/languages.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const Python = {
2626
name: "Python",
2727
// """"#" is for .ipynb files, where we add '"""' surrounding markdown blocks.
2828
// This stops the model from trying to complete the start of a new markdown block
29-
topLevelKeywords: ["def", "class", '"""#'],
29+
topLevelKeywords: ["def", "class", "\"\"\"#"],
3030
singleLineComment: "#",
3131
endOfLine: [],
3232
};

core/autocomplete/templates.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ const codestralMultifileFimTemplate: AutocompleteTemplate = {
7070
.map((snippet, i) => `+++++ ${relativePaths[i]}\n${snippet.contents}`)
7171
.join("\n\n");
7272
return [
73-
`${otherFiles}\n\n+++++ ${relativePaths[relativePaths.length - 1]}\n${prefix}`,
73+
`${otherFiles}\n\n+++++ ${
74+
relativePaths[relativePaths.length - 1]
75+
}\n${prefix}`,
7476
suffix,
7577
];
7678
},
@@ -172,8 +174,10 @@ const codegeexFimTemplate: AutocompleteTemplate = {
172174
...snippets.map((snippet) => snippet.filepath),
173175
filepath,
174176
]);
175-
const baseTemplate = `###PATH:${relativePaths[relativePaths.length - 1]}\n###LANGUAGE:${language}\n###MODE:BLOCK\n<|code_suffix|>${suffix}<|code_prefix|>${prefix}<|code_middle|>`;
176-
if (snippets.length == 0) {
177+
const baseTemplate = `###PATH:${
178+
relativePaths[relativePaths.length - 1]
179+
}\n###LANGUAGE:${language}\n###MODE:BLOCK\n<|code_suffix|>${suffix}<|code_prefix|>${prefix}<|code_middle|>`;
180+
if (snippets.length === 0) {
177181
return `<|user|>\n${baseTemplate}<|assistant|>\n`;
178182
}
179183
const references = `###REFERENCE:\n${snippets

core/context/providers/PostgresContextProvider.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class PostgresContextProvider extends BaseContextProvider {
3737
let tablesInfoQuery = `
3838
SELECT table_schema, table_name
3939
FROM information_schema.tables`;
40-
if (schema != null) {
40+
if (schema !== null) {
4141
tablesInfoQuery += ` WHERE table_schema = '${schema}'`;
4242
}
4343
const { rows: tablesInfo } = await pool.query(tablesInfoQuery);

core/context/rerankers/tei.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class HuggingFaceTEIReranker implements Reranker {
2626

2727
const resp = await fetch(new URL("rerank", apiBase), {
2828
method: "POST",
29-
headers: { 'Content-Type': 'application/json' },
29+
headers: { "Content-Type": "application/json" },
3030
body: JSON.stringify({
3131
query: query,
3232
return_text: false,

core/control-plane/client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class ControlPlaneClient {
7474
}
7575

7676
try {
77-
const resp = await this.request(`/workspaces`, {
77+
const resp = await this.request("/workspaces", {
7878
method: "GET",
7979
});
8080
return (await resp.json()) as any;

core/indexing/TestCodebaseIndex.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ export class TestCodebaseIndex implements CodebaseIndex {
3535

3636
for (const item of [...results.compute, ...results.addTag]) {
3737
await db.run(
38-
`INSERT INTO test_index (path, branch, directory) VALUES (?, ?, ?)`,
38+
"INSERT INTO test_index (path, branch, directory) VALUES (?, ?, ?)",
3939
[item.path, tag.branch, tag.directory],
4040
);
4141
}
4242

4343
for (const item of [...results.del, ...results.removeTag]) {
4444
await db.run(
45-
`DELETE FROM test_index WHERE path = ? AND branch = ? AND directory = ?`,
45+
"DELETE FROM test_index WHERE path = ? AND branch = ? AND directory = ?",
4646
[item.path, tag.branch, tag.directory],
4747
);
4848
}

core/llm/autodetect.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function modelSupportsImages(
8080
title: string | undefined,
8181
capabilities: ModelCapability | undefined
8282
): boolean {
83-
if (capabilities?.uploadImage !== undefined) return capabilities.uploadImage
83+
if (capabilities?.uploadImage !== undefined) {return capabilities.uploadImage;}
8484
if (!PROVIDER_SUPPORTS_IMAGES.includes(provider)) {
8585
return false;
8686
}

core/llm/llms/FreeTrial.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class FreeTrial extends BaseLLM {
3131
private async _countTokens(prompt: string, model: string, isPrompt: boolean) {
3232
if (!Telemetry.client) {
3333
throw new Error(
34-
'In order to use the free trial, telemetry must be enabled so that we can monitor abuse. To enable telemetry, set "allowAnonymousTelemetry": true in config.json and make sure the box is checked in IDE settings. If you use your own model (local or API key), telemetry will never be required.',
34+
"In order to use the free trial, telemetry must be enabled so that we can monitor abuse. To enable telemetry, set \"allowAnonymousTelemetry\": true in config.json and make sure the box is checked in IDE settings. If you use your own model (local or API key), telemetry will never be required.",
3535
);
3636
}
3737
const event = isPrompt

core/llm/llms/Ollama.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Ollama extends BaseLLM {
6161
this.completionOptions.stop.push(JSON.parse(value));
6262
} catch (e) {
6363
console.warn(
64-
'Error parsing stop parameter value "{value}: ${e}',
64+
"Error parsing stop parameter value \"{value}: ${e}",
6565
);
6666
}
6767
break;

core/llm/llms/SageMaker.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class SageMaker extends BaseLLM {
5555
let position;
5656
while ((position = buffer.indexOf("\n")) >= 0) {
5757
const line = buffer.slice(0, position);
58-
const data = JSON.parse(line.replace(/^data:/, ''));
58+
const data = JSON.parse(line.replace(/^data:/, ""));
5959
if ("choices" in data) {
6060
yield data.choices[0].delta.content;
6161
}
@@ -94,7 +94,7 @@ class SageMaker extends BaseLLM {
9494
let position;
9595
while ((position = buffer.indexOf("\n")) >= 0) {
9696
const line = buffer.slice(0, position);
97-
const data = JSON.parse(line.replace(/^data:/, ''));
97+
const data = JSON.parse(line.replace(/^data:/, ""));
9898
if ("choices" in data) {
9999
yield { role: "assistant", content: data.choices[0].delta.content };
100100
}
@@ -143,7 +143,7 @@ class MessageAPIToolkit implements SageMakerModelToolkit {
143143
let prompt = jinja.compile(this.sagemaker.completionOptions.chat_template).render(
144144
{ messages: messages, add_generation_prompt: true },
145145
{ autoEscape: false }
146-
)
146+
);
147147
const payload = {
148148
inputs: prompt,
149149
parameters: this.sagemaker.completionOptions,

core/llm/llms/WatsonX.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class WatsonX extends BaseLLM {
1919
super(options);
2020
}
2121
async getBearerToken(): Promise<{ token: string; expiration: number }> {
22-
if (this.watsonxUrl != null && this.watsonxUrl.includes("cloud.ibm.com")) {
22+
if (this.watsonxUrl !== null && this.watsonxUrl.includes("cloud.ibm.com")) {
2323
// watsonx SaaS
2424
const wxToken = await (
2525
await fetch(
@@ -125,7 +125,9 @@ class WatsonX extends BaseLLM {
125125
protected _getHeaders() {
126126
return {
127127
"Content-Type": "application/json",
128-
Authorization: `${watsonxConfig.accessToken.expiration === -1 ? "ZenApiKey" : "Bearer"} ${watsonxConfig.accessToken.token}`,
128+
Authorization: `${
129+
watsonxConfig.accessToken.expiration === -1 ? "ZenApiKey" : "Bearer"
130+
} ${watsonxConfig.accessToken.token}`,
129131
};
130132
}
131133

@@ -169,11 +171,13 @@ class WatsonX extends BaseLLM {
169171
watsonxConfig.accessToken = await this.getBearerToken();
170172
} else {
171173
console.log(
172-
`Reusing token (expires in ${(watsonxConfig.accessToken.expiration - now) / 60} mins)`,
174+
`Reusing token (expires in ${
175+
(watsonxConfig.accessToken.expiration - now) / 60
176+
} mins)`,
173177
);
174178
}
175179
if (watsonxConfig.accessToken.token === undefined) {
176-
throw new Error(`Something went wrong. Check your credentials, please.`);
180+
throw new Error("Something went wrong. Check your credentials, please.");
177181
}
178182

179183
const stopToken =
@@ -185,7 +189,9 @@ class WatsonX extends BaseLLM {
185189
method: "POST",
186190
headers: {
187191
"Content-Type": "application/json",
188-
Authorization: `${watsonxConfig.accessToken.expiration === -1 ? "ZenApiKey" : "Bearer"} ${watsonxConfig.accessToken.token}`,
192+
Authorization: `${
193+
watsonxConfig.accessToken.expiration === -1 ? "ZenApiKey" : "Bearer"
194+
} ${watsonxConfig.accessToken.token}`,
189195
},
190196
body: JSON.stringify({
191197
input: messages[messages.length - 1].content,

core/llm/templates/edit.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const osModelsEditPrompt: PromptTemplate = (history, otherData) => {
7474
!firstCharOfFirstLine;
7575
const suffixTag = isSuffix ? "<STOP EDITING HERE>" : "";
7676
const suffixExplanation = isSuffix
77-
? ' When you get to "<STOP EDITING HERE>", end your response.'
77+
? " When you get to \"<STOP EDITING HERE>\", end your response."
7878
: "";
7979

8080
// If neither prefilling nor /v1/completions are supported, we have to use a chat prompt without putting words in the model's mouth

core/test/indexing/chunk/code.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe.skip("codeChunker", () => {
2929
test("should capture small class and function from large python file", async () => {
3030
const extraLine = "# This is a comment";
3131
const myClass = "class MyClass:\n def __init__(self):\n pass";
32-
const myFunction = 'def my_function():\n return "Hello, World!"';
32+
const myFunction = "def my_function():\n return \"Hello, World!\"";
3333

3434
const file =
3535
Array(100).fill(extraLine).join("\n") +
@@ -66,7 +66,7 @@ describe.skip("codeChunker", () => {
6666
chunks[0].startsWith("class MyClass:\n def method1():\n ..."),
6767
).toBe(true);
6868
// The extra spaces seem to be a bug with tree-sitter-python
69-
expect(chunks).toContain('def method1():\n return "Hello, 1!"');
70-
expect(chunks).toContain('def method20():\n return "Hello, 20!"');
69+
expect(chunks).toContain("def method1():\n return \"Hello, 1!\"");
70+
expect(chunks).toContain("def method20():\n return \"Hello, 20!\"");
7171
});
7272
});

core/test/util/merge.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe("mergeJson", () => {
99
expect(result).toEqual({ a: 1, b: 3, c: 4 });
1010
});
1111

12-
it('should overwrite values when mergeBehavior is "overwrite"', () => {
12+
it("should overwrite values when mergeBehavior is \"overwrite\"", () => {
1313
const first = { a: 1, b: 2 };
1414
const second = { b: 3, c: 4 };
1515
const result = mergeJson(first, second, "overwrite");

core/util/devdataSqlite.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ export class DevDataSqliteDb {
2121

2222
// Add tokens_prompt column if it doesn't exist
2323
const columnCheckResult = await db.all(
24-
`PRAGMA table_info(tokens_generated);`,
24+
"PRAGMA table_info(tokens_generated);",
2525
);
2626
const columnExists = columnCheckResult.some(
2727
(col: any) => col.name === "tokens_prompt",
2828
);
2929
if (!columnExists) {
3030
await db.exec(
31-
`ALTER TABLE tokens_generated ADD COLUMN tokens_prompt INTEGER NOT NULL DEFAULT 0;`,
31+
"ALTER TABLE tokens_generated ADD COLUMN tokens_prompt INTEGER NOT NULL DEFAULT 0;",
3232
);
3333
}
3434
}
@@ -41,7 +41,7 @@ export class DevDataSqliteDb {
4141
) {
4242
const db = await DevDataSqliteDb.get();
4343
await db?.run(
44-
`INSERT INTO tokens_generated (model, provider, tokens_prompt, tokens_generated) VALUES (?, ?, ?, ?)`,
44+
"INSERT INTO tokens_generated (model, provider, tokens_prompt, tokens_generated) VALUES (?, ?, ?, ?)",
4545
[model, provider, promptTokens, generatedTokens],
4646
);
4747
}

core/util/extractMinimalStackTraceInfo.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @returns A string containing the minimal stack trace information.
66
*/
77
export function extractMinimalStackTraceInfo(stack: unknown): string {
8-
if (typeof stack !== "string") return "";
8+
if (typeof stack !== "string") {return "";}
99
const lines = stack.split("\n");
1010
const minimalLines = lines.filter((line) => {
1111
return line.trimStart().startsWith("at ") && !line.includes("node_modules");

core/util/filesystem.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ class FileSystemIde implements IDE {
8484
}
8585

8686
async getTags(artifactId: string): Promise<IndexTag[]> {
87-
const directory =(await this.getWorkspaceDirs())[0]
87+
const directory =(await this.getWorkspaceDirs())[0];
8888
return [{
8989
artifactId,
9090
branch: await this.getBranch(directory),
9191
directory
92-
}]
92+
}];
9393
}
9494

9595
getIdeInfo(): Promise<IdeInfo> {

core/util/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ export function removeQuotesAndEscapes(output: string): string {
22
output = output.trim();
33

44
// Replace smart quotes
5-
output = output.replace("“", '"');
6-
output = output.replace("”", '"');
5+
output = output.replace("“", "\"");
6+
output = output.replace("”", "\"");
77
output = output.replace("‘", "'");
88
output = output.replace("’", "'");
99

1010
// Remove escapes
11-
output = output.replace('\\"', '"');
11+
output = output.replace("\\\"", "\"");
1212
output = output.replace("\\'", "'");
1313
output = output.replace("\\n", "\n");
1414
output = output.replace("\\t", "\t");
1515
output = output.replace("\\\\", "\\");
1616
while (
17-
(output.startsWith('"') && output.endsWith('"')) ||
17+
(output.startsWith("\"") && output.endsWith("\"")) ||
1818
(output.startsWith("'") && output.endsWith("'"))
1919
) {
2020
output = output.slice(1, -1);
@@ -120,7 +120,7 @@ export function getUniqueFilePath(
120120
}
121121

122122
export function shortestRelativePaths(paths: string[]): string[] {
123-
if (paths.length === 0) return [];
123+
if (paths.length === 0) {return [];}
124124

125125
const partsLengths = paths.map((x) => x.split(SEP_REGEX).length);
126126
const currentRelativePaths = paths.map(getBasename);
@@ -135,7 +135,7 @@ export function shortestRelativePaths(paths: string[]): string[] {
135135
const firstDuplicatedPath = currentRelativePaths.find(
136136
(x, i) => isDuplicated[i],
137137
);
138-
if (!firstDuplicatedPath) break;
138+
if (!firstDuplicatedPath) {break;}
139139

140140
currentRelativePaths.forEach((x, i) => {
141141
if (x === firstDuplicatedPath) {

core/util/messenger.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class InProcessMessenger<
7575
messageId?: string,
7676
): ToProtocol[T][1] {
7777
const listener = this.myTypeListeners.get(messageType);
78-
if (!listener) return;
78+
if (!listener) {return;}
7979

8080
const msg: Message = {
8181
messageType: messageType as string,

0 commit comments

Comments
 (0)