auto-fixed prefer-const violation

This commit is contained in:
Johannes
2022-06-08 17:49:21 +02:00
parent aa23a0dbb7
commit 0656d21d11
862 changed files with 6489 additions and 6489 deletions

View File

@@ -180,7 +180,7 @@ configurationExtPoint.setHandler((extensions, { added, removed }) => {
function handleConfiguration(node: IConfigurationNode, extension: IExtensionPointUser<any>): IConfigurationNode[] {
const configurations: IConfigurationNode[] = [];
let configuration = objects.deepClone(node);
const configuration = objects.deepClone(node);
if (configuration.title && (typeof configuration.title !== 'string')) {
extension.collector.error(nls.localize('invalid.title', "'configuration.title' must be a string"));
@@ -197,13 +197,13 @@ configurationExtPoint.setHandler((extensions, { added, removed }) => {
}
function validateProperties(configuration: IConfigurationNode, extension: IExtensionPointUser<any>): void {
let properties = configuration.properties;
const properties = configuration.properties;
if (properties) {
if (typeof properties !== 'object') {
extension.collector.error(nls.localize('invalid.properties', "'configuration.properties' must be an object"));
configuration.properties = {};
}
for (let key in properties) {
for (const key in properties) {
const propertyConfiguration = properties[key];
const message = validateProperty(key, propertyConfiguration);
if (message) {
@@ -241,10 +241,10 @@ configurationExtPoint.setHandler((extensions, { added, removed }) => {
}
}
}
let subNodes = configuration.allOf;
const subNodes = configuration.allOf;
if (subNodes) {
extension.collector.error(nls.localize('invalid.allOf', "'configuration.allOf' is deprecated and should no longer be used. Instead, pass multiple configuration sections as an array to the 'configuration' contribution point."));
for (let node of subNodes) {
for (const node of subNodes) {
validateProperties(node, extension);
}
}
@@ -252,7 +252,7 @@ configurationExtPoint.setHandler((extensions, { added, removed }) => {
if (added.length) {
const addedConfigurations: IConfigurationNode[] = [];
for (let extension of added) {
for (const extension of added) {
const configurations: IConfigurationNode[] = [];
const value = <IConfigurationNode | IConfigurationNode[]>extension.value;
if (Array.isArray(value)) {

View File

@@ -222,7 +222,7 @@ export class ExtHostCommands implements ExtHostCommandsShape {
throw new Error('Unknown command');
}
this._reportTelemetry(command, id);
let { callback, thisArg, description } = command;
const { callback, thisArg, description } = command;
if (description) {
for (let i = 0; i < description.args.length; i++) {
try {
@@ -304,8 +304,8 @@ export class ExtHostCommands implements ExtHostCommandsShape {
$getContributedCommandHandlerDescriptions(): Promise<{ [id: string]: string | ICommandHandlerDescriptionDto }> {
const result: { [id: string]: string | ICommandHandlerDescription } = Object.create(null);
for (let [id, command] of this._commands) {
let { description } = command;
for (const [id, command] of this._commands) {
const { description } = command;
if (description) {
result[id] = description;
}

View File

@@ -96,9 +96,9 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
return arg;
}
let commentUniqueId = arg.commentUniqueId;
const commentUniqueId = arg.commentUniqueId;
let comment = commentThread.getCommentByUniqueId(commentUniqueId);
const comment = commentThread.getCommentByUniqueId(commentUniqueId);
if (!comment) {
return arg;
@@ -119,10 +119,10 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
return arg;
}
let body = arg.text;
let commentUniqueId = arg.commentUniqueId;
const body = arg.text;
const commentUniqueId = arg.commentUniqueId;
let comment = commentThread.getCommentByUniqueId(commentUniqueId);
const comment = commentThread.getCommentByUniqueId(commentUniqueId);
if (!comment) {
return arg;
@@ -487,9 +487,9 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
}
getCommentByUniqueId(uniqueId: number): vscode.Comment | undefined {
for (let key of this._commentsMap) {
let comment = key[0];
let id = key[1];
for (const key of this._commentsMap) {
const comment = key[0];
const id = key[1];
if (uniqueId === id) {
return comment;
}
@@ -613,14 +613,14 @@ export function createExtHostComments(mainContext: IMainContext, commands: ExtHo
}
$updateCommentThreadTemplate(threadHandle: number, range: IRange): void {
let thread = this._threads.get(threadHandle);
const thread = this._threads.get(threadHandle);
if (thread) {
thread.range = extHostTypeConverter.Range.to(range);
}
}
$deleteCommentThread(threadHandle: number): void {
let thread = this._threads.get(threadHandle);
const thread = this._threads.get(threadHandle);
if (thread) {
thread.dispose();

View File

@@ -47,7 +47,7 @@ export class ExtHostDecorations implements ExtHostDecorationsShape {
this._proxy.$onDidChange(handle, null);
return;
}
let array = asArray(e);
const array = asArray(e);
if (array.length <= ExtHostDecorations._maxEventSize) {
this._proxy.$onDidChange(handle, array);
return;
@@ -58,11 +58,11 @@ export class ExtHostDecorations implements ExtHostDecorationsShape {
this._logService.warn('[Decorations] CAPPING events from decorations provider', extensionId.value, array.length);
const mapped = array.map(uri => ({ uri, rank: count(uri.path, '/') }));
const groups = groupBy(mapped, (a, b) => a.rank - b.rank || compare(a.uri.path, b.uri.path));
let picked: URI[] = [];
outer: for (let uris of groups) {
const picked: URI[] = [];
outer: for (const uris of groups) {
let lastDirname: string | undefined;
for (let obj of uris) {
let myDirname = dirname(obj.uri.path);
for (const obj of uris) {
const myDirname = dirname(obj.uri.path);
if (lastDirname !== myDirname) {
lastDirname = myDirname;
if (picked.push(obj.uri) >= ExtHostDecorations._maxEventSize) {

View File

@@ -123,7 +123,7 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
return;
}
const entries: [URI, IMarkerData[]][] = [];
for (let uri of toSync) {
for (const uri of toSync) {
let marker: IMarkerData[] = [];
const diagnostics = this.#data.get(uri);
if (diagnostics) {
@@ -133,7 +133,7 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
marker = [];
const order = [DiagnosticSeverity.Error, DiagnosticSeverity.Warning, DiagnosticSeverity.Information, DiagnosticSeverity.Hint];
orderLoop: for (let i = 0; i < 4; i++) {
for (let diagnostic of diagnostics) {
for (const diagnostic of diagnostics) {
if (diagnostic.severity === order[i]) {
const len = marker.push(converter.Diagnostic.from(diagnostic));
if (len === this._maxDiagnosticsPerFile) {
@@ -182,7 +182,7 @@ export class DiagnosticCollection implements vscode.DiagnosticCollection {
forEach(callback: (uri: URI, diagnostics: ReadonlyArray<vscode.Diagnostic>, collection: DiagnosticCollection) => any, thisArg?: any): void {
this._checkDisposed();
for (let uri of this.#data.keys()) {
for (const uri of this.#data.keys()) {
callback.apply(thisArg, [uri, this.get(uri), this]);
}
}
@@ -317,7 +317,7 @@ export class ExtHostDiagnostics implements ExtHostDiagnosticsShape {
private _getDiagnostics(resource: vscode.Uri): ReadonlyArray<vscode.Diagnostic> {
let res: vscode.Diagnostic[] = [];
for (let collection of this._collections.values()) {
for (const collection of this._collections.values()) {
if (collection.has(resource)) {
res = res.concat(collection.get(resource));
}

View File

@@ -55,7 +55,7 @@ export class ExtHostDocumentSaveParticipant implements ExtHostDocumentSavePartic
const results: boolean[] = [];
try {
for (let listener of [...this._callbacks]) { // copy to prevent concurrent modifications
for (const listener of [...this._callbacks]) { // copy to prevent concurrent modifications
if (didTimeout) {
// timeout - no more listeners
break;

View File

@@ -910,8 +910,8 @@ export abstract class AbstractExtHostExtensionService extends Disposable impleme
}
public async $test_down(size: number): Promise<VSBuffer> {
let buff = VSBuffer.alloc(size);
let value = Math.random() % 256;
const buff = VSBuffer.alloc(size);
const value = Math.random() % 256;
for (let i = 0; i < size; i++) {
buff.writeUInt8(value, i);
}

View File

@@ -171,7 +171,7 @@ export class ExtHostFileSystem implements ExtHostFileSystemShape {
const subscription = provider.onDidChangeFile(event => {
const mapped: IFileChangeDto[] = [];
for (const e of event) {
let { uri: resource, type } = e;
const { uri: resource, type } = e;
if (resource.scheme !== scheme) {
// dropping events for wrong scheme
continue;

View File

@@ -63,7 +63,7 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
const subscription = dispatcher(events => {
if (!ignoreCreateEvents) {
for (let created of events.created) {
for (const created of events.created) {
const uri = URI.revive(created);
if (parsedPattern(uri.fsPath) && (!excludeOutOfWorkspaceEvents || workspace.getWorkspaceFolder(uri))) {
this._onDidCreate.fire(uri);
@@ -71,7 +71,7 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
}
}
if (!ignoreChangeEvents) {
for (let changed of events.changed) {
for (const changed of events.changed) {
const uri = URI.revive(changed);
if (parsedPattern(uri.fsPath) && (!excludeOutOfWorkspaceEvents || workspace.getWorkspaceFolder(uri))) {
this._onDidChange.fire(uri);
@@ -79,7 +79,7 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
}
}
if (!ignoreDeleteEvents) {
for (let deleted of events.deleted) {
for (const deleted of events.deleted) {
const uri = URI.revive(deleted);
if (parsedPattern(uri.fsPath) && (!excludeOutOfWorkspaceEvents || workspace.getWorkspaceFolder(uri))) {
this._onDidDelete.fire(uri);
@@ -92,7 +92,7 @@ class FileSystemWatcher implements vscode.FileSystemWatcher {
}
private ensureWatching(mainContext: IMainContext, extension: IExtensionDescription, globPattern: string | IRelativePatternDto): Disposable {
let disposable = Disposable.from();
const disposable = Disposable.from();
if (typeof globPattern === 'string') {
return disposable; // a pattern alone does not carry sufficient information to start watching anything
@@ -249,8 +249,8 @@ export class ExtHostFileSystemEventService implements ExtHostFileSystemEventServ
// concat all WorkspaceEdits collected via waitUntil-call and send them over to the renderer
const dto: IWorkspaceEditDto = { edits: [] };
for (let edit of edits) {
let { edits } = typeConverter.WorkspaceEdit.from(edit, {
for (const edit of edits) {
const { edits } = typeConverter.WorkspaceEdit.from(edit, {
getTextDocumentVersion: uri => this._extHostDocumentsAndEditors.getDocument(uri)?.version,
getNotebookDocumentVersion: () => undefined,
});

View File

@@ -1454,7 +1454,7 @@ class InlayHintsAdapter {
result.label = hint.label;
} else {
result.label = hint.label.map(part => {
let result: languages.InlayHintLabelPart = { label: part.value };
const result: languages.InlayHintLabelPart = { label: part.value };
result.tooltip = typeConvert.MarkdownString.fromStrict(part.tooltip);
if (Location.isLocation(part.location)) {
result.location = typeConvert.location.from(part.location);
@@ -2508,7 +2508,7 @@ export class ExtHostLanguageFeatures implements extHostProtocol.ExtHostLanguageF
}
setLanguageConfiguration(extension: IExtensionDescription, languageId: string, configuration: vscode.LanguageConfiguration): vscode.Disposable {
let { wordPattern } = configuration;
const { wordPattern } = configuration;
// check for a valid word pattern
if (wordPattern && regExpLeadsToEndlessLoop(wordPattern)) {

View File

@@ -102,7 +102,7 @@ export class ExtHostLanguages implements ExtHostLanguagesShape {
};
let soonHandle: IDisposable | undefined;
let commandDisposables = new DisposableStore();
const commandDisposables = new DisposableStore();
const updateAsync = () => {
soonHandle?.dispose();
soonHandle = disposableTimeout(() => {

View File

@@ -78,7 +78,7 @@ export class ExtensionMemento implements vscode.Memento {
update(key: string, value: any): Promise<void> {
this._value![key] = value;
let record = this._deferredPromises.get(key);
const record = this._deferredPromises.get(key);
if (record !== undefined) {
return record.p;
}

View File

@@ -56,7 +56,7 @@ export class ExtHostMessageService {
if (typeof command === 'string') {
commands.push({ title: command, handle, isCloseAffordance: false });
} else if (typeof command === 'object') {
let { title, isCloseAffordance } = command;
const { title, isCloseAffordance } = command;
commands.push({ title, isCloseAffordance: !!isCloseAffordance, handle });
} else {
this._logService.warn('Invalid message item:', command);

View File

@@ -366,7 +366,7 @@ export class ExtHostNotebookDocument {
});
if (bucket) {
for (let changeEvent of contentChangeEvents) {
for (const changeEvent of contentChangeEvents) {
bucket.push(changeEvent.asApiEvent());
}
}

View File

@@ -73,7 +73,7 @@ export abstract class RequireInterceptor {
public register(interceptor: INodeModuleFactory | IAlternativeModuleProvider): void {
if ('nodeModuleName' in interceptor) {
if (Array.isArray(interceptor.nodeModuleName)) {
for (let moduleName of interceptor.nodeModuleName) {
for (const moduleName of interceptor.nodeModuleName) {
this._factories.set(moduleName, interceptor);
}
} else {

View File

@@ -175,7 +175,7 @@ export namespace ShellExecutionDTO {
export namespace CustomExecutionDTO {
export function is(value: tasks.IShellExecutionDTO | tasks.IProcessExecutionDTO | tasks.ICustomExecutionDTO | undefined): value is tasks.ICustomExecutionDTO {
if (value) {
let candidate = value as tasks.ICustomExecutionDTO;
const candidate = value as tasks.ICustomExecutionDTO;
return candidate && candidate.customExecution === 'customExecution';
} else {
return false;
@@ -227,7 +227,7 @@ export namespace TaskDTO {
return [];
}
const result: tasks.ITaskDTO[] = [];
for (let task of tasks) {
for (const task of tasks) {
const converted = from(task, extension);
if (converted) {
result.push(converted);
@@ -460,7 +460,7 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape, IExtHostTask
public fetchTasks(filter?: vscode.TaskFilter): Promise<vscode.Task[]> {
return this._proxy.$fetchTasks(TaskFilterDTO.from(filter)).then(async (values) => {
const result: vscode.Task[] = [];
for (let value of values) {
for (const value of values) {
const task = await TaskDTO.to(value, this._workspaceProvider, this._providedCustomExecutions2);
if (task) {
result.push(task);
@@ -636,7 +636,7 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape, IExtHostTask
return taskExecution;
}
let result: Promise<TaskExecutionImpl> | undefined = this._taskExecutionPromises.get(execution.id);
const result: Promise<TaskExecutionImpl> | undefined = this._taskExecutionPromises.get(execution.id);
if (result) {
return result;
}
@@ -687,7 +687,7 @@ export abstract class ExtHostTaskBase implements ExtHostTaskShape, IExtHostTask
this._providedCustomExecutions2.delete(execution.id);
this._notProvidedCustomExecutions.delete(execution.id);
}
let iterator = this._notProvidedCustomExecutions.values();
const iterator = this._notProvidedCustomExecutions.values();
let iteratorResult = iterator.next();
while (!iteratorResult.done) {
if (!this._activeCustomExecutions2.has(iteratorResult.value) && (this._lastStartedTask !== iteratorResult.value)) {
@@ -750,7 +750,7 @@ export class WorkerExtHostTask extends ExtHostTaskBase {
protected provideTasksInternal(validTypes: { [key: string]: boolean }, taskIdPromises: Promise<void>[], handler: HandlerData, value: vscode.Task[] | null | undefined): { tasks: tasks.ITaskDTO[]; extension: IExtensionDescription } {
const taskDTOs: tasks.ITaskDTO[] = [];
if (value) {
for (let task of value) {
for (const task of value) {
this.checkDeprecation(task, handler);
if (!task.definition || !validTypes[task.definition.type]) {
this._logService.warn(`The task [${task.source}, ${task.name}] uses an undefined task type. The task will be ignored in the future.`);

View File

@@ -1574,7 +1574,7 @@ export namespace NotebookData {
metadata: data.metadata ?? Object.create(null),
cells: [],
};
for (let cell of data.cells) {
for (const cell of data.cells) {
types.NotebookCellData.validate(cell);
res.cells.push(NotebookCellData.from(cell));
}

View File

@@ -97,7 +97,7 @@ export class Position {
if (other instanceof Position) {
return true;
}
let { line, character } = <Position>other;
const { line, character } = <Position>other;
if (typeof line === 'number' && typeof character === 'number') {
return true;
}
@@ -822,7 +822,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
get(uri: URI): TextEdit[] {
const res: TextEdit[] = [];
for (let candidate of this._edits) {
for (const candidate of this._edits) {
if (candidate._type === FileEditType.Text && candidate.uri.toString() === uri.toString()) {
res.push(candidate.edit);
}
@@ -832,7 +832,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
entries(): [URI, TextEdit[]][] {
const textEdits = new ResourceMap<[URI, TextEdit[]]>();
for (let candidate of this._edits) {
for (const candidate of this._edits) {
if (candidate._type === FileEditType.Text) {
let textEdit = textEdits.get(candidate.uri);
if (!textEdit) {
@@ -2030,7 +2030,7 @@ export class ProcessExecution implements vscode.ProcessExecution {
props.push(this._process);
}
if (this._args && this._args.length > 0) {
for (let arg of this._args) {
for (const arg of this._args) {
props.push(arg);
}
}
@@ -2116,7 +2116,7 @@ export class ShellExecution implements vscode.ShellExecution {
props.push(typeof this._command === 'string' ? this._command : this._command.value);
}
if (this._args && this._args.length > 0) {
for (let arg of this._args) {
for (const arg of this._args) {
props.push(typeof arg === 'string' ? arg : arg.value);
}
}
@@ -3006,7 +3006,7 @@ export class SemanticTokensBuilder {
}
private static _sortAndDeltaEncode(data: number[]): Uint32Array {
let pos: number[] = [];
const pos: number[] = [];
const tokenCount = (data.length / 5) | 0;
for (let i = 0; i < tokenCount; i++) {
pos[i] = i;

View File

@@ -58,7 +58,7 @@ export class JSONValidationExtensionPoint {
collector.error(nls.localize('invalid.fileMatch', "'configuration.jsonValidation.fileMatch' must be defined as a string or an array of strings."));
return;
}
let uri = extension.url;
const uri = extension.url;
if (!isString(uri)) {
collector.error(nls.localize('invalid.url', "'configuration.jsonValidation.url' must be a URL or relative path"));
return;