mirror of
https://github.com/cline/cline.git
synced 2025-06-03 03:59:07 +00:00

* Fix linter warnings in the webview (part 2) Replace protobus calls using object literals to use Message.create({...}) Fix incorrect property name detected after this change in webview-ui/src/components/settings/SettingsView.tsx Optimised imports in vscode. * formatting * feat(lint): Add custom ESLint rules for protobuf type checking Add two custom ESLint rules to enforce proper usage patterns when creating protobuf objects. Using .create() to build protobufs ensures that the protobuf is type checked when it is created. Protobufs created using object literals are not type checked, which can lead to subtle bugs and type mismatches. The linter rules detect when protobufs are created without using .create() or .fromPartial(). - no-protobuf-object-literals: Enforces the use of `.create()` or `.fromPartial()` methods instead of object literals when creating protobuf types. ``` /Users/sjf/cline/src/shared/proto-conversions/state/chat-settings-conversion.ts 9:9 warning Use ChatSettings.create() or ChatSettings.fromPartial() instead of object literal for protobuf type Found: return { mode: chatSettings.mode === "plan" ? PlanActMode.PLAN : PlanActMode.ACT, preferredLanguage: chatSettings.preferredLanguage, openAiReasoningEffort: chatSettings.openAIReasoningEffort, } Suggestion: ChatSettings.create({ mode: chatSettings.mode === "plan" ? PlanActMode.PLAN : PlanActMode.ACT, preferredLanguage: chatSettings.preferredLanguage, openAiReasoningEffort: chatSettings.openAIReasoningEffort, }) ``` - no-grpc-client-object-literals: Enforces proper protobuf creation for gRPC service client parameters. This needs a separate rule because the type signatures of the ServiceClients methods are too generic to be detected by the previous rule. ``` /Users/sjf/cline/webview-ui/src/components/mcp/configuration/tabs/add-server/AddRemoteServerForm.tsx 41:62 warning Use the appropriate protobuf .create() or .fromPartial() method instead of object literal for gRPC client parameters. Found: McpServiceClient.addRemoteMcpServer({ serverName: serverName.trim(), serverUrl: serverUrl.trim(), }) ``` These rules help maintain code quality by enforcing consistent patterns for working with protocol buffers throughout the codebase, reducing potential runtime errors from improper message construction. * Update test * Add custom eslint rules to new webview-ui config * Only include webview grpc ServiceClient check * Fix lint errors * formatting * Update package-lock.json * Update package.json
32 lines
694 B
JSON
32 lines
694 B
JSON
{
|
|
"name": "eslint-plugin-eslint-rules",
|
|
"version": "1.0.0",
|
|
"description": "Custom ESLint rules for Cline",
|
|
"main": "index.js",
|
|
"scripts": {
|
|
"test": "mocha --no-config --require ts-node/register __tests__/**/*.test.ts"
|
|
},
|
|
"keywords": [
|
|
"eslint",
|
|
"eslintplugin"
|
|
],
|
|
"author": "Cline Bot Inc.",
|
|
"license": "Apache-2.0",
|
|
"dependencies": {
|
|
"@typescript-eslint/utils": "^8.33.0"
|
|
},
|
|
"devDependencies": {
|
|
"@types/eslint": "^8.0.0",
|
|
"@types/mocha": "^10.0.7",
|
|
"@types/node": "^20.0.0",
|
|
"@typescript-eslint/parser": "^7.14.1",
|
|
"eslint": "^8.57.0",
|
|
"mocha": "^10.0.0",
|
|
"ts-node": "^10.9.2",
|
|
"typescript": "^5.4.5"
|
|
},
|
|
"peerDependencies": {
|
|
"eslint": ">=8.0.0"
|
|
}
|
|
}
|