Skip to content

Commit dbc21ab

Browse files
committed
chore: fixed linting with latest changes from main
1 parent 4cf5027 commit dbc21ab

34 files changed

+201
-157
lines changed

chat-client-ui-types/src/uiContracts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export type UiMessageResultParams =
174174
}
175175
export interface ErrorResult {
176176
message: string
177-
type: 'InvalidRequest' | 'InternalError' | 'UnknownError' | string
177+
type: 'InvalidRequest' | 'InternalError' | 'UnknownError'
178178
}
179179

180180
/*

package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

runtimes/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"@types/mock-fs": "^4.13.4",
6161
"@types/node": "^22.13.1",
6262
"@types/node-forge": "^1.3.11",
63+
"@types/win-ca": "^3.5.4",
6364
"assert": "^2.0.0",
6465
"copyfiles": "^2.4.1",
6566
"husky": "^9.1.7",

runtimes/protocol/notification.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ export interface NotificationContent {
1313
readonly title?: string
1414
}
1515

16-
export namespace FollowupNotificationActionType {
17-
export const Acknowledge = 'Acknowledge'
18-
}
16+
export const FollowupNotificationActionType = {
17+
Acknowledge: 'Acknowledge',
18+
} as const
1919

2020
export type FollowupNotificationActionType = typeof FollowupNotificationActionType.Acknowledge
2121

22-
export namespace NotificationActionType {
23-
export const Url = 'Url'
24-
export const Marketplace = 'Marketplace'
25-
}
22+
const NotificationActionType = {
23+
Url: 'Url',
24+
Marketplace: 'Marketplace',
25+
} as const
2626

2727
export type NotificationActionType =
2828
| typeof NotificationActionType.Url

runtimes/runtimes/auth/auth.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ describe('Auth', () => {
396396
describe('Encrypted credentials', () => {
397397
it('Rejects when encrypted flag is set wrong', async () => {
398398
const updateIamRequest: UpdateCredentialsParams = {
399-
data: iamCredentials as IamCredentials,
399+
data: iamCredentials,
400400
encrypted: true,
401401
}
402402
const auth = new Auth(serverLspConnectionMock, lspRouter)
@@ -472,8 +472,8 @@ describe('Auth', () => {
472472

473473
const jwt = await new jose.EncryptJWT(payload)
474474
.setProtectedHeader({ alg: 'dir', enc: 'A256GCM' })
475-
.setNotBefore(new Date().getTime() / 1000 + 50) //allows up to 60s clockTolerance
476-
.setExpirationTime(new Date().getTime() / 1000 - 70) //not allowed
475+
.setNotBefore(Date.now() / 1000 + 50) // allows up to 60s clockTolerance
476+
.setExpirationTime(Date.now() / 1000 - 70) // not allowed
477477
.encrypt(encryptionKey)
478478

479479
const updateBearerRequest: UpdateCredentialsParams = {

runtimes/runtimes/auth/auth.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/restrict-template-expressions */
12
import { jwtDecrypt } from 'jose'
23
import { Connection } from 'vscode-languageserver'
34
import { CredentialsEncoding } from './standalone/encryption'
@@ -97,7 +98,7 @@ export class Auth {
9798
return creds && (isIamCredentials(creds) || isBearerCredentials(creds))
9899
}
99100

100-
private async registerLspCredentialsUpdateHandlers() {
101+
private registerLspCredentialsUpdateHandlers() {
101102
this.registerIamCredentialsUpdateHandlers()
102103
this.registerBearerCredentialsUpdateHandlers()
103104
}
@@ -166,11 +167,11 @@ export class Auth {
166167
private setCredentials(creds: Credentials) {
167168
if (this.areValidCredentials(creds)) {
168169
if (isIamCredentials(creds)) {
169-
this.iamCredentials = creds as IamCredentials
170+
this.iamCredentials = creds
170171
// Prevent modifying credentials by implementors
171172
Object.freeze(this.iamCredentials)
172173
} else {
173-
this.bearerCredentials = creds as BearerCredentials
174+
this.bearerCredentials = creds
174175
Object.freeze(this.bearerCredentials)
175176
}
176177
}

runtimes/runtimes/auth/standalone/encryption.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Readable } from 'stream'
22
import { CompactEncrypt } from 'jose'
33

44
export function shouldWaitForEncryptionKey(): boolean {
5-
return process.argv.some(arg => arg === '--set-credentials-encryption-key')
5+
return process.argv.includes('--set-credentials-encryption-key')
66
}
77

88
export type CredentialsEncoding = 'JWT'
@@ -38,7 +38,7 @@ export function validateEncryptionDetails(encryptionDetails: EncryptionInitializ
3838
}
3939

4040
if (encryptionDetails.mode !== 'JWT') {
41-
throw new Error(`Unsupported encoding mode: ${encryptionDetails.mode}`)
41+
throw new Error(`Unsupported encoding mode: ${String(encryptionDetails.mode)}`)
4242
}
4343
}
4444

@@ -65,9 +65,9 @@ export function readEncryptionDetails(stream: Readable): Promise<EncryptionIniti
6565

6666
// Fires when the stream has contents that can be read
6767
const onStreamIsReadable = () => {
68-
let byteRead
68+
let byteRead: Buffer | null
6969
while ((byteRead = stream.read(1)) !== null) {
70-
if (byteRead.toString('utf-8') == '\n') {
70+
if (byteRead.toString('utf-8') === '\n') {
7171
clearTimer()
7272
// Stop reading this stream, we have read a line from it
7373
stream.removeListener('readable', onStreamIsReadable)
@@ -90,7 +90,12 @@ export function readEncryptionDetails(stream: Readable): Promise<EncryptionIniti
9090
/**
9191
* Encrypt an object with the provided key
9292
*/
93-
export function encryptObjectWithKey(request: Object, key: string, alg?: string, enc?: string): Promise<string> {
93+
export function encryptObjectWithKey(
94+
request: NonNullable<unknown>,
95+
key: string,
96+
alg?: string,
97+
enc?: string
98+
): Promise<string> {
9499
const payload = new TextEncoder().encode(JSON.stringify(request))
95100
const keyBuffer = Buffer.from(key, 'base64')
96101
return new CompactEncrypt(payload)
@@ -126,8 +131,8 @@ export function isMessageJWEEncrypted(message: string, algorithm: string, encodi
126131
if (
127132
protectedHeader.alg &&
128133
protectedHeader.enc &&
129-
protectedHeader.alg == algorithm &&
130-
protectedHeader.enc == encoding
134+
protectedHeader.alg === algorithm &&
135+
protectedHeader.enc === encoding
131136
) {
132137
return true
133138
}

runtimes/runtimes/base-runtime.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,10 @@ import {
4444
inlineChatResultNotificationType,
4545
listConversationsRequestType,
4646
conversationClickRequestType,
47-
GetSerializedChatParams,
48-
GetSerializedChatResult,
49-
RequestHandler,
50-
TabBarActionParams,
51-
TabBarActionResult,
5247
getSerializedChatRequestType,
5348
tabBarActionRequestType,
5449
chatOptionsUpdateType,
5550
promptInputOptionChangeNotificationType,
56-
buttonClickRequestType,
5751
} from '../protocol'
5852
import { createConnection } from 'vscode-languageserver/browser'
5953
import {
@@ -122,10 +116,11 @@ export const baseRuntime = (connections: { reader: MessageReader; writer: Messag
122116
// Set up the workspace to use the LSP Text Documents component
123117
const defaultHomeDir = '/home/user'
124118
const workspace: Workspace = {
125-
getTextDocument: async uri => documents.get(uri),
126-
getAllTextDocuments: async () => documents.all(),
127-
getWorkspaceFolder: _uri =>
128-
lspRouter.clientInitializeParams!.workspaceFolders && lspRouter.clientInitializeParams!.workspaceFolders[0],
119+
getTextDocument: uri => Promise.resolve(documents.get(uri)),
120+
getAllTextDocuments: () => Promise.resolve(documents.all()),
121+
getWorkspaceFolder: _ =>
122+
lspRouter.clientInitializeParams?.workspaceFolders &&
123+
lspRouter.clientInitializeParams.workspaceFolders?.[0],
129124
fs: {
130125
copyFile: (_src, _dest, _options?) => Promise.resolve(),
131126
exists: _path => Promise.resolve(false),
@@ -166,10 +161,10 @@ export const baseRuntime = (connections: { reader: MessageReader; writer: Messag
166161
onFollowUpClicked: handler => lspConnection.onNotification(followUpClickNotificationType.method, handler),
167162
chatOptionsUpdate: params => lspConnection.sendNotification(chatOptionsUpdateType.method, params),
168163
openTab: params => lspConnection.sendRequest(openTabRequestType.method, params),
169-
onButtonClick: params => lspConnection.onRequest(buttonClickRequestType.method, params),
170-
sendChatUpdate: params => lspConnection.sendNotification(chatUpdateNotificationType.method, params),
164+
sendChatUpdate: params => () => lspConnection.sendNotification(chatUpdateNotificationType.method, params),
171165
onFileClicked: handler => lspConnection.onNotification(fileClickNotificationType.method, handler),
172-
sendContextCommands: params => lspConnection.sendNotification(contextCommandsNotificationType.method, params),
166+
sendContextCommands: params => () =>
167+
lspConnection.sendNotification(contextCommandsNotificationType.method, params),
173168
onCreatePrompt: handler => lspConnection.onNotification(createPromptNotificationType.method, handler),
174169
onInlineChatResult: handler => lspConnection.onNotification(inlineChatResultNotificationType.method, handler),
175170
onListConversations: handler => lspConnection.onRequest(listConversationsRequestType.method, handler),
@@ -185,7 +180,7 @@ export const baseRuntime = (connections: { reader: MessageReader; writer: Messag
185180
onUpdateProfile: handler => lspConnection.onRequest(updateProfileRequestType, handler),
186181
onGetSsoToken: handler => lspConnection.onRequest(getSsoTokenRequestType, handler),
187182
onInvalidateSsoToken: handler => lspConnection.onRequest(invalidateSsoTokenRequestType, handler),
188-
sendSsoTokenChanged: params => lspConnection.sendNotification(ssoTokenChangedRequestType, params),
183+
sendSsoTokenChanged: params => () => lspConnection.sendNotification(ssoTokenChangedRequestType, params),
189184
}
190185

191186
// Set up auth without encryption
@@ -197,7 +192,7 @@ export const baseRuntime = (connections: { reader: MessageReader; writer: Messag
197192
version: props.version,
198193
},
199194
platform: 'browser',
200-
getConfiguration(key: string) {
195+
getConfiguration(_key: string) {
201196
return undefined
202197
},
203198
}
@@ -238,8 +233,10 @@ export const baseRuntime = (connections: { reader: MessageReader; writer: Messag
238233
onDidDeleteFiles: params => lspConnection.workspace.onDidDeleteFiles(params),
239234
onDidRenameFiles: params => lspConnection.workspace.onDidRenameFiles(params),
240235
onUpdateConfiguration: lspServer.setUpdateConfigurationHandler,
241-
selectWorkspaceItem: params => lspConnection.sendRequest(selectWorkspaceItemRequestType.method, params),
242-
openFileDiff: params => lspConnection.sendNotification(openFileDiffNotificationType.method, params),
236+
selectWorkspaceItem: params => () =>
237+
lspConnection.sendRequest(selectWorkspaceItemRequestType.method, params),
238+
openFileDiff: params => () =>
239+
lspConnection.sendNotification(openFileDiffNotificationType.method, params),
243240
},
244241
window: {
245242
showMessage: params => lspConnection.sendNotification(ShowMessageNotification.method, params),
@@ -298,7 +295,9 @@ export const baseRuntime = (connections: { reader: MessageReader; writer: Messag
298295

299296
// Free up any resources or threads used by Servers
300297
lspConnection.onExit(() => {
301-
disposables.forEach(d => d())
298+
for (const d of disposables) {
299+
d()
300+
}
302301
})
303302

304303
// Initialize the documents listener and start the LSP connection

runtimes/runtimes/chat/baseChat.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,28 @@ export class BaseChat implements Chat {
137137
}
138138

139139
public chatOptionsUpdate(params: ChatOptionsUpdateParams): void {
140-
this.connection.sendNotification(chatOptionsUpdateType.method, params)
140+
this.connection
141+
.sendNotification(chatOptionsUpdateType.method, params)
142+
.then(() => {})
143+
.catch(() => {})
141144
}
142145

143146
public sendChatUpdate(params: ChatUpdateParams) {
144-
this.connection.sendNotification(chatUpdateNotificationType.method, params)
147+
this.connection
148+
.sendNotification(chatUpdateNotificationType.method, params)
149+
.then(() => {})
150+
.catch(() => {})
145151
}
146152

147153
public onFileClicked(handler: NotificationHandler<FileClickParams>) {
148154
this.connection.onNotification(fileClickNotificationType.method, handler)
149155
}
150156

151157
public sendContextCommands(params: ContextCommandParams) {
152-
this.connection.sendNotification(contextCommandsNotificationType.method, params)
158+
this.connection
159+
.sendNotification(contextCommandsNotificationType.method, params)
160+
.then(() => {})
161+
.catch(() => {})
153162
}
154163

155164
public onCreatePrompt(handler: NotificationHandler<CreatePromptParams>) {

runtimes/runtimes/encoding.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ export interface Encoding {
33
encode(value: string): string
44
}
55

6-
const HEX_PAD: string = '00'
7-
const HEX_REGEX: RegExp = /%([0-9A-F]{2})/g
6+
const HEX_PAD = '00'
7+
const HEX_REGEX = /%([0-9A-F]{2})/g
88
export class WebBase64Encoding implements Encoding {
99
constructor(private window: WindowOrWorkerGlobalScope) {}
1010

@@ -22,7 +22,7 @@ export class WebBase64Encoding implements Encoding {
2222

2323
encode(value: string): string {
2424
// to support Unicode chars
25-
const converted = encodeURIComponent(value).replace(HEX_REGEX, (_, arg) => {
25+
const converted = encodeURIComponent(value).replace(HEX_REGEX, (_, arg: string) => {
2626
return String.fromCharCode(parseInt(arg, 16))
2727
})
2828
return this.window.btoa(converted)

0 commit comments

Comments
 (0)