Skip to content

Commit

Permalink
chore - push workaround and a lint rule for evanw/esbuild#3823 (micro…
Browse files Browse the repository at this point in the history
…soft#220077)

* chore - push workaround and a lint rule for evanw/esbuild#3823

* modernize `tsconfig.monaco`
  • Loading branch information
jrieken authored Jul 5, 2024
1 parent 7c8097d commit 80bdfeb
Show file tree
Hide file tree
Showing 16 changed files with 102 additions and 36 deletions.
56 changes: 56 additions & 0 deletions .eslintplugin/code-no-static-self-ref.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as eslint from 'eslint';
import { TSESTree } from '@typescript-eslint/experimental-utils';

/**
* WORKAROUND for https://github.com/evanw/esbuild/issues/3823
*/
export = new class implements eslint.Rule.RuleModule {

create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener {

function checkProperty(inNode: any) {

const classDeclaration = context.getAncestors().find(node => node.type === 'ClassDeclaration');
const propertyDefinition = <TSESTree.PropertyDefinition>inNode;

if (!classDeclaration || !classDeclaration.id?.name) {
return;
}

if (!propertyDefinition.value) {
return;
}

const classCtor = classDeclaration.body.body.find(node => node.type === 'MethodDefinition' && node.kind === 'constructor')

if (!classCtor) {
return;
}

const name = classDeclaration.id.name;
const valueText = context.getSourceCode().getText(<any>propertyDefinition.value)

if (valueText.includes(name + '.')) {

if (classCtor.value?.type === 'FunctionExpression' && !classCtor.value.params.find((param: any) => param.type === 'TSParameterProperty' && param.decorators?.length > 0)) {
return
}

context.report({
loc: propertyDefinition.value.loc,
message: `Static properties in decorated classes should not reference the class they are defined in. Use 'this' instead. This is a workaround for https://github.com/evanw/esbuild/issues/3823.`
});
}

}

return {
'PropertyDefinition[static=true]': checkProperty,
};
}
};
12 changes: 11 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@
]
}
},
{
"files": [
"src/**/*.ts"
],
"rules": {
"local/code-no-static-self-ref": "warn"
}
},
{
"files": [
"src/vs/**/*.test.ts"
Expand Down Expand Up @@ -1090,7 +1098,9 @@
"local/code-no-runtime-import": [
"error",
{
"src/vs/workbench/contrib/notebook/browser/view/renderers/webviewPreloads.ts": ["**/*"]
"src/vs/workbench/contrib/notebook/browser/view/renderers/webviewPreloads.ts": [
"**/*"
]
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion src/tsconfig.monaco.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"moduleResolution": "classic",
"removeComments": false,
"preserveConstEnums": true,
"target": "es2018",
"target": "ES2022",
"sourceMap": false,
"declaration": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';

export class OverviewRulerFeature extends Disposable {
private static readonly ONE_OVERVIEW_WIDTH = 15;
public static readonly ENTIRE_DIFF_OVERVIEW_WIDTH = OverviewRulerFeature.ONE_OVERVIEW_WIDTH * 2;
public static readonly ENTIRE_DIFF_OVERVIEW_WIDTH = this.ONE_OVERVIEW_WIDTH * 2;
public readonly width = OverviewRulerFeature.ENTIRE_DIFF_OVERVIEW_WIDTH;

constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ export class InlineEditController extends Disposable {
static ID = 'editor.contrib.inlineEditController';

public static readonly inlineEditVisibleKey = 'inlineEditVisible';
public static readonly inlineEditVisibleContext = new RawContextKey<boolean>(InlineEditController.inlineEditVisibleKey, false);
public static readonly inlineEditVisibleContext = new RawContextKey<boolean>(this.inlineEditVisibleKey, false);
private _isVisibleContext = InlineEditController.inlineEditVisibleContext.bindTo(this.contextKeyService);

public static readonly cursorAtInlineEditKey = 'cursorAtInlineEdit';
public static readonly cursorAtInlineEditContext = new RawContextKey<boolean>(InlineEditController.cursorAtInlineEditKey, false);
public static readonly cursorAtInlineEditContext = new RawContextKey<boolean>(this.cursorAtInlineEditKey, false);
private _isCursorAtInlineEditContext = InlineEditController.cursorAtInlineEditContext.bindTo(this.contextKeyService);

public static get(editor: ICodeEditor): InlineEditController | null {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit

static PREFIX = '@';
static SCOPE_PREFIX = ':';
static PREFIX_BY_CATEGORY = `${AbstractGotoSymbolQuickAccessProvider.PREFIX}${AbstractGotoSymbolQuickAccessProvider.SCOPE_PREFIX}`;
static PREFIX_BY_CATEGORY = `${this.PREFIX}${this.SCOPE_PREFIX}`;

protected override readonly options: IGotoSymbolQuickAccessProviderOptions;

Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/common/extHostDiagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export class ExtHostDiagnostics implements ExtHostDiagnosticsShape {

private static _idPool: number = 0;
private static readonly _maxDiagnosticsPerFile: number = 1000;
private static readonly _maxDiagnosticsTotal: number = 1.1 * ExtHostDiagnostics._maxDiagnosticsPerFile;
private static readonly _maxDiagnosticsTotal: number = 1.1 * this._maxDiagnosticsPerFile;

private readonly _proxy: MainThreadDiagnosticsShape;
private readonly _collections = new Map<string, DiagnosticCollection>();
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/browser/parts/editor/editorPlaceholder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class WorkspaceTrustRequiredPlaceholderEditor extends EditorPlaceholder {
static readonly ID = 'workbench.editors.workspaceTrustRequiredEditor';
private static readonly LABEL = localize('trustRequiredEditor', "Workspace Trust Required");

static readonly DESCRIPTOR = EditorPaneDescriptor.create(WorkspaceTrustRequiredPlaceholderEditor, WorkspaceTrustRequiredPlaceholderEditor.ID, WorkspaceTrustRequiredPlaceholderEditor.LABEL);
static readonly DESCRIPTOR = EditorPaneDescriptor.create(WorkspaceTrustRequiredPlaceholderEditor, this.ID, this.LABEL);

constructor(
group: IEditorGroup,
Expand Down Expand Up @@ -223,7 +223,7 @@ export class ErrorPlaceholderEditor extends EditorPlaceholder {
private static readonly ID = 'workbench.editors.errorEditor';
private static readonly LABEL = localize('errorEditor', "Error Editor");

static readonly DESCRIPTOR = EditorPaneDescriptor.create(ErrorPlaceholderEditor, ErrorPlaceholderEditor.ID, ErrorPlaceholderEditor.LABEL);
static readonly DESCRIPTOR = EditorPaneDescriptor.create(ErrorPlaceholderEditor, this.ID, this.LABEL);

constructor(
group: IEditorGroup,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class NotificationsToasts extends Themable implements INotificationsToast
// Count for the number of notifications over 800ms...
interval: 800,
// ...and ensure we are not showing more than MAX_NOTIFICATIONS
limit: NotificationsToasts.MAX_NOTIFICATIONS
limit: this.MAX_NOTIFICATIONS
};

private readonly _onDidChangeVisibility = this._register(new Emitter<void>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class BulkEditPane extends ViewPane {
static readonly ctxGroupByFile = new RawContextKey('refactorPreview.groupByFile', true);
static readonly ctxHasCheckedChanges = new RawContextKey('refactorPreview.hasCheckedChanges', true);

private static readonly _memGroupByFile = `${BulkEditPane.ID}.groupByFile`;
private static readonly _memGroupByFile = `${this.ID}.groupByFile`;

private _tree!: WorkbenchAsyncDataTree<BulkFileOperations, BulkEditElement, FuzzyScore>;
private _treeDataSource!: BulkEditDataSource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ export class BulkEditPreviewProvider implements ITextModelContentProvider {

private static readonly Schema = 'vscode-bulkeditpreview-editor';

static emptyPreview = URI.from({ scheme: BulkEditPreviewProvider.Schema, fragment: 'empty' });
static emptyPreview = URI.from({ scheme: this.Schema, fragment: 'empty' });


static fromPreviewUri(uri: URI): URI {
Expand Down
8 changes: 4 additions & 4 deletions src/vs/workbench/contrib/chat/common/voiceChatService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ export class VoiceChatService extends Disposable implements IVoiceChatService {
private static readonly COMMAND_PREFIX = chatSubcommandLeader;

private static readonly PHRASES_LOWER = {
[VoiceChatService.AGENT_PREFIX]: 'at',
[VoiceChatService.COMMAND_PREFIX]: 'slash'
[this.AGENT_PREFIX]: 'at',
[this.COMMAND_PREFIX]: 'slash'
};

private static readonly PHRASES_UPPER = {
[VoiceChatService.AGENT_PREFIX]: 'At',
[VoiceChatService.COMMAND_PREFIX]: 'Slash'
[this.AGENT_PREFIX]: 'At',
[this.COMMAND_PREFIX]: 'Slash'
};

private static readonly CHAT_AGENT_ALIAS = new Map<string, string>([['vscode', 'code']]);
Expand Down
32 changes: 16 additions & 16 deletions src/vs/workbench/contrib/extensions/browser/extensionsActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ export class ButtonWithDropdownExtensionActionViewItem extends ActionWithDropdow

export class InstallAction extends ExtensionAction {

static readonly CLASS = `${ExtensionAction.LABEL_ACTION_CLASS} prominent install`;
private static readonly HIDE = `${InstallAction.CLASS} hide`;
static readonly CLASS = `${this.LABEL_ACTION_CLASS} prominent install`;
private static readonly HIDE = `${this.CLASS} hide`;

protected _manifest: IExtensionManifest | null = null;
set manifest(manifest: IExtensionManifest | null) {
Expand Down Expand Up @@ -862,8 +862,8 @@ export class UninstallAction extends ExtensionAction {

abstract class AbstractUpdateAction extends ExtensionAction {

private static readonly EnabledClass = `${ExtensionAction.LABEL_ACTION_CLASS} prominent update`;
private static readonly DisabledClass = `${AbstractUpdateAction.EnabledClass} disabled`;
private static readonly EnabledClass = `${this.LABEL_ACTION_CLASS} prominent update`;
private static readonly DisabledClass = `${this.EnabledClass} disabled`;

private readonly updateThrottler = new Throttler();

Expand Down Expand Up @@ -940,7 +940,7 @@ export class ToggleAutoUpdateForExtensionAction extends ExtensionAction {
static readonly LABEL = localize2('enableAutoUpdateLabel', "Auto Update");

private static readonly EnabledClass = `${ExtensionAction.EXTENSION_ACTION_CLASS} auto-update`;
private static readonly DisabledClass = `${ToggleAutoUpdateForExtensionAction.EnabledClass} hide`;
private static readonly DisabledClass = `${this.EnabledClass} hide`;

constructor(
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
Expand Down Expand Up @@ -1023,7 +1023,7 @@ export class ToggleAutoUpdatesForPublisherAction extends ExtensionAction {
export class MigrateDeprecatedExtensionAction extends ExtensionAction {

private static readonly EnabledClass = `${ExtensionAction.LABEL_ACTION_CLASS} migrate`;
private static readonly DisabledClass = `${MigrateDeprecatedExtensionAction.EnabledClass} disabled`;
private static readonly DisabledClass = `${this.EnabledClass} disabled`;

constructor(
private readonly small: boolean,
Expand Down Expand Up @@ -1213,7 +1213,7 @@ export class ManageExtensionAction extends DropDownExtensionAction {
static readonly ID = 'extensions.manage';

private static readonly Class = `${ExtensionAction.ICON_ACTION_CLASS} manage ` + ThemeIcon.asClassName(manageExtensionIcon);
private static readonly HideManageExtensionClass = `${ManageExtensionAction.Class} hide`;
private static readonly HideManageExtensionClass = `${this.Class} hide`;

constructor(
@IInstantiationService instantiationService: IInstantiationService,
Expand Down Expand Up @@ -1370,7 +1370,7 @@ export class TogglePreReleaseExtensionAction extends ExtensionAction {
static readonly LABEL = localize('togglePreRleaseLabel', "Pre-Release");

private static readonly EnabledClass = `${ExtensionAction.LABEL_ACTION_CLASS} pre-release`;
private static readonly DisabledClass = `${TogglePreReleaseExtensionAction.EnabledClass} hide`;
private static readonly DisabledClass = `${this.EnabledClass} hide`;

constructor(
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
Expand Down Expand Up @@ -1653,7 +1653,7 @@ export class DisableDropDownAction extends ButtonWithDropDownExtensionAction {
export class ExtensionRuntimeStateAction extends ExtensionAction {

private static readonly EnabledClass = `${ExtensionAction.LABEL_ACTION_CLASS} reload`;
private static readonly DisabledClass = `${ExtensionRuntimeStateAction.EnabledClass} disabled`;
private static readonly DisabledClass = `${this.EnabledClass} disabled`;

updateWhenCounterExtensionChanges: boolean = true;

Expand Down Expand Up @@ -1767,7 +1767,7 @@ export class SetColorThemeAction extends ExtensionAction {
static readonly TITLE = localize2('workbench.extensions.action.setColorTheme', 'Set Color Theme');

private static readonly EnabledClass = `${ExtensionAction.LABEL_ACTION_CLASS} theme`;
private static readonly DisabledClass = `${SetColorThemeAction.EnabledClass} disabled`;
private static readonly DisabledClass = `${this.EnabledClass} disabled`;

constructor(
@IExtensionService extensionService: IExtensionService,
Expand Down Expand Up @@ -1818,7 +1818,7 @@ export class SetFileIconThemeAction extends ExtensionAction {
static readonly TITLE = localize2('workbench.extensions.action.setFileIconTheme', 'Set File Icon Theme');

private static readonly EnabledClass = `${ExtensionAction.LABEL_ACTION_CLASS} theme`;
private static readonly DisabledClass = `${SetFileIconThemeAction.EnabledClass} disabled`;
private static readonly DisabledClass = `${this.EnabledClass} disabled`;

constructor(
@IExtensionService extensionService: IExtensionService,
Expand Down Expand Up @@ -1868,7 +1868,7 @@ export class SetProductIconThemeAction extends ExtensionAction {
static readonly TITLE = localize2('workbench.extensions.action.setProductIconTheme', 'Set Product Icon Theme');

private static readonly EnabledClass = `${ExtensionAction.LABEL_ACTION_CLASS} theme`;
private static readonly DisabledClass = `${SetProductIconThemeAction.EnabledClass} disabled`;
private static readonly DisabledClass = `${this.EnabledClass} disabled`;

constructor(
@IExtensionService extensionService: IExtensionService,
Expand Down Expand Up @@ -1919,7 +1919,7 @@ export class SetLanguageAction extends ExtensionAction {
static readonly TITLE = localize2('workbench.extensions.action.setDisplayLanguage', 'Set Display Language');

private static readonly EnabledClass = `${ExtensionAction.LABEL_ACTION_CLASS} language`;
private static readonly DisabledClass = `${SetLanguageAction.EnabledClass} disabled`;
private static readonly DisabledClass = `${this.EnabledClass} disabled`;

constructor(
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
Expand Down Expand Up @@ -1955,7 +1955,7 @@ export class ClearLanguageAction extends ExtensionAction {
static readonly TITLE = localize2('workbench.extensions.action.clearLanguage', 'Clear Display Language');

private static readonly EnabledClass = `${ExtensionAction.LABEL_ACTION_CLASS} language`;
private static readonly DisabledClass = `${ClearLanguageAction.EnabledClass} disabled`;
private static readonly DisabledClass = `${this.EnabledClass} disabled`;

constructor(
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
Expand Down Expand Up @@ -2267,7 +2267,7 @@ export class ConfigureWorkspaceFolderRecommendedExtensionsAction extends Abstrac
export class ExtensionStatusLabelAction extends Action implements IExtensionContainer {

private static readonly ENABLED_CLASS = `${ExtensionAction.TEXT_ACTION_CLASS} extension-status-label`;
private static readonly DISABLED_CLASS = `${ExtensionStatusLabelAction.ENABLED_CLASS} hide`;
private static readonly DISABLED_CLASS = `${this.ENABLED_CLASS} hide`;

private initialStatus: ExtensionState | null = null;
private status: ExtensionState | null = null;
Expand Down Expand Up @@ -2370,7 +2370,7 @@ export class ExtensionStatusLabelAction extends Action implements IExtensionCont
export class ToggleSyncExtensionAction extends DropDownExtensionAction {

private static readonly IGNORED_SYNC_CLASS = `${ExtensionAction.ICON_ACTION_CLASS} extension-sync ${ThemeIcon.asClassName(syncIgnoredIcon)}`;
private static readonly SYNC_CLASS = `${ToggleSyncExtensionAction.ICON_ACTION_CLASS} extension-sync ${ThemeIcon.asClassName(syncEnabledIcon)}`;
private static readonly SYNC_CLASS = `${this.ICON_ACTION_CLASS} extension-sync ${ThemeIcon.asClassName(syncEnabledIcon)}`;

constructor(
@IConfigurationService private readonly configurationService: IConfigurationService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class SettingsEditor2 extends EditorPane {
private static TOC_RESET_WIDTH: number = 200;
private static EDITOR_MIN_WIDTH: number = 500;
// Below NARROW_TOTAL_WIDTH, we only render the editor rather than the ToC.
private static NARROW_TOTAL_WIDTH: number = SettingsEditor2.TOC_RESET_WIDTH + SettingsEditor2.EDITOR_MIN_WIDTH;
private static NARROW_TOTAL_WIDTH: number = this.TOC_RESET_WIDTH + this.EDITOR_MIN_WIDTH;

private static SUGGESTIONS: string[] = [
`@${MODIFIED_SETTING_TAG}`,
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/preferences/browser/settingsTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -750,9 +750,9 @@ export abstract class AbstractSettingRenderer extends Disposable implements ITre
abstract get templateId(): string;

static readonly CONTROL_CLASS = 'setting-control-focus-target';
static readonly CONTROL_SELECTOR = '.' + AbstractSettingRenderer.CONTROL_CLASS;
static readonly CONTROL_SELECTOR = '.' + this.CONTROL_CLASS;
static readonly CONTENTS_CLASS = 'setting-item-contents';
static readonly CONTENTS_SELECTOR = '.' + AbstractSettingRenderer.CONTENTS_CLASS;
static readonly CONTENTS_SELECTOR = '.' + this.CONTENTS_CLASS;
static readonly ALL_ROWS_SELECTOR = '.monaco-list-row';

static readonly SETTING_KEY_ATTR = 'data-key';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export interface IUntitledTextEditorModel extends ITextEditorModel, ILanguageSup
export class UntitledTextEditorModel extends BaseTextEditorModel implements IUntitledTextEditorModel {

private static readonly FIRST_LINE_NAME_MAX_LENGTH = 40;
private static readonly FIRST_LINE_NAME_CANDIDATE_MAX_LENGTH = UntitledTextEditorModel.FIRST_LINE_NAME_MAX_LENGTH * 10;
private static readonly FIRST_LINE_NAME_CANDIDATE_MAX_LENGTH = this.FIRST_LINE_NAME_MAX_LENGTH * 10;

// Support the special '${activeEditorLanguage}' language by
// looking up the language id from the editor that is active
Expand Down

0 comments on commit 80bdfeb

Please sign in to comment.