Skip to content

Commit 5b682fe

Browse files
authored
Merge pull request #137 from RooVetGit/jq/fix-lint
fix npm run lint
2 parents 476e564 + e6b591b commit 5b682fe

File tree

7 files changed

+46
-26
lines changed

7 files changed

+46
-26
lines changed

.changeset/shaggy-moons-dance.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"roo-cline": patch
3+
---
4+
5+
Fix lint errors and change npm run lint to also run on webview-ui

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
"compile": "npm run check-types && npm run lint && node esbuild.js",
154154
"compile-tests": "tsc -p . --outDir out",
155155
"install:all": "npm install && cd webview-ui && npm install",
156-
"lint": "eslint src --ext ts",
156+
"lint": "eslint src --ext ts && npm run lint --prefix webview-ui",
157157
"package": "npm run build:webview && npm run check-types && npm run lint && node esbuild.js --production",
158158
"pretest": "npm run compile-tests && npm run compile && npm run lint",
159159
"start:webview": "cd webview-ui && npm run start",

webview-ui/package-lock.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"start": "react-scripts start",
3232
"build": "node ./scripts/build-react-no-split.js",
3333
"test": "react-scripts test --watchAll=false",
34-
"eject": "react-scripts eject"
34+
"eject": "react-scripts eject",
35+
"lint": "eslint src --ext ts,tsx"
3536
},
3637
"eslintConfig": {
3738
"extends": [
@@ -53,7 +54,8 @@
5354
},
5455
"devDependencies": {
5556
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
56-
"@types/vscode-webview": "^1.57.5"
57+
"@types/vscode-webview": "^1.57.5",
58+
"eslint": "^8.57.0"
5759
},
5860
"jest": {
5961
"transformIgnorePatterns": [

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
479479
})
480480
}, [modifiedMessages])
481481

482-
const isReadOnlyToolAction = (message: ClineMessage | undefined) => {
482+
const isReadOnlyToolAction = useCallback((message: ClineMessage | undefined) => {
483483
if (message?.type === "ask") {
484484
if (!message.text) {
485485
return true
@@ -488,9 +488,9 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
488488
return ["readFile", "listFiles", "listFilesTopLevel", "listFilesRecursive", "listCodeDefinitionNames", "searchFiles"].includes(tool.tool)
489489
}
490490
return false
491-
}
491+
}, [])
492492

493-
const isWriteToolAction = (message: ClineMessage | undefined) => {
493+
const isWriteToolAction = useCallback((message: ClineMessage | undefined) => {
494494
if (message?.type === "ask") {
495495
if (!message.text) {
496496
return true
@@ -499,9 +499,9 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
499499
return ["editedExistingFile", "appliedDiff", "newFileCreated"].includes(tool.tool)
500500
}
501501
return false
502-
}
502+
}, [])
503503

504-
const isMcpToolAlwaysAllowed = (message: ClineMessage | undefined) => {
504+
const isMcpToolAlwaysAllowed = useCallback((message: ClineMessage | undefined) => {
505505
if (message?.type === "ask" && message.ask === "use_mcp_server") {
506506
if (!message.text) {
507507
return true
@@ -514,9 +514,9 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
514514
}
515515
}
516516
return false
517-
}
517+
}, [mcpServers])
518518

519-
const isAllowedCommand = (message: ClineMessage | undefined) => {
519+
const isAllowedCommand = useCallback((message: ClineMessage | undefined) => {
520520
if (message?.type === "ask") {
521521
const command = message.text
522522
if (!command) {
@@ -533,19 +533,32 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
533533
})
534534
}
535535
return false
536-
}
536+
}, [allowedCommands])
537537

538-
const isAutoApproved = (message: ClineMessage | undefined) => {
539-
if (!message || message.type !== "ask") return false
538+
const isAutoApproved = useCallback(
539+
(message: ClineMessage | undefined) => {
540+
if (!message || message.type !== "ask") return false
540541

541-
return (
542-
(alwaysAllowBrowser && message.ask === "browser_action_launch") ||
543-
(alwaysAllowReadOnly && message.ask === "tool" && isReadOnlyToolAction(message)) ||
544-
(alwaysAllowWrite && message.ask === "tool" && isWriteToolAction(message)) ||
545-
(alwaysAllowExecute && message.ask === "command" && isAllowedCommand(message)) ||
546-
(alwaysAllowMcp && message.ask === "use_mcp_server" && isMcpToolAlwaysAllowed(message))
547-
)
548-
}
542+
return (
543+
(alwaysAllowBrowser && message.ask === "browser_action_launch") ||
544+
(alwaysAllowReadOnly && message.ask === "tool" && isReadOnlyToolAction(message)) ||
545+
(alwaysAllowWrite && message.ask === "tool" && isWriteToolAction(message)) ||
546+
(alwaysAllowExecute && message.ask === "command" && isAllowedCommand(message)) ||
547+
(alwaysAllowMcp && message.ask === "use_mcp_server" && isMcpToolAlwaysAllowed(message))
548+
)
549+
},
550+
[
551+
alwaysAllowBrowser,
552+
alwaysAllowReadOnly,
553+
alwaysAllowWrite,
554+
alwaysAllowExecute,
555+
alwaysAllowMcp,
556+
isReadOnlyToolAction,
557+
isWriteToolAction,
558+
isAllowedCommand,
559+
isMcpToolAlwaysAllowed
560+
]
561+
)
549562

550563
useEffect(() => {
551564
// Only execute when isStreaming changes from true to false
@@ -580,7 +593,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
580593
}
581594
// Update previous value
582595
setWasStreaming(isStreaming)
583-
}, [isStreaming, lastMessage, wasStreaming])
596+
}, [isStreaming, lastMessage, wasStreaming, isAutoApproved])
584597

585598
const isBrowserSessionMessage = (message: ClineMessage): boolean => {
586599
// which of visible messages are browser session messages, see above
@@ -822,7 +835,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
822835
if (isAutoApproved(lastMessage)) {
823836
handlePrimaryButtonClick()
824837
}
825-
}, [clineAsk, enableButtons, handlePrimaryButtonClick, alwaysAllowBrowser, alwaysAllowReadOnly, alwaysAllowWrite, alwaysAllowExecute, alwaysAllowMcp, messages, allowedCommands, mcpServers])
838+
}, [clineAsk, enableButtons, handlePrimaryButtonClick, alwaysAllowBrowser, alwaysAllowReadOnly, alwaysAllowWrite, alwaysAllowExecute, alwaysAllowMcp, messages, allowedCommands, mcpServers, isAutoApproved, lastMessage])
826839

827840
return (
828841
<div

webview-ui/src/components/mcp/__tests__/McpToolRow.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ jest.mock('@vscode/webview-ui-toolkit/react', () => ({
2323
<label>
2424
<input
2525
type="checkbox"
26-
role="checkbox"
2726
checked={checked}
2827
onChange={onChange}
2928
/>

webview-ui/src/components/settings/__tests__/SettingsView.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jest.mock('@vscode/webview-ui-toolkit/react', () => ({
4040
/>
4141
),
4242
VSCodeTextArea: () => <textarea />,
43-
VSCodeLink: () => <a />,
43+
VSCodeLink: ({ children, href }: any) => <a href={href || '#'}>{children}</a>,
4444
VSCodeDropdown: ({ children, value, onChange }: any) => (
4545
<select value={value} onChange={onChange}>
4646
{children}

0 commit comments

Comments
 (0)