Update ESLint rules and error handling

- Remove "no-unused-vars" and "no-unused-expressions" from .eslintrc.json.
- Simplify error handling in devchat.ts by returning stderr directly.
- Remove "noUnusedLocals" and "noUnusedParameters" from tsconfig.json.
This commit is contained in:
bobo.yang 2023-05-31 16:10:53 +08:00
parent ba097eab26
commit 3136748f72
3 changed files with 2 additions and 7 deletions

View File

@ -9,8 +9,6 @@
"@typescript-eslint" "@typescript-eslint"
], ],
"rules": { "rules": {
"no-unused-vars": "warn",
"no-unused-expressions": "warn",
"@typescript-eslint/naming-convention": "warn", "@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/semi": "warn", "@typescript-eslint/semi": "warn",
"curly": "warn", "curly": "warn",

View File

@ -208,12 +208,11 @@ class DevChat {
const { exitCode: code, stdout, stderr } = await this.commandRun.spawnAsync(devChat, args, spawnAsyncOptions, onStdoutPartial, undefined, undefined, undefined); const { exitCode: code, stdout, stderr } = await this.commandRun.spawnAsync(devChat, args, spawnAsyncOptions, onStdoutPartial, undefined, undefined, undefined);
if (stderr) { if (stderr) {
const errorMessage = stderr.trim().match(/Error(.+)/)?.[1];
return { return {
"prompt-hash": "", "prompt-hash": "",
user: "", user: "",
date: "", date: "",
response: errorMessage ? `Error: ${errorMessage}` : "Unknown error", response: stderr,
isError: true, isError: true,
}; };
} }

View File

@ -12,9 +12,7 @@
"rootDir": "src", "rootDir": "src",
"strict": true, "strict": true,
"jsx": "react", "jsx": "react",
"esModuleInterop": true, "esModuleInterop": true
"noUnusedLocals": true,
"noUnusedParameters": true,
}, },
"exclude": ["test"] "exclude": ["test"]
} }