Skip to content

[No QA] fix: Allow private_ prefix lint rule for variable naming #54937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ module.exports = {
{
selector: ['variable', 'property'],
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
filter: {
regex: '^private_[a-z][a-zA-Z0-9]+$',
match: false,
},
},
{
selector: 'function',
Expand Down
1 change: 0 additions & 1 deletion src/libs/DebugUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,6 @@ function validateReportDraftProperty(key: keyof Report, value: string) {
fieldList: CONST.RED_BRICK_ROAD_PENDING_ACTION,
permissions: CONST.RED_BRICK_ROAD_PENDING_ACTION,
tripData: CONST.RED_BRICK_ROAD_PENDING_ACTION,
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: CONST.RED_BRICK_ROAD_PENDING_ACTION,
addWorkspaceRoom: CONST.RED_BRICK_ROAD_PENDING_ACTION,
avatar: CONST.RED_BRICK_ROAD_PENDING_ACTION,
Expand Down
3 changes: 1 addition & 2 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,6 @@ function createOption(
if (report) {
result.isChatRoom = ReportUtils.isChatRoom(report);
result.isDefaultRoom = ReportUtils.isDefaultRoom(report);
// eslint-disable-next-line @typescript-eslint/naming-convention
result.private_isArchived = report.private_isArchived;
result.isExpenseReport = ReportUtils.isExpenseReport(report);
result.isInvoiceRoom = ReportUtils.isInvoiceRoom(report);
Expand Down Expand Up @@ -1159,7 +1158,7 @@ function getValidOptions(

return ReportUtils.shouldReportBeInOptionList({
report,
currentReportId: topmostReportId,
currentReportId: topmostReportId ?? '',
Copy link
Contributor

@ZhenjaHorbach ZhenjaHorbach Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need these changes ?
After this PR, undefined is a valid value
#54936

so could you update the branch to the latest version of main and remove all unnecessary changes, please ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @ZhenjaHorbach, i updated

betas,
policies,
doesReportHaveViolations,
Expand Down
33 changes: 22 additions & 11 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ function getOrderedReportIDs(
if ((Object.values(CONST.REPORT.UNSUPPORTED_TYPE) as string[]).includes(report?.type ?? '')) {
return;
}
const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1');
const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID, report?.parentReportActionID);
const doesReportHaveViolations = ReportUtils.shouldDisplayViolationsRBRInLHN(report, transactionViolations);
const isHidden = ReportUtils.isHiddenForCurrentUser(report);
const isFocused = report.reportID === currentReportId;
const hasErrorsOtherThanFailedReceipt = ReportUtils.hasReportErrorsOtherThanFailedReceipt(report, doesReportHaveViolations, transactionViolations);
const isReportInAccessible = report?.errorFields?.notFound;
if (ReportUtils.isOneTransactionThread(report.reportID, report.parentReportID ?? '0', parentReportAction)) {
if (ReportUtils.isOneTransactionThread(report.reportID, report.parentReportID, parentReportAction)) {
return;
}
if (hasErrorsOtherThanFailedReceipt && !isReportInAccessible) {
Expand All @@ -155,7 +155,7 @@ function getOrderedReportIDs(
if (
ReportUtils.shouldReportBeInOptionList({
report,
currentReportId: currentReportId ?? '-1',
currentReportId: currentReportId ?? '',
isInFocusMode,
betas,
policies: policies as OnyxCollection<Policy>,
Expand Down Expand Up @@ -200,13 +200,13 @@ function getOrderedReportIDs(
};

const isPinned = report?.isPinned ?? false;
const reportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1');
const reportAction = ReportActionsUtils.getReportAction(report?.parentReportID, report?.parentReportActionID);
const reportNameValuePairs = ReportUtils.getReportNameValuePairs(report?.reportID);
if (isPinned || ReportUtils.requiresAttentionFromCurrentUser(report, reportAction)) {
pinnedAndGBRReports.push(miniReport);
} else if (report?.hasErrorsOtherThanFailedReceipt) {
errorReports.push(miniReport);
} else if (hasValidDraftComment(report?.reportID ?? '-1')) {
} else if (hasValidDraftComment(report?.reportID)) {
draftReports.push(miniReport);
} else if (ReportUtils.isArchivedRoom(report, reportNameValuePairs)) {
archivedReports.push(miniReport);
Expand Down Expand Up @@ -239,7 +239,12 @@ function getOrderedReportIDs(
// Now that we have all the reports grouped and sorted, they must be flattened into an array and only return the reportID.
// The order the arrays are concatenated in matters and will determine the order that the groups are displayed in the sidebar.

const LHNReports = [...pinnedAndGBRReports, ...errorReports, ...draftReports, ...nonArchivedReports, ...archivedReports].map((report) => report?.reportID ?? '-1');
const LHNReports = [...pinnedAndGBRReports, ...errorReports, ...draftReports, ...nonArchivedReports, ...archivedReports].map((report) => {
if (!report?.reportID) {
return '';
}
return report?.reportID;
});

Performance.markEnd(CONST.TIMING.GET_ORDERED_REPORT_IDS);
return LHNReports;
Expand Down Expand Up @@ -340,7 +345,6 @@ function getOptionData({
hasParentAccess: undefined,
isIOUReportOwner: null,
isChatRoom: false,
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: undefined,
shouldShowSubscript: false,
isPolicyExpenseChat: false,
Expand All @@ -363,7 +367,6 @@ function getOptionData({
result.isTaskReport = ReportUtils.isTaskReport(report);
result.isInvoiceReport = ReportUtils.isInvoiceReport(report);
result.parentReportAction = parentReportAction;
// eslint-disable-next-line @typescript-eslint/naming-convention
result.private_isArchived = report?.private_isArchived;
result.isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report);
result.isExpenseRequest = ReportUtils.isExpenseRequest(report);
Expand All @@ -385,7 +388,7 @@ function getOptionData({
result.iouReportID = report.iouReportID;
result.keyForList = String(report.reportID);
result.hasOutstandingChildRequest = report.hasOutstandingChildRequest;
result.parentReportID = report.parentReportID ?? '-1';
result.parentReportID = report.parentReportID;
result.isWaitingOnBankAccount = report.isWaitingOnBankAccount;
result.notificationPreference = ReportUtils.getReportNotificationPreference(report);
result.isAllowedToComment = ReportUtils.canUserPerformWriteAction(report);
Expand Down Expand Up @@ -518,7 +521,7 @@ function getOptionData({
}

if (!hasMultipleParticipants) {
result.accountID = personalDetail?.accountID ?? -1;
result.accountID = personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID;
result.login = personalDetail?.login ?? '';
result.phoneNumber = personalDetail?.phoneNumber ?? '';
}
Expand All @@ -529,7 +532,15 @@ function getOptionData({
result.subtitle = subtitle;
result.participantsList = participantPersonalDetailList;

result.icons = ReportUtils.getIcons(report, personalDetails, personalDetail?.avatar, personalDetail?.login, personalDetail?.accountID ?? -1, policy, invoiceReceiverPolicy);
result.icons = ReportUtils.getIcons(
report,
personalDetails,
personalDetail?.avatar,
personalDetail?.login,
personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID,
policy,
invoiceReceiverPolicy,
);
result.displayNamesWithTooltips = displayNamesWithTooltips;

if (status) {
Expand Down
2 changes: 0 additions & 2 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ function deleteWorkspace(policyID: string, policyName: string) {
oldPolicyName: allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`]?.name ?? '',
policyName: '',
}),
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: currentTime,
},
});
Expand Down Expand Up @@ -412,7 +411,6 @@ function deleteWorkspace(policyID: string, policyName: string) {
statusNum,
oldPolicyName,
policyName: report?.policyName,
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: null,
},
});
Expand Down
1 change: 0 additions & 1 deletion src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro
visibility: reportOnyx.visibility,
oldPolicyName: reportOnyx.oldPolicyName,
policyName: reportOnyx.policyName,
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: reportOnyx.private_isArchived,
lastMentionedTime: reportOnyx.lastMentionedTime,
avatarUrl: reportOnyx.avatarUrl,
Expand Down
1 change: 0 additions & 1 deletion src/types/form/DebugReportForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const INPUT_IDS = {
POLICY_ID: 'policyID',
POLICY_NAME: 'policyName',
PRIVATE_NOTES: 'privateNotes',
// eslint-disable-next-line @typescript-eslint/naming-convention
PRIVATE_IS_ARCHIVED: 'private_isArchived',
REPORT_ID: 'reportID',
REPORT_NAME: 'reportName',
Expand Down
1 change: 0 additions & 1 deletion src/types/onyx/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback<
};

/** Whether the report is archived */
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived?: string;

/** The report's welcome message */
Expand Down
1 change: 0 additions & 1 deletion src/types/onyx/ReportNameValuePairs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type * as OnyxCommon from './OnyxCommon';
/** Model of additional report details */
type ReportNameValuePairs = OnyxCommon.OnyxValueWithOfflineFeedback<{
/** Whether the report is an archived room */
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: boolean;
}>;

Expand Down
1 change: 0 additions & 1 deletion src/types/onyx/SearchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ type SearchReport = {
unheldTotal?: number;

/** Whether the report is archived */
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived?: string;

/** Whether the action is loading */
Expand Down
1 change: 0 additions & 1 deletion src/types/utils/whitelistedReportKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ type WhitelistedReport = OnyxCommon.OnyxValueWithOfflineFeedback<
endDate: unknown;
tripID: unknown;
};
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: unknown;
welcomeMessage: unknown;
},
Expand Down
1 change: 0 additions & 1 deletion tests/data/Invoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ const convertedInvoiceChat: OnyxTypes.Report = {
policyAvatar: '',
policyID: 'CC048FA711B35B1F',
policyName: "53019's Workspace",
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: '',
reportID: '7605647250932303',
reportName: 'Chat Report',
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/LHNItemsPresence.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,10 @@ describe('SidebarLinksData', () => {
LHNTestUtils.getDefaultRenderedSidebarLinks();
const archivedReport: Report = {
...createReport(false),
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: DateUtils.getDBTime(),
};
const reportNameValuePairs = {
type: 'chat',
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: true,
};

Expand Down
2 changes: 0 additions & 2 deletions tests/unit/DebugUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,6 @@ describe('DebugUtils', () => {
await Onyx.set(ONYXKEYS.NVP_PRIORITY_MODE, CONST.PRIORITY_MODE.DEFAULT);
const reason = DebugUtils.getReasonForShowingRowInLHN({
...baseReport,
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: 'true',
});
expect(reason).toBe('debug.reasonVisibleInLHN.isArchived');
Expand Down Expand Up @@ -1061,7 +1060,6 @@ describe('DebugUtils', () => {
await Onyx.multiSet({
...MOCK_REPORTS,
[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}2` as const]: {
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: false,
},
[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}1` as const]: MOCK_REPORT_ACTIONS,
Expand Down
1 change: 0 additions & 1 deletion tests/unit/OptionsListUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ describe('OptionsListUtils', () => {
// This indicates that the report is archived
stateNum: 2,
statusNum: 2,
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: DateUtils.getDBTime(),
},
};
Expand Down
3 changes: 0 additions & 3 deletions tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ describe('ReportUtils', () => {
...baseAdminsRoom,
statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: DateUtils.getDBTime(),
};

Expand All @@ -214,7 +213,6 @@ describe('ReportUtils', () => {
...baseUserCreatedRoom,
statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: DateUtils.getDBTime(),
};

Expand Down Expand Up @@ -260,7 +258,6 @@ describe('ReportUtils', () => {
oldPolicyName: policy.name,
statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: DateUtils.getDBTime(),
};

Expand Down
2 changes: 0 additions & 2 deletions tests/unit/SidebarOrderTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,6 @@ describe('Sidebar', () => {
chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM,
statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: DateUtils.getDBTime(),
};
const report2 = LHNTestUtils.getFakeReport([1, 3]);
Expand Down Expand Up @@ -984,7 +983,6 @@ describe('Sidebar', () => {
statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
lastMessageText: 'test',
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: DateUtils.getDBTime(),
};
const report2 = {
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/SidebarTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ describe('Sidebar', () => {
chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM,
statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: DateUtils.getDBTime(),
lastMessageText: 'test',
};
Expand Down Expand Up @@ -102,7 +101,6 @@ describe('Sidebar', () => {
chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM,
statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: DateUtils.getDBTime(),
lastMessageText: 'test',
};
Expand Down
1 change: 0 additions & 1 deletion tests/utils/collections/optionData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default function createRandomOptionData(index: number): OptionData {
policyName: randWord(),
policyID: `policy_${index}`,
accountID: randNumber(),
// eslint-disable-next-line @typescript-eslint/naming-convention
private_isArchived: new Date().toISOString(),
isPolicyExpenseChat: randBoolean(),
chatType: rand(Object.values(CONST.REPORT.CHAT_TYPE)),
Expand Down
Loading