Skip to content

Commit 4eca988

Browse files
committed
simplify eslint.
1 parent 4165f34 commit 4eca988

File tree

9 files changed

+119
-136
lines changed

9 files changed

+119
-136
lines changed

eslint.config.js

Lines changed: 67 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -5,65 +5,77 @@ import eslintConfigPrettier from "eslint-config-prettier";
55
import importPlugin from "eslint-plugin-import";
66
import unusedImports from "eslint-plugin-unused-imports";
77

8-
export default tseslint.config(
9-
eslint.configs.recommended,
10-
...tseslint.configs.recommended,
11-
eslintConfigPrettier,
8+
export default [
129
{
13-
plugins: {
14-
import: importPlugin,
15-
'unused-imports': unusedImports,
16-
},
17-
ignores: ["dist/", "node_modules/"],
18-
languageOptions: {
19-
parser: tseslint.parser,
20-
parserOptions: {
21-
project: "./tsconfig.json",
10+
ignores: ["**/dist/**", "**/node_modules/**", "**/coverage/**"],
11+
},
12+
...tseslint.config(
13+
eslint.configs.recommended,
14+
...tseslint.configs.recommended,
15+
eslintConfigPrettier,
16+
{
17+
files: ["src/**/*.{js,ts}", "tests/**/*.{js,ts}", "bin/**/*.{js,ts}"],
18+
plugins: {
19+
import: importPlugin,
20+
"unused-imports": unusedImports,
2221
},
23-
},
24-
rules: {
25-
// Basic TypeScript rules
26-
"@typescript-eslint/no-unused-vars": ["warn", { "ignoreRestSiblings": true }],
27-
"unused-imports/no-unused-imports": "error",
28-
"@typescript-eslint/no-explicit-any": "off", // Allow any for initial flexibility
29-
"@typescript-eslint/explicit-function-return-type": "off",
30-
"@typescript-eslint/no-floating-promises": "warn",
22+
languageOptions: {
23+
ecmaVersion: 2022,
24+
sourceType: "module",
25+
parser: tseslint.parser,
26+
},
27+
rules: {
28+
// Basic TypeScript rules
29+
"@typescript-eslint/no-unused-vars": [
30+
"warn",
31+
{
32+
ignoreRestSiblings: true,
33+
argsIgnorePattern: "^_",
34+
varsIgnorePattern: "^_",
35+
caughtErrorsIgnorePattern: "^_",
36+
},
37+
],
38+
"unused-imports/no-unused-imports": "error",
39+
"@typescript-eslint/no-explicit-any": "off",
40+
"@typescript-eslint/explicit-function-return-type": "off",
41+
"@typescript-eslint/no-floating-promises": "off",
42+
43+
// Basic code quality rules
44+
"no-console": "off",
45+
"prefer-const": "warn",
46+
"no-var": "warn",
47+
eqeqeq: ["warn", "always"],
3148

32-
// Basic code quality rules
33-
"no-console": "off", // Allow console logs for development
34-
"prefer-const": "warn",
35-
"no-var": "warn",
36-
eqeqeq: ["warn", "always"],
49+
// Light complexity rules
50+
complexity: ["warn", { max: 20 }],
51+
"max-depth": ["warn", { max: 4 }],
52+
"max-lines-per-function": ["warn", { max: 150 }],
3753

38-
// Light complexity rules
39-
complexity: ["warn", { max: 20 }], // More permissive complexity
40-
"max-depth": ["warn", { max: 4 }],
41-
"max-lines-per-function": ["warn", { max: 100 }],
54+
// Error prevention
55+
"import/no-duplicates": "error",
56+
"no-template-curly-in-string": "warn",
4257

43-
// Error prevention
44-
"import/no-duplicates": "error", // Using import plugin's rule instead
45-
"no-template-curly-in-string": "warn",
58+
// Format and whitespace
59+
"max-len": [
60+
"warn",
61+
{
62+
code: 120,
63+
ignoreComments: true,
64+
ignoreStrings: true,
65+
ignoreTemplateLiterals: true,
66+
},
67+
],
4668

47-
// Format and whitespace
48-
"max-len": [
49-
"warn",
50-
{
51-
code: 120, // More permissive line length
52-
ignoreComments: true,
53-
ignoreStrings: true,
54-
ignoreTemplateLiterals: true,
55-
},
56-
],
69+
// Import rules
70+
"import/extensions": ["off"],
71+
"import/no-unresolved": "off",
5772

58-
// Import rules
59-
"import/extensions": [
60-
"error",
61-
"ignorePackages",
62-
{
63-
ts: "never",
64-
tsx: "never",
65-
},
66-
],
67-
},
68-
}
69-
);
73+
// Disable specific TypeScript rules that require type information
74+
"@typescript-eslint/no-unsafe-assignment": "off",
75+
"@typescript-eslint/no-unsafe-member-access": "off",
76+
"@typescript-eslint/no-unsafe-call": "off",
77+
"@typescript-eslint/no-unsafe-return": "off",
78+
},
79+
}
80+
),
81+
];

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"build:ci": "tsc",
2525
"clean": "rimraf dist",
2626
"clean:all": "rimraf dist node_modules",
27-
"lint": "eslint \"src/**/*.ts\" --fix",
27+
"lint": "eslint . --fix",
2828
"format": "prettier --write \"src/**/*.*\"",
2929
"test": "vitest run",
3030
"test:watch": "vitest",

src/core/toolAgent.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable max-lines-per-function */
1+
22
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
33
import { executeToolCall } from "./executeToolCall.js";
44
import { Tool } from "./types.js";

src/core/toolAgent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ async function executeTools(
155155
return { sequenceCompleted, completionResult, toolResults };
156156
}
157157

158-
// eslint-disable-next-line max-lines-per-function
158+
159159
export const toolAgent = async (
160160
initialPrompt: string,
161161
tools: Tool[],

src/tools/system/shellMessage.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, it, expect, beforeEach, afterEach } from "vitest";
22
import { processStates, shellStartTool } from "./shellStart.js";
33
import { MockLogger } from "../../utils/mockLogger.js";
4-
import { shellMessageTool } from "./shellMessage.js";
4+
import { shellMessageTool, NodeSignals } from "./shellMessage.js";
55

66
const logger = new MockLogger();
77

@@ -116,7 +116,7 @@ describe("shellMessageTool", () => {
116116
const result = await shellMessageTool.execute(
117117
{
118118
instanceId,
119-
signal: "SIGTERM",
119+
signal: NodeSignals.SIGTERM,
120120
description: "Send SIGTERM",
121121
},
122122
{ logger },
@@ -154,7 +154,7 @@ describe("shellMessageTool", () => {
154154
const result = await shellMessageTool.execute(
155155
{
156156
instanceId,
157-
signal: "SIGTERM",
157+
signal: NodeSignals.SIGTERM,
158158
description: "Send signal to terminated process",
159159
},
160160
{ logger },
@@ -181,7 +181,7 @@ describe("shellMessageTool", () => {
181181
await shellMessageTool.execute(
182182
{
183183
instanceId,
184-
signal: "SIGTERM",
184+
signal: NodeSignals.SIGTERM,
185185
description: "Send SIGTERM",
186186
},
187187
{ logger },

src/tools/system/shellMessage.ts

Lines changed: 38 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -3,83 +3,49 @@ import { z } from "zod";
33
import { zodToJsonSchema } from "zod-to-json-schema";
44
import { processStates } from "./shellStart.js";
55

6-
// Define valid NodeJS signals as a union type
7-
type NodeSignals =
8-
| "SIGABRT"
9-
| "SIGALRM"
10-
| "SIGBUS"
11-
| "SIGCHLD"
12-
| "SIGCONT"
13-
| "SIGFPE"
14-
| "SIGHUP"
15-
| "SIGILL"
16-
| "SIGINT"
17-
| "SIGIO"
18-
| "SIGIOT"
19-
| "SIGKILL"
20-
| "SIGPIPE"
21-
| "SIGPOLL"
22-
| "SIGPROF"
23-
| "SIGPWR"
24-
| "SIGQUIT"
25-
| "SIGSEGV"
26-
| "SIGSTKFLT"
27-
| "SIGSTOP"
28-
| "SIGSYS"
29-
| "SIGTERM"
30-
| "SIGTRAP"
31-
| "SIGTSTP"
32-
| "SIGTTIN"
33-
| "SIGTTOU"
34-
| "SIGUNUSED"
35-
| "SIGURG"
36-
| "SIGUSR1"
37-
| "SIGUSR2"
38-
| "SIGVTALRM"
39-
| "SIGWINCH"
40-
| "SIGXCPU"
41-
| "SIGXFSZ";
6+
// Define NodeJS signals as an enum
7+
export enum NodeSignals {
8+
SIGABRT = "SIGABRT",
9+
SIGALRM = "SIGALRM",
10+
SIGBUS = "SIGBUS",
11+
SIGCHLD = "SIGCHLD",
12+
SIGCONT = "SIGCONT",
13+
SIGFPE = "SIGFPE",
14+
SIGHUP = "SIGHUP",
15+
SIGILL = "SIGILL",
16+
SIGINT = "SIGINT",
17+
SIGIO = "SIGIO",
18+
SIGIOT = "SIGIOT",
19+
SIGKILL = "SIGKILL",
20+
SIGPIPE = "SIGPIPE",
21+
SIGPOLL = "SIGPOLL",
22+
SIGPROF = "SIGPROF",
23+
SIGPWR = "SIGPWR",
24+
SIGQUIT = "SIGQUIT",
25+
SIGSEGV = "SIGSEGV",
26+
SIGSTKFLT = "SIGSTKFLT",
27+
SIGSTOP = "SIGSTOP",
28+
SIGSYS = "SIGSYS",
29+
SIGTERM = "SIGTERM",
30+
SIGTRAP = "SIGTRAP",
31+
SIGTSTP = "SIGTSTP",
32+
SIGTTIN = "SIGTTIN",
33+
SIGTTOU = "SIGTTOU",
34+
SIGUNUSED = "SIGUNUSED",
35+
SIGURG = "SIGURG",
36+
SIGUSR1 = "SIGUSR1",
37+
SIGUSR2 = "SIGUSR2",
38+
SIGVTALRM = "SIGVTALRM",
39+
SIGWINCH = "SIGWINCH",
40+
SIGXCPU = "SIGXCPU",
41+
SIGXFSZ = "SIGXFSZ"
42+
}
4243

4344
const parameterSchema = z.object({
4445
instanceId: z.string().describe("The ID returned by shellStart"),
4546
stdin: z.string().optional().describe("Input to send to process"),
4647
signal: z
47-
.enum([
48-
"SIGABRT",
49-
"SIGALRM",
50-
"SIGBUS",
51-
"SIGCHLD",
52-
"SIGCONT",
53-
"SIGFPE",
54-
"SIGHUP",
55-
"SIGILL",
56-
"SIGINT",
57-
"SIGIO",
58-
"SIGIOT",
59-
"SIGKILL",
60-
"SIGPIPE",
61-
"SIGPOLL",
62-
"SIGPROF",
63-
"SIGPWR",
64-
"SIGQUIT",
65-
"SIGSEGV",
66-
"SIGSTKFLT",
67-
"SIGSTOP",
68-
"SIGSYS",
69-
"SIGTERM",
70-
"SIGTRAP",
71-
"SIGTSTP",
72-
"SIGTTIN",
73-
"SIGTTOU",
74-
"SIGUNUSED",
75-
"SIGURG",
76-
"SIGUSR1",
77-
"SIGUSR2",
78-
"SIGVTALRM",
79-
"SIGWINCH",
80-
"SIGXCPU",
81-
"SIGXFSZ",
82-
] as const)
48+
.nativeEnum(NodeSignals)
8349
.optional()
8450
.describe("Signal to send to the process (e.g., SIGTERM, SIGINT)"),
8551
description: z

src/tools/system/shellStart.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ describe("shellStartTool", () => {
8080

8181
// Even sync results should be in processStates
8282
expect(processStates.size).toBeGreaterThan(0);
83+
expect(syncResult.mode).toBe("sync");
84+
expect(syncResult.error).toBeUndefined();
85+
if (syncResult.mode === "sync") {
86+
expect(syncResult.exitCode).toBe(0);
87+
}
8388

8489
// Test async mode
8590
const asyncResult = await shellStartTool.execute(

src/utils/logger.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable max-lines-per-function */
1+
22
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
33
import { Logger, LogLevel } from "./logger.js";
44

src/utils/versionCheck.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable max-lines-per-function */
1+
22
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
33
import {
44
generateUpgradeMessage,

0 commit comments

Comments
 (0)