Skip to content

Commit

Permalink
fix: lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sroussey committed Apr 7, 2024
1 parent bcd9940 commit 4aa4611
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 32 deletions.
6 changes: 1 addition & 5 deletions packages/web/.eslintrc.cjs → .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
],
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"build-server-bun": "bun build --target=bun --sourcemap=external --external @sroussey/transformers --outdir ./dist ./src/server*.ts",
"build-types": "tsc",
"build-types-map": "tsc --declarationMap",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"test": "bun test"
},
"module": "dist/server.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/job/IndexedDbJobQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class IndexedDbQueue<Input, Output> extends JobQueue<Input, Output> {
const store = tx.objectStore("jobs");

const index = store.index("status_runAfter");
let cursorRequest = index.openCursor(IDBKeyRange.only("PENDING"), "next");
const cursorRequest = index.openCursor(IDBKeyRange.only("PENDING"), "next");

return new Promise((resolve) => {
cursorRequest.onsuccess = (e) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/job/test/JobQueue-Sqlite.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class TestJob extends Job<TaskInput, TaskOutput> {
}

describe("SqliteJobQueue", () => {
let db = getDatabase(":memory:");
let queueName = "sqlite_test_queue";
let jobQueue = new SqliteJobQueue(
const db = getDatabase(":memory:");
const queueName = "sqlite_test_queue";
const jobQueue = new SqliteJobQueue(
db,
queueName,
new SqliteRateLimiter(db, queueName, 4, 1).ensureTableExists(),
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/provider/ProviderRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ export function getProviderRegistry() {
if (!providerRegistry) providerRegistry = new ProviderRegistry();
return providerRegistry;
}
export function setProviderRegistry(providerRegistry: ProviderRegistry<TaskInput, TaskOutput>) {
providerRegistry = providerRegistry;
export function setProviderRegistry(pr: ProviderRegistry<TaskInput, TaskOutput>) {
providerRegistry = pr;
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function generateProgressCallback(task: JobQueueLlmTask, instance: any) {
skip_special_tokens: true,
});
const len = decodedText.split(" ").length;
let result = 100 * (1 - Math.exp(-0.05 * len));
const result = 100 * (1 - Math.exp(-0.05 * len));
task.progress = Math.min(result, 100);
task.emit("progress", task.progress, decodedText);
};
Expand Down Expand Up @@ -162,7 +162,7 @@ export async function HuggingFaceLocal_EmbeddingRun(
const model = findModelByName(runInputData.model) as ONNXTransformerJsModel;
const generateEmbedding: FeatureExtractionPipeline = await getPipeline(task, model);

var hfVector = await generateEmbedding(runInputData.text, {
const hfVector = await generateEmbedding(runInputData.text, {
pooling: "mean",
normalize: model.normalize,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/storage/base/KVRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export abstract class KVRepository<
let keyClone: any = { ...keySimpleOrObject };
if (discriminatorKeys.length > 0) {
discriminatorKeys.forEach((k) => {
if (keyClone.hasOwnProperty(k)) {
if (Object.prototype.hasOwnProperty.call(keyClone, k)) {
discriminators[k] = keyClone[k];
delete keyClone[k];
}
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/task/DownloadModelTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ export class DownloadModelTask extends JobQueueLlmTask {
runSyncOnly(): TaskOutput {
const model = findModelByName(this.runInputData.model);
if (model) {
// @ts-expect-error
this.runOutputData[String(model.useCase).toLowerCase()] = model.name;
model.useCase.forEach((useCase) => {
// @ts-expect-error -- we really can use this an index
this.runOutputData[String(useCase).toLowerCase()] = model.name;
});
this.runOutputData.model = model.name;
this.runOutputData.dimensions = model.dimensions!;
this.runOutputData.normalize = model.normalize;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/task/JsonTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class JsonTask extends RegenerativeCompoundTask {
for (const item of jsonItems) {
if (!item.dependencies) continue;
for (const [input, dependency] of Object.entries(item.dependencies)) {
let dependencies = Array.isArray(dependency) ? dependency : [dependency];
const dependencies = Array.isArray(dependency) ? dependency : [dependency];
for (const dep of dependencies) {
const sourceTask = this.subGraph.getTask(dep.id);
if (!sourceTask) {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/task/base/ArrayTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ function generateCombinations<T extends TaskInput>(input: T, inputMakeArray: (ke
);

// Initialize indices and combinations
let indices = arraysToCombine.map(() => 0);
let combinations: number[][] = [];
const indices = arraysToCombine.map(() => 0);
const combinations: number[][] = [];
let done = false;

while (!done) {
Expand All @@ -112,7 +112,7 @@ function generateCombinations<T extends TaskInput>(input: T, inputMakeArray: (ke

// Build objects based on the combinations
return combinations.map((combination) => {
let result = { ...input }; // Start with a shallow copy of the input
const result = { ...input }; // Start with a shallow copy of the input

// Set values from the arrays based on the current combination
combination.forEach((valueIndex, arrayIndex) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/task/base/TaskGraphBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function TaskGraphBuilderHelper<I extends TaskInput>(
}
return this;
};
// @ts-expect-error -
// @ts-expect-error - runtype is hack from ArrayTask TODO: fix
result.type = taskClass.runtype ?? taskClass.type;
result.inputs = taskClass.inputs;
result.outputs = taskClass.outputs;
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/task/base/TaskIOTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ type DocParser = (typeof doc_parsers)[number];
// Provided lookup type
interface TsTypes {
any: any;
function: Function;
function: (...args: any[]) => any;
boolean: boolean;
string: string;
number: number;
Expand Down Expand Up @@ -164,8 +164,6 @@ export function validateItem(valueType: ValueTypesIndex, item: any): boolean {
return typeof item === "boolean";
case "function":
return typeof item === "function";
case "vector":
return item instanceof ElVector;
case "log_level":
return log_levels.includes(item);
case "doc_parser":
Expand Down
9 changes: 4 additions & 5 deletions packages/core/src/util/Misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
// * Licensed under the Apache License, Version 2.0 (the "License"); *
// *******************************************************************************

import { TaskInput } from "../task/base/Task";

export function forceArray<T = any>(input: T | T[]): T[] {
if (Array.isArray(input)) return input;
return [input];
Expand Down Expand Up @@ -39,14 +37,14 @@ export function deepEqual(a: any, b: any): boolean {
return false;
}

let keysA = Object.keys(a);
let keysB = Object.keys(b);
const keysA = Object.keys(a);
const keysB = Object.keys(b);

if (keysA.length !== keysB.length) {
return false;
}

for (let key of keysA) {
for (const key of keysA) {
if (!keysB.includes(key)) {
return false;
}
Expand Down Expand Up @@ -86,6 +84,7 @@ export async function sha256(data: string): Promise<string> {
});
} else if (typeof process === "object" && process.versions && process.versions.node) {
// Node.js environment
// eslint-disable-next-line @typescript-eslint/no-var-requires
const crypto = require("crypto");
return Promise.resolve(crypto.createHash("sha256").update(data).digest("hex"));
} else {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/util/db_sqlite.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const wrapper = function () {
if (process["isBun"]) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
return require("bun:sqlite").Database;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"scripts": {
"dev": "concurrently -c 'auto' -n app,types 'vite' 'tsc -w --noEmit'",
"build": "vite build",
"build": "vite build && tsc --noEmit",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
Expand Down
1 change: 0 additions & 1 deletion packages/web/src/layout.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Edge, Node, Position } from "@sroussey/xyflow-react";
import { DirectedAcyclicGraph } from "@sroussey/typescript-graph";

Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const orange = dark ? "#da885e" : "#953402";

console.log("%cWelcome to Ellmers!", "color: green; font-size: 16px;");
console.log(
"%cOpen DevTools settings, and under Console, turn on 'enable custom formatters' for best experience.",
"%cOpen DevTools settings, and under Console, turn on 'enable custom formatters' for best experience. Then reload the page.",
"color: red;"
);
console.log(
Expand Down

0 comments on commit 4aa4611

Please sign in to comment.