Skip to content

Commit 5aeab23

Browse files
authored
feat: add ESLint configuration (#7)
- Add eslint.config.js with TypeScript and React plugins - Add lint script to package.json - Re-enable lint step in CI workflow - Fix all lint errors (unused imports, const assignments) - 41 warnings remain (mostly @typescript-eslint/no-explicit-any)
1 parent 4ad0a08 commit 5aeab23

12 files changed

Lines changed: 4180 additions & 200 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ jobs:
3535
run: |
3636
npm run test
3737
npm run typecheck
38+
npm run lint

convex/component/chat.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// <reference types="vite/client" />
2-
import { describe, it, expect, vi } from "vitest";
2+
import { describe, it, expect } from "vitest";
33
import { convexTest } from "convex-test";
44
import schema from "./schema";
55
import { api } from "./_generated/api";

convex/component/chat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
validateToolArgs,
99
} from "./tools";
1010
import type { DatabaseChatTool } from "./tools";
11-
import { DeltaStreamer, type StreamPart } from "./deltaStreamer";
11+
import { DeltaStreamer } from "./deltaStreamer";
1212

1313
/**
1414
* Send a message and get a streaming response.

convex/component/conversations.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// <reference types="vite/client" />
2-
import { describe, it, expect, beforeEach } from "vitest";
2+
import { describe, it, expect } from "vitest";
33
import { convexTest } from "convex-test";
44
import schema from "./schema";
55
import { api } from "./_generated/api";

convex/component/schemaTools.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe("schemaTools", () => {
2222
searchIndexes: [],
2323
};
2424

25-
const handlers: SchemaToolHandlers = {
25+
const _handlers: SchemaToolHandlers = {
2626
query: "query_handler",
2727
count: "count_handler",
2828
aggregate: "aggregate_handler",

convex/component/schemaTools.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@
2121
* ```
2222
*/
2323

24-
import type {
25-
DatabaseChatTool,
26-
ToolParameterSchema,
27-
AutoToolsConfig,
28-
} from "./tools";
24+
import type { DatabaseChatTool, AutoToolsConfig } from "./tools";
2925

3026
// =============================================================================
3127
// Types
@@ -89,7 +85,7 @@ export interface GenerateToolsOptions extends AutoToolsConfig {
8985
/**
9086
* Map Convex validator types to JSON Schema types.
9187
*/
92-
function convexTypeToJsonType(
88+
function _convexTypeToJsonType(
9389
convexType: string
9490
): "string" | "number" | "boolean" | "array" | "object" {
9591
const typeMap: Record<string, "string" | "number" | "boolean" | "array" | "object"> = {
@@ -337,7 +333,7 @@ export function generateToolsFromSchema(
337333
const {
338334
tables,
339335
allowedTables,
340-
excludeFields,
336+
excludeFields: _excludeFields,
341337
tableDescriptions,
342338
handlers,
343339
} = options;

convex/component/stream.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// <reference types="vite/client" />
2-
import { describe, it, expect, beforeEach, vi } from "vitest";
2+
import { describe, it, expect } from "vitest";
33
import { convexTest } from "convex-test";
44
import schema from "./schema";
55
import { api } from "./_generated/api";

eslint.config.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import eslint from "@eslint/js";
2+
import tseslint from "typescript-eslint";
3+
import reactPlugin from "eslint-plugin-react";
4+
import reactHooksPlugin from "eslint-plugin-react-hooks";
5+
6+
export default tseslint.config(
7+
eslint.configs.recommended,
8+
...tseslint.configs.recommended,
9+
{
10+
ignores: [
11+
"dist/**",
12+
"node_modules/**",
13+
"**/convex/_generated/**",
14+
"**/_generated/**",
15+
"example/dist/**",
16+
],
17+
},
18+
{
19+
files: ["**/*.ts", "**/*.tsx"],
20+
plugins: {
21+
react: reactPlugin,
22+
"react-hooks": reactHooksPlugin,
23+
},
24+
languageOptions: {
25+
parserOptions: {
26+
ecmaFeatures: {
27+
jsx: true,
28+
},
29+
},
30+
},
31+
rules: {
32+
// TypeScript rules
33+
"@typescript-eslint/no-unused-vars": [
34+
"error",
35+
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
36+
],
37+
"@typescript-eslint/no-explicit-any": "warn",
38+
"@typescript-eslint/no-require-imports": "off",
39+
40+
// React rules
41+
"react/react-in-jsx-scope": "off",
42+
"react-hooks/rules-of-hooks": "error",
43+
"react-hooks/exhaustive-deps": "warn",
44+
45+
// General rules
46+
"no-console": ["warn", { allow: ["warn", "error"] }],
47+
},
48+
settings: {
49+
react: {
50+
version: "detect",
51+
},
52+
},
53+
}
54+
);

example/convex/chat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ async function callLLMWithTools(
426426
},
427427
}));
428428

429-
let currentMessages = [...messages];
429+
const currentMessages = [...messages];
430430
let loopCount = 0;
431431
const MAX_LOOPS = 5;
432432

example/src/components/Chat.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useEffect, useRef, useMemo, FormEvent } from "react";
1+
import { useState, useEffect, useRef, FormEvent } from "react";
22
import { useQuery, useMutation, useAction } from "convex/react";
33
import { api } from "../../convex/_generated/api";
44
import { useRateLimit } from "../hooks/useRateLimit";

0 commit comments

Comments
 (0)