Skip to content

Commit d4a4a26

Browse files
dmitrivMSCopilot
andauthored
eslint: fix bracket notation in test infrastructure (#334773)
* eslint: enable no bracket notation rule Enable code-no-bracket-notation-for-identifiers for JavaScript and TypeScript files while grandfathering the 509 files with existing violations in a CODEOWNERS-gated allowlist. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * eslint: update bracket allowlist owners Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * eslint: group bracket notation exclusions Organize the existing baseline by feature area so cleanup can be tracked and assigned without changing the excluded file set. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * eslint: test no bracket notation rule Add RuleTester coverage for valid accesses, diagnostics, and autofix edge cases. Preserve escaped string-literal property names by checking their raw source before reporting. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * eslint: fix bracket notation in test infrastructure Replace identifier-safe bracket notation across test infrastructure and remove the completed group from the temporary allowlist. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent be31694 commit d4a4a26

19 files changed

Lines changed: 51 additions & 71 deletions

File tree

‎.eslint-allowed-bracket-notation-files‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -508,26 +508,6 @@ extensions/git/src/ipc/ipcClient.ts
508508
extensions/git/src/ipc/ipcServer.ts
509509
extensions/git/src/util.ts
510510

511-
# Test infrastructure (18 files)
512-
src/vs/platform/instantiation/test/common/instantiationServiceMock.ts
513-
src/vs/workbench/test/browser/componentFixtures/chat/chatWidget.fixture.ts
514-
src/vs/workbench/test/browser/componentFixtures/multiDiffEditorScroll.fixture.ts
515-
src/vs/workbench/test/browser/componentFixtures/resizeObserver.fixture.ts
516-
test/automation/src/electron.ts
517-
test/automation/src/scm.ts
518-
test/automation/src/search.ts
519-
test/componentFixtures/playwright/tests/chatResizeObserver.spec.ts
520-
test/componentFixtures/playwright/tests/utils.ts
521-
test/monaco/esm-check/esm-check.js
522-
test/sanity/src/context.ts
523-
test/sanity/src/main.ts
524-
test/smoke/src/areas/agentsWindow/agentsWindow.test.ts
525-
test/smoke/src/areas/preferences/preferences.test.ts
526-
test/smoke/test/index.js
527-
test/unit/electron/index.js
528-
test/unit/electron/preload.js
529-
test/unit/electron/renderer.js
530-
531511
# Workbench UI and remaining services (23 files)
532512
src/vs/workbench/browser/parts/editor/editor.ts
533513
src/vs/workbench/browser/parts/editor/editorGroupView.ts

‎src/vs/platform/instantiation/test/common/instantiationServiceMock.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ export class TestInstantiationService extends InstantiationService implements ID
122122
private _getOrCreateService<T>(serviceMock: IServiceMock<T>, opts: SinonOptions, reset?: boolean): any {
123123
const service: any = this._serviceCollection.get(serviceMock.id);
124124
if (!reset && service) {
125-
if (opts.mock && service['sinonOptions'] && !!service['sinonOptions'].mock) {
125+
if (opts.mock && service.sinonOptions && !!service.sinonOptions.mock) {
126126
return service;
127127
}
128-
if (opts.stub && service['sinonOptions'] && !!service['sinonOptions'].stub) {
128+
if (opts.stub && service.sinonOptions && !!service.sinonOptions.stub) {
129129
return service;
130130
}
131131
}
@@ -135,7 +135,7 @@ export class TestInstantiationService extends InstantiationService implements ID
135135
private _createService(serviceMock: IServiceMock<any>, opts: SinonOptions): any {
136136
serviceMock.service = serviceMock.service ? serviceMock.service : this._servciesMap.get(serviceMock.id);
137137
const service = opts.mock ? sinon.mock(serviceMock.service) : this._createStub(serviceMock.service);
138-
service['sinonOptions'] = opts;
138+
service.sinonOptions = opts;
139139
return service;
140140
}
141141

‎src/vs/workbench/test/browser/componentFixtures/chat/chatWidget.fixture.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ export async function renderChatWidget(context: ComponentFixtureContext, options
482482
? Math.max(0, Math.max(116, inputHeight) - inputHeight)
483483
: Math.max(0, height - inputHeight);
484484
listContainer.style.height = `${contentHeight}px`;
485-
listContainer.dataset['expectedHeight'] = String(contentHeight);
485+
listContainer.dataset.expectedHeight = String(contentHeight);
486486
listWidget.layout(contentHeight, width);
487487
} finally {
488488
layouting = false;
@@ -807,7 +807,7 @@ async function renderResizeObserverLoopHarness(context: ComponentFixtureContext,
807807
if (event instanceof ErrorEvent && event.message.includes('ResizeObserver loop')) {
808808
warningCount++;
809809
warnings.textContent = `Warnings: ${warningCount}`;
810-
warnings.dataset['observerContext'] = dom.getRecentDisposableResizeObserverContextForLoopError(event.message, targetWindow) ?? event.message;
810+
warnings.dataset.observerContext = dom.getRecentDisposableResizeObserverContextForLoopError(event.message, targetWindow) ?? event.message;
811811
status.textContent = 'Captured ResizeObserver warning';
812812
}
813813
}));
@@ -908,11 +908,11 @@ async function renderDisabledPetResizeObserverProbe(context: ComponentFixtureCon
908908
const status = dom.append(context.container, dom.$('.disabled-pet-resize-observer-status'));
909909
status.role = 'status';
910910
status.textContent = 'Running disabled pet observer probe';
911-
status.dataset['warningCount'] = '0';
911+
status.dataset.warningCount = '0';
912912
context.disposableStore.add(dom.addDisposableListener(targetWindow, dom.EventType.ERROR, event => {
913913
if (event instanceof ErrorEvent && event.message.includes('ResizeObserver loop')) {
914-
status.dataset['warningCount'] = String(Number(status.dataset['warningCount']) + 1);
915-
status.dataset['observerContext'] = dom.getRecentDisposableResizeObserverContextForLoopError(event.message, targetWindow) ?? event.message;
914+
status.dataset.warningCount = String(Number(status.dataset.warningCount) + 1);
915+
status.dataset.observerContext = dom.getRecentDisposableResizeObserverContextForLoopError(event.message, targetWindow) ?? event.message;
916916
}
917917
}));
918918

‎src/vs/workbench/test/browser/componentFixtures/multiDiffEditorScroll.fixture.ts‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ function parseSerializedFixtureState(text: string): ISerializedFixtureState {
701701
if (!isJsonObject(value)) {
702702
throw new Error('Fixture state must be a JSON object.');
703703
}
704-
const items = value['items'];
704+
const items = value.items;
705705
if (!Array.isArray(items)) {
706706
throw new Error('Fixture state must contain an items array.');
707707
}
@@ -720,24 +720,24 @@ function parseSerializedFixtureItem(value: JsonValue, index: number): ISerialize
720720
if (!isJsonObject(value)) {
721721
throw new Error(`items[${index}] must be a JSON object.`);
722722
}
723-
const bindingPhase = value['bindingPhase'];
723+
const bindingPhase = value.bindingPhase;
724724
if (!isBindingPhase(bindingPhase)) {
725725
throw new Error(`items[${index}].bindingPhase must be unbound, binding, projecting, or active.`);
726726
}
727727
const path = `items[${index}]`;
728-
const lineCount = value['lineCount'] === undefined
728+
const lineCount = value.lineCount === undefined
729729
? heightToLineCount(readNonNegativeNumber(value, 'fullHeight', true, path))
730730
: readNonNegativeInteger(value, 'lineCount', path);
731-
const geometryOscillationValue = value['geometryOscillation'];
731+
const geometryOscillationValue = value.geometryOscillation;
732732
const geometryOscillation = geometryOscillationValue === undefined
733733
? createDefaultGeometryOscillation()
734734
: parseSerializedGeometryOscillation(geometryOscillationValue, index, lineCount);
735-
const topLineCountValue = value['topLineCount'];
736-
const bottomLineCountValue = value['bottomLineCount'];
737-
const legacyContentTopInset = value['contentTopInset'];
738-
const mountLineCountsValue = value['mountLineCounts'];
739-
const legacyMountHeightsValue = value['mountHeights'];
740-
const unmountLineCountResetValue = value['unmountLineCountReset'];
735+
const topLineCountValue = value.topLineCount;
736+
const bottomLineCountValue = value.bottomLineCount;
737+
const legacyContentTopInset = value.contentTopInset;
738+
const mountLineCountsValue = value.mountLineCounts;
739+
const legacyMountHeightsValue = value.mountHeights;
740+
const unmountLineCountResetValue = value.unmountLineCountReset;
741741
return {
742742
label: readString(value, 'label', path),
743743
lineCount,
@@ -787,12 +787,12 @@ function parseSerializedGeometryOscillation(value: JsonValue, index: number, lin
787787
if (!isJsonObject(value)) {
788788
throw new Error(`${path} must be a JSON object.`);
789789
}
790-
const ordering = value['ordering'];
790+
const ordering = value.ordering;
791791
if (!isGeometryChangeOrdering(ordering)) {
792792
throw new Error(`${path}.ordering must be atomic, lines-first, or offset-first.`);
793793
}
794794
const normalizedOrdering = ordering === 'height-first' ? 'lines-first' : ordering;
795-
if (value['topLineCountA'] !== undefined) {
795+
if (value.topLineCountA !== undefined) {
796796
return {
797797
enabled: readBoolean(value, 'enabled', path),
798798
topLineCountA: readNonNegativeInteger(value, 'topLineCountA', path),
@@ -802,7 +802,7 @@ function parseSerializedGeometryOscillation(value: JsonValue, index: number, lin
802802
ordering: normalizedOrdering,
803803
};
804804
}
805-
const location = value['location'];
805+
const location = value.location;
806806
if (location !== 'above' && location !== 'below') {
807807
throw new Error(`${path}.location must be above or below when importing legacy height geometry.`);
808808
}

‎src/vs/workbench/test/browser/componentFixtures/resizeObserver.fixture.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ function renderLoopContextProbe(context: ComponentFixtureContext): void {
1515

1616
const status = dom.append(context.container, dom.$('.resize-observer-context-status'));
1717
status.textContent = 'Waiting for ResizeObserver loop warning';
18-
status.dataset['warningCount'] = '0';
18+
status.dataset.warningCount = '0';
1919

2020
const observation = context.disposableStore.add(new MutableDisposable<IDisposable>());
2121
context.disposableStore.add(dom.addDisposableListener(targetWindow, dom.EventType.ERROR, event => {
2222
if (!(event instanceof ErrorEvent) || !event.message.includes('ResizeObserver loop')) {
2323
return;
2424
}
2525

26-
status.dataset['warningCount'] = '1';
27-
status.dataset['observerContext'] = dom.getRecentDisposableResizeObserverContextForLoopError(event.message, targetWindow) ?? '';
26+
status.dataset.warningCount = '1';
27+
status.dataset.observerContext = dom.getRecentDisposableResizeObserverContextForLoopError(event.message, targetWindow) ?? '';
2828
status.textContent = 'Captured ResizeObserver loop warning';
2929
observation.clear();
3030
}));

‎test/automation/src/electron.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ export async function resolveElectronConfiguration(options: LaunchOptions): Prom
7474
if (userDataDir) {
7575
const remoteDataDir = `${userDataDir}-server`;
7676
fs.mkdirSync(remoteDataDir, { recursive: true });
77-
env['TESTRESOLVER_DATA_FOLDER'] = remoteDataDir;
77+
env.TESTRESOLVER_DATA_FOLDER = remoteDataDir;
7878
}
79-
env['TESTRESOLVER_LOGS_FOLDER'] = join(logsPath, 'server');
79+
env.TESTRESOLVER_LOGS_FOLDER = join(logsPath, 'server');
8080
// Exercise the remote server's exit diagnostics (see `installServerProcessExitDiagnostics`
8181
// in server-main.ts) so unexpected server exits are explained in the captured logs,
8282
// even when running smoke tests locally (where `isCI` is false).
83-
env['VSCODE_SERVER_EXIT_DIAGNOSTICS'] = '1';
83+
env.VSCODE_SERVER_EXIT_DIAGNOSTICS = '1';
8484
if (options.verbose) {
85-
env['TESTRESOLVER_LOG_LEVEL'] = 'trace';
85+
env.TESTRESOLVER_LOG_LEVEL = 'trace';
8686
}
8787
}
8888

‎test/automation/src/scm.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function toChange(element: IElement): Change {
2727
const type = element.attributes['data-tooltip'] || '';
2828

2929
const actionElementList = findElements(element, e => /\baction-label\b/.test(e.className));
30-
const actions = actionElementList.map(e => e.attributes['title']);
30+
const actions = actionElementList.map(e => e.attributes.title);
3131

3232
return {
3333
name: name.textContent || '',

‎test/automation/src/search.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ export class Search extends Viewlet {
4949
}
5050

5151
async getSearchTooltip(): Promise<any> {
52-
const icon = await this.code.waitForElement(`.activitybar .action-label.codicon.codicon-search-view-icon`, (el) => !!el?.attributes?.['title']);
53-
return icon.attributes['title'];
52+
const icon = await this.code.waitForElement(`.activitybar .action-label.codicon.codicon-search-view-icon`, (el) => !!el?.attributes?.title);
53+
return icon.attributes.title;
5454
}
5555

5656
async searchFor(text: string): Promise<void> {

‎test/componentFixtures/playwright/tests/chatResizeObserver.spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ for (const scenario of scenarios) {
3434
const geometry = await page.locator('.interactive-list').evaluate(element => {
3535
const list = element.querySelector<HTMLElement>('.monaco-list');
3636
return {
37-
expectedHeight: Number((element as HTMLElement).dataset['expectedHeight']),
37+
expectedHeight: Number((element as HTMLElement).dataset.expectedHeight),
3838
containerHeight: element.getBoundingClientRect().height,
3939
listHeight: list?.getBoundingClientRect().height,
4040
};

‎test/componentFixtures/playwright/tests/utils.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { Page } from '@playwright/test';
77

88
function getBaseURL(): string {
9-
const port = process.env['COMPONENT_EXPLORER_PORT'];
9+
const port = process.env.COMPONENT_EXPLORER_PORT;
1010
if (!port) {
1111
throw new Error('COMPONENT_EXPLORER_PORT is not set. Is the webServer running?');
1212
}

0 commit comments

Comments
 (0)