diff --git a/eslint.config.js b/eslint.config.js index 4811f9625e9..5f42abbc744 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1487,32 +1487,27 @@ export default tseslint.config( '@typescript-eslint/no-base-to-string': 'error', '@typescript-eslint/no-confusing-non-null-assertion': 'error', '@typescript-eslint/no-confusing-void-expression': 'error', - // '@typescript-eslint/no-duplicate-enum-values': 'error', - // '@typescript-eslint/no-dynamic-delete': 'error', - // 'no-empty-function': 'off', '@typescript-eslint/no-empty-function': [ - // 'error', - // { - // 'allow': [ - // 'private-constructors' - // ] - // } - // ], - // '@typescript-eslint/no-empty-object-type': 'error', - // '@typescript-eslint/no-explicit-any': 'error', - // '@typescript-eslint/no-extra-non-null-assertion': 'error', - // '@typescript-eslint/no-extraneous-class': 'error', + '@typescript-eslint/no-duplicate-enum-values': 'error', + '@typescript-eslint/no-dynamic-delete': 'error', + 'no-empty-function': 'off', '@typescript-eslint/no-empty-function': [ + 'error', { 'allow': ['private-constructors'] } + ], + '@typescript-eslint/no-empty-object-type': 'error', + '@typescript-eslint/no-explicit-any': ['error', { 'ignoreRestArgs': true }], + '@typescript-eslint/no-extra-non-null-assertion': 'error', + '@typescript-eslint/no-extraneous-class': 'error', + '@typescript-eslint/no-for-in-array': 'error', + 'no-implied-eval': 'off', '@typescript-eslint/no-implied-eval': 'error', + '@typescript-eslint/no-invalid-void-type': 'error', + 'no-loop-func': 'off', '@typescript-eslint/no-loop-func': 'error', + '@typescript-eslint/no-misused-new': 'warn', + '@typescript-eslint/no-mixed-enums': 'error', // '@typescript-eslint/no-floating-promises': 'error', - // '@typescript-eslint/no-for-in-array': 'error', - // 'no-implied-eval': 'off', '@typescript-eslint/no-implied-eval': 'error', - // '@typescript-eslint/no-invalid-void-type': 'error', - // 'no-loop-func': 'off', '@typescript-eslint/no-loop-func': 'error', - // '@typescript-eslint/no-misused-new': 'warn', // '@typescript-eslint/no-misused-promises': 'error', - // '@typescript-eslint/no-mixed-enums': 'error', - // '@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error', - // '@typescript-eslint/no-non-null-asserted-optional-chain': 'error', - // '@typescript-eslint/no-non-null-assertion': 'error', - // '@typescript-eslint/no-redundant-type-constituents': 'error', + '@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error', + '@typescript-eslint/no-non-null-asserted-optional-chain': 'error', + '@typescript-eslint/no-non-null-assertion': 'error', + '@typescript-eslint/no-redundant-type-constituents': 'error', '@typescript-eslint/naming-convention': [ 'warn', { 'selector': 'variable', 'format': ['camelCase', 'UPPER_CASE', 'PascalCase'] }, diff --git a/src/vs/editor/common/codecs/simpleCodec/parserBase.ts b/src/vs/editor/common/codecs/simpleCodec/parserBase.ts index afd3051309e..3df13577159 100644 --- a/src/vs/editor/common/codecs/simpleCodec/parserBase.ts +++ b/src/vs/editor/common/codecs/simpleCodec/parserBase.ts @@ -111,7 +111,7 @@ export abstract class ParserBase { * * @throws the resulting decorated method throws if the parser object was already consumed. */ -export function assertNotConsumed>( +export function assertNotConsumed>( _target: T, propertyKey: 'accept', descriptor: PropertyDescriptor, diff --git a/src/vs/editor/common/codecs/utils/tokenStream.ts b/src/vs/editor/common/codecs/utils/tokenStream.ts index a09c3a9858c..94585882bb6 100644 --- a/src/vs/editor/common/codecs/utils/tokenStream.ts +++ b/src/vs/editor/common/codecs/utils/tokenStream.ts @@ -64,7 +64,7 @@ export class TokenStream extends ObservableDisposable imple } // periodically send tokens to the stream - this.interval = setInterval(() => { + this.interval = setInterval(async () => { if (this.tokensLeft === 0) { clearInterval(this.interval); delete this.interval; @@ -72,7 +72,7 @@ export class TokenStream extends ObservableDisposable imple return; } - this.sendTokens(); + await this.sendTokens(); }, 1); return this; @@ -95,9 +95,9 @@ export class TokenStream extends ObservableDisposable imple /** * Sends a provided number of tokens to the stream. */ - private sendTokens( + private async sendTokens( tokensCount: number = 25, - ): void { + ): Promise { if (this.tokensLeft <= 0) { return; } @@ -110,9 +110,14 @@ export class TokenStream extends ObservableDisposable imple `Token index '${this.index}' is out of bounds.`, ); - this.stream.write(this.tokens[this.index]); - this.index++; - tokensToSend--; + try { + await this.stream.write(this.tokens[this.index]); + this.index++; + tokensToSend--; + } catch { + this.stopStream(); + return; + } } // if sent all tokens, end the stream immediately @@ -148,7 +153,7 @@ export class TokenStream extends ObservableDisposable imple public on(event: 'data', callback: (data: T) => void): void; public on(event: 'error', callback: (err: Error) => void): void; public on(event: 'end', callback: () => void): void; - public on(event: 'data' | 'error' | 'end', callback: (arg?: any) => void): void { + public on(event: 'data' | 'error' | 'end', callback: (...args: any[]) => void): void { if (event === 'data') { this.stream.on(event, callback); // this is the convention of the readable stream, - when diff --git a/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.ts b/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.ts index 5ec7f47ac1b..e6e561f1c6e 100644 --- a/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.ts +++ b/src/vs/workbench/contrib/chat/common/promptSyntax/contentProviders/textModelContentsProvider.ts @@ -79,7 +79,7 @@ export class TextModelContentsProvider extends PromptContentsProviderBase { + const interval = setInterval(async () => { // if we have written all lines or lines count is zero, // end the stream and stop the interval timer if (i >= linesCount) { @@ -99,14 +99,14 @@ export class TextModelContentsProvider extends PromptContentsProviderBase { + this.logService.warn('failed to migrate config setting value.', error); + }); + } + + /** + * The main function that implements the migration logic. + */ + private async migrateConfig(): Promise { + const value = await this.configService.getValue(CONFIG_KEY); // if setting is not set, nothing to do if ((value === undefined) || (value === null)) { @@ -49,8 +62,8 @@ export class ConfigMigration implements IWorkbenchContribution { locationsValue[trimmedValue] = true; } - configService.updateValue(CONFIG_KEY, true); - configService.updateValue(PROMPT_LOCATIONS_CONFIG_KEY, locationsValue); + await this.configService.updateValue(CONFIG_KEY, true); + await this.configService.updateValue(PROMPT_LOCATIONS_CONFIG_KEY, locationsValue); return; } @@ -82,8 +95,8 @@ export class ConfigMigration implements IWorkbenchContribution { locationsValue[trimmedValue] = enabled; } - configService.updateValue(CONFIG_KEY, true); - configService.updateValue(PROMPT_LOCATIONS_CONFIG_KEY, locationsValue); + await this.configService.updateValue(CONFIG_KEY, true); + await this.configService.updateValue(PROMPT_LOCATIONS_CONFIG_KEY, locationsValue); return; } @@ -99,8 +112,8 @@ export class ConfigMigration implements IWorkbenchContribution { `String value must not be a boolean, got '${value}'.`, ); - configService.updateValue(CONFIG_KEY, true); - configService.updateValue(PROMPT_LOCATIONS_CONFIG_KEY, { [value]: true }); + await this.configService.updateValue(CONFIG_KEY, true); + await this.configService.updateValue(PROMPT_LOCATIONS_CONFIG_KEY, { [value]: true }); return; } } diff --git a/src/vs/workbench/contrib/chat/common/promptSyntax/utils/treeUtils.ts b/src/vs/workbench/contrib/chat/common/promptSyntax/utils/treeUtils.ts index 6c596c3ab7f..cdc81e77ec4 100644 --- a/src/vs/workbench/contrib/chat/common/promptSyntax/utils/treeUtils.ts +++ b/src/vs/workbench/contrib/chat/common/promptSyntax/utils/treeUtils.ts @@ -127,14 +127,14 @@ export const map = < * Type for a rest parameters of function, excluding * the first argument. */ -type TRestParameters any> = - T extends (first: any, ...rest: infer R) => any ? R : never; +type TRestParameters unknown> = + T extends (first: Parameters[0], ...rest: infer R) => unknown ? R : never; /** * Type for a curried function. * See {@link curry} for more info. */ -type TCurriedFunction any> = ((...args: TRestParameters) => ReturnType); +type TCurriedFunction unknown> = ((...args: TRestParameters) => ReturnType); /** * Curry a provided function with the first argument.