Skip to content

Commit a952194

Browse files
Scheduler — Replace underscore-prefixed: Cherry-pick to 25_1 and validate completion (#33164)
1 parent d9b80fb commit a952194

76 files changed

Lines changed: 1474 additions & 1318 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
const schedulerDOMComponentOverrides = [
2+
'_createActionByOption',
3+
'_defaultOptionsRules',
4+
'_dimensionChanged',
5+
'_dispose',
6+
'_disposed',
7+
'_getDefaultOptions',
8+
'_init',
9+
'_initTemplates',
10+
'_optionChanged',
11+
'_setDeprecatedOptions',
12+
'_setOptionsByReference',
13+
'_useTemplates',
14+
'_visibilityChanged',
15+
];
16+
17+
const schedulerWidgetOverrides = [
18+
'_activeStateUnit',
19+
'_clean',
20+
'_cleanFocusState',
21+
'_eventBindingTarget',
22+
'_fireContentReadyAction',
23+
'_focusInHandler',
24+
'_focusOutHandler',
25+
'_focusTarget',
26+
'_initMarkup',
27+
'_keyboardHandler',
28+
'_render',
29+
'_renderContent',
30+
'_renderFocusState',
31+
'_renderFocusTarget',
32+
'_supportedKeys',
33+
'_toggleVisibility',
34+
'_createAction',
35+
'_createEventArgs',
36+
'_dataSource',
37+
'_dataSourceChangedHandler',
38+
'_dataSourceOptions',
39+
'_options',
40+
];
41+
42+
const schedulerCollectionWidgetOverrides = [
43+
'_cleanItemContainer',
44+
'_clearDropDownItemsElements',
45+
'_createItemByTemplate',
46+
'_executeItemRenderAction',
47+
'_filteredItems',
48+
'_findItemElementByItem',
49+
'_focusedItemIndexBeforeRender',
50+
'_getItemContent',
51+
'_itemClass',
52+
'_itemClickHandler',
53+
'_itemContainer',
54+
'_moveFocus',
55+
'_postprocessRenderItem',
56+
'_processItemClick',
57+
'_refreshActiveDescendant',
58+
'_renderDirection',
59+
'_renderItem',
60+
'_sortedItems',
61+
];
62+
63+
const schedulerR1Overrides = [
64+
'_propsInfo',
65+
'_value',
66+
'_viewComponent',
67+
];
68+
69+
const schedulerFrameworkOptions = [
70+
'_swipeEnabled',
71+
'_loopFocus',
72+
];
73+
74+
const schedulerLegacyMembers = [
75+
// workspaces/m_work_space.ts
76+
'_$allDayPanel',
77+
'_$dateTable',
78+
'_$dateTableScrollableContent',
79+
'_$flexContainer',
80+
'_$groupTable',
81+
'_$headerPanel',
82+
'_$headerPanelContainer',
83+
'_$thead',
84+
'_dateTableScrollable',
85+
'_getCellCount',
86+
'_getGroupCount',
87+
'_groupedStrategy',
88+
'_isHorizontalGroupedWorkSpace',
89+
'_shader',
90+
'_sidebarScrollable',
91+
92+
// m_scheduler.ts
93+
'_appointments',
94+
'_compactAppointmentsHelper',
95+
'_dataAccessors',
96+
'_getDragBehavior',
97+
'_isAppointmentBeingUpdated',
98+
'_layoutManager',
99+
'_workSpace',
100+
101+
// appointments/m_appointment_collection.ts
102+
'_renderAppointmentTemplate',
103+
104+
// workspaces/view_model/m_view_data_generator.ts
105+
'_getIntervalDuration',
106+
107+
// workspaces/m_virtual_scrolling.ts
108+
'_renderGrid',
109+
110+
// appointment_popup/m_popup.ts
111+
'_popup',
112+
113+
// appointment_popup/m_legacy_popup.ts
114+
'_ignorePreventScrollEventsDeprecation',
115+
116+
// header/m_header.ts
117+
'_useShortDateFormat',
118+
119+
// header/m_view_switcher.ts
120+
'_wrapperClassExternal',
121+
122+
// utils/options/constants.ts, utils/options/types.ts
123+
'_appointmentTooltipOffset',
124+
'_draggingMode',
125+
'_appointmentCountPerCell',
126+
'_collectorOffset',
127+
'_appointmentOffset',
128+
];
129+
130+
const schedulerMemberAllowlist = [
131+
...schedulerDOMComponentOverrides,
132+
...schedulerWidgetOverrides,
133+
...schedulerCollectionWidgetOverrides,
134+
...schedulerR1Overrides,
135+
...schedulerFrameworkOptions,
136+
...schedulerLegacyMembers,
137+
];
138+
139+
export const schedulerMemberAllowlistRegex =
140+
`^(_|__esModule|${schedulerMemberAllowlist.map(s => s.replace(/\$/g, '\\$')).join('|')})$`;

packages/devextreme/eslint.config.mjs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import simpleImportSort from 'eslint-plugin-simple-import-sort';
1515
import { changeRulesToStylistic } from 'eslint-migration-utils';
1616
import unicorn from 'eslint-plugin-unicorn';
1717
import customRules from './eslint_plugins/index.js';
18+
import { schedulerMemberAllowlistRegex } from './eslint-scheduler-allowlist.mjs';
1819

1920
const __filename = fileURLToPath(import.meta.url);
2021
const __dirname = path.dirname(__filename);
@@ -575,13 +576,40 @@ export default [
575576
{
576577
selector: 'memberLike',
577578
format: null,
578-
leadingUnderscore: 'allow',
579+
leadingUnderscore: 'forbid',
580+
filter: {
581+
regex: schedulerMemberAllowlistRegex,
582+
match: false,
583+
},
579584
},
580585
],
581586
'devextreme-custom/no-deferred': 'error',
582587
'devextreme-custom/prefer-switch-true': ['error', { minBranches: 3 }],
583588
},
584589
},
590+
// Temporarily allow underscore members in appointments/ (pending refactoring)
591+
{
592+
files: ['js/__internal/scheduler/appointments/**/*.ts?(x)'],
593+
rules: {
594+
'@typescript-eslint/naming-convention': [
595+
'error',
596+
{
597+
selector: ['variable', 'function', 'parameter'],
598+
format: null,
599+
leadingUnderscore: 'forbid',
600+
filter: {
601+
regex: '^_$',
602+
match: false,
603+
},
604+
},
605+
{
606+
selector: 'memberLike',
607+
format: null,
608+
leadingUnderscore: 'allow',
609+
},
610+
],
611+
},
612+
},
585613
// Allow Deferred in m_* scheduler files only
586614
{
587615
files: ['js/__internal/scheduler/**/m_*.ts?(x)'],

packages/devextreme/js/__internal/scheduler/__tests__/__mock__/m_mock_scheduler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const setupSchedulerTestEnvironment = ({
1919
}: SetupSchedulerTestEnvironmentOptions = {}): void => {
2020
jest.spyOn(logger, 'warn').mockImplementation(() => {});
2121
DOMComponent.prototype._isVisible = jest.fn((): boolean => true);
22-
SchedulerWorkSpace.prototype._createCrossScrollingConfig = (): {
22+
(SchedulerWorkSpace.prototype as any).createCrossScrollingConfig = (): {
2323
direction: string;
2424
onScroll: jest.Mock;
2525
onEnd: jest.Mock;

packages/devextreme/js/__internal/scheduler/__tests__/workspace.base.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ describe('scheduler workspace', () => {
5858
expect(workspace.cache.clear).toHaveBeenCalledTimes(1);
5959
});
6060

61-
it(`should clear cache on _cleanView call, view: ${currentView}`, () => {
61+
it(`should clear cache on cleanView call, view: ${currentView}`, () => {
6262
const workspace = createWorkspace(WorkSpace, currentView);
6363
jest.spyOn(workspace.cache, 'clear');
6464

6565
workspace.cache.memo('test', () => 'value');
66-
workspace._cleanView();
66+
(workspace as any).cleanView();
6767

6868
expect(workspace.cache.clear).toHaveBeenCalledTimes(1);
6969
expect(workspace.cache.size).toBe(0);

packages/devextreme/js/__internal/scheduler/appointment_popup/m_form.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class AppointmentForm {
103103
const colSpan = isRecurrence ? 1 : 2;
104104

105105
const mainItems = [
106-
...this._createMainItems(expr, triggerResize, changeSize, allowTimeZoneEditing),
106+
...this.createMainItems(expr, triggerResize, changeSize, allowTimeZoneEditing),
107107
...this.scheduler.createResourceEditorModel(),
108108
];
109109

@@ -124,7 +124,7 @@ export class AppointmentForm {
124124
name: APPOINTMENT_FORM_GROUP_NAMES.Recurrence,
125125
visible: isRecurrence,
126126
colSpan,
127-
items: this._createRecurrenceEditor(expr),
127+
items: this.createRecurrenceEditor(expr),
128128
},
129129
];
130130

@@ -152,7 +152,7 @@ export class AppointmentForm {
152152
});
153153
}
154154

155-
_dateBoxValueChanged(args, dateExpr, isNeedCorrect) {
155+
private dateBoxValueChanged(args, dateExpr, isNeedCorrect) {
156156
validateAppointmentFormDate(args.component, args.value, args.previousValue);
157157

158158
const value = dateSerialization.deserializeDate(args.value);
@@ -166,7 +166,7 @@ export class AppointmentForm {
166166
}
167167
}
168168

169-
_createTimezoneEditor(timeZoneExpr, secondTimeZoneExpr, visibleIndex, colSpan, isMainTimeZone, cssClass, visible = false) {
169+
private createTimezoneEditor(timeZoneExpr, secondTimeZoneExpr, visibleIndex, colSpan, isMainTimeZone, cssClass, visible = false) {
170170
const noTzTitle = messageLocalization.format('dxScheduler-noTimezoneTitle');
171171

172172
return {
@@ -197,7 +197,7 @@ export class AppointmentForm {
197197
};
198198
}
199199

200-
_createDateBoxItems(dataExprs, allowTimeZoneEditing) {
200+
private createDateBoxItems(dataExprs, allowTimeZoneEditing) {
201201
const colSpan = allowTimeZoneEditing ? 2 : 1;
202202
const firstDayOfWeek = this.scheduler.getFirstDayOfWeek();
203203

@@ -209,11 +209,11 @@ export class AppointmentForm {
209209
'dxScheduler-editorLabelStartDate',
210210
E2E_TEST_CLASSES.startDateEditor,
211211
(args) => {
212-
this._dateBoxValueChanged(args, dataExprs.endDateExpr, (endValue, startValue) => endValue < startValue);
212+
this.dateBoxValueChanged(args, dataExprs.endDateExpr, (endValue, startValue) => endValue < startValue);
213213
},
214214
),
215215

216-
this._createTimezoneEditor(
216+
this.createTimezoneEditor(
217217
dataExprs.startDateTimeZoneExpr,
218218
dataExprs.endDateTimeZoneExpr,
219219
1,
@@ -230,11 +230,11 @@ export class AppointmentForm {
230230
'dxScheduler-editorLabelEndDate',
231231
E2E_TEST_CLASSES.endDateEditor,
232232
(args) => {
233-
this._dateBoxValueChanged(args, dataExprs.startDateExpr, (startValue, endValue) => endValue < startValue);
233+
this.dateBoxValueChanged(args, dataExprs.startDateExpr, (startValue, endValue) => endValue < startValue);
234234
},
235235
),
236236

237-
this._createTimezoneEditor(
237+
this.createTimezoneEditor(
238238
dataExprs.endDateTimeZoneExpr,
239239
dataExprs.startDateTimeZoneExpr,
240240
3,
@@ -246,7 +246,7 @@ export class AppointmentForm {
246246
];
247247
}
248248

249-
_changeFormItemDateType(name: string, groupName: string, isAllDay: boolean): void {
249+
private changeFormItemDateType(name: string, groupName: string, isAllDay: boolean): void {
250250
const editorPath = this.getEditorPath(name, groupName);
251251
const itemEditorOptions = this.form.itemOption(editorPath).editorOptions;
252252

@@ -257,7 +257,7 @@ export class AppointmentForm {
257257
this.form.itemOption(editorPath, 'editorOptions', newEditorOption);
258258
}
259259

260-
_createMainItems(dataExprs, triggerResize, changeSize, allowTimeZoneEditing) {
260+
private createMainItems(dataExprs, triggerResize, changeSize, allowTimeZoneEditing) {
261261
return [
262262
{
263263
name: this.normalizeEditorName(dataExprs.textExpr),
@@ -279,7 +279,7 @@ export class AppointmentForm {
279279
lg: 2,
280280
xs: 1,
281281
},
282-
items: this._createDateBoxItems(dataExprs, allowTimeZoneEditing),
282+
items: this.createDateBoxItems(dataExprs, allowTimeZoneEditing),
283283
},
284284
{
285285
itemType: 'group',
@@ -317,8 +317,8 @@ export class AppointmentForm {
317317
}
318318
}
319319

320-
this._changeFormItemDateType(dataExprs.startDateExpr, 'Main', value);
321-
this._changeFormItemDateType(dataExprs.endDateExpr, 'Main', value);
320+
this.changeFormItemDateType(dataExprs.startDateExpr, 'Main', value);
321+
this.changeFormItemDateType(dataExprs.endDateExpr, 'Main', value);
322322
},
323323
},
324324
}, {
@@ -370,7 +370,7 @@ export class AppointmentForm {
370370
];
371371
}
372372

373-
_createRecurrenceEditor(dataExprs) {
373+
private createRecurrenceEditor(dataExprs) {
374374
return [{
375375
name: this.normalizeEditorName(dataExprs.recurrenceRuleExpr),
376376
dataField: dataExprs.recurrenceRuleExpr,

0 commit comments

Comments
 (0)