Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9d252e8
Changed [] to at()
zfurtak Sep 20, 2024
821199c
Removed unnecessary files
zfurtak Sep 20, 2024
dd5bda1
Removed unnecessary files
zfurtak Sep 20, 2024
c5a6703
Fixed ts issues
zfurtak Sep 20, 2024
3f8676a
Fixed eslint issues
zfurtak Sep 20, 2024
d1776d3
Fixed tsc check
zfurtak Sep 20, 2024
f8fbbcc
Fixed lint
zfurtak Sep 20, 2024
a5bc7a4
Fixed eslint changed files check
zfurtak Sep 20, 2024
a240b40
Fixed performance tests
zfurtak Sep 23, 2024
c29ede6
Merge main
zfurtak Sep 23, 2024
ff5bb29
First part of adjustments after review
zfurtak Sep 24, 2024
e14c4fe
Second part of adjustments after review
zfurtak Sep 24, 2024
df2133a
Marge main
zfurtak Sep 24, 2024
d88dc5e
Adjust proposalPoliceComment
zfurtak Sep 24, 2024
c11cee1
Reset proposalPoliceComment index
zfurtak Sep 25, 2024
0993f36
Third part of adjustments after review
zfurtak Sep 25, 2024
bb47985
Merge branch 'main' into @zfurtak/new-eslint-rule
zfurtak Sep 30, 2024
c52a33c
Adjustments after review
zfurtak Sep 30, 2024
37d321d
Github actions fix
zfurtak Sep 30, 2024
b2295da
Reverted User.ts
zfurtak Sep 30, 2024
5c3bf8f
Fix eslint errors
zfurtak Sep 30, 2024
6d5facb
Fixed last errors
zfurtak Sep 30, 2024
2196c6f
Adjusted fallback icons
zfurtak Oct 1, 2024
c0d03fb
Merge branch 'main' into @zfurtak/new-eslint-rule
zfurtak Oct 1, 2024
f7b4f48
Fixed errors after merge
zfurtak Oct 1, 2024
a7cf2f4
Updated package-lock
zfurtak Oct 1, 2024
fe43351
Adjusted to reviews
zfurtak Oct 1, 2024
0abdee3
Adjustments
zfurtak Oct 1, 2024
4fd4b50
Emoji fix
zfurtak Oct 1, 2024
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
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,11 @@ module.exports = {
'rulesdir/use-periods-for-error-messages': 'error',
},
},
{
files: ['*.ts', '*.tsx'],
rules: {
'rulesdir/prefer-at': 'error',
},
},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ function partitionWithChecklist(body: string): string[] {
async function getNumberOfItemsFromAuthorChecklist(): Promise<number> {
const response = await fetch(pathToAuthorChecklist);
const fileContents = await response.text();
const checklist = partitionWithChecklist(fileContents)[1];
const numberOfChecklistItems = (checklist.match(/\[ \]/g) ?? []).length;
const checklist = partitionWithChecklist(fileContents).at(1);
const numberOfChecklistItems = (checklist?.match(/\[ \]/g) ?? []).length ?? 0;
return numberOfChecklistItems;
}

Expand Down
18 changes: 11 additions & 7 deletions .github/actions/javascript/authorChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16771,8 +16771,8 @@ function partitionWithChecklist(body) {
async function getNumberOfItemsFromAuthorChecklist() {
const response = await fetch(pathToAuthorChecklist);
const fileContents = await response.text();
const checklist = partitionWithChecklist(fileContents)[1];
const numberOfChecklistItems = (checklist.match(/\[ \]/g) ?? []).length;
const checklist = partitionWithChecklist(fileContents).at(1);
const numberOfChecklistItems = (checklist?.match(/\[ \]/g) ?? []).length ?? 0;
return numberOfChecklistItems;
}
function checkPRForCompletedChecklist(expectedNumberOfChecklistItems, checklist) {
Expand Down Expand Up @@ -17180,7 +17180,11 @@ class GithubUtils {
if (data.length > 1) {
throw new Error(`Found more than one ${CONST_1.default.LABELS.STAGING_DEPLOY} issue.`);
}
return this.getStagingDeployCashData(data[0]);
const issue = data.at(0);
if (!issue) {
throw new Error(`Found an undefined ${CONST_1.default.LABELS.STAGING_DEPLOY} issue.`);
}
return this.getStagingDeployCashData(issue);
});
}
/**
Expand Down Expand Up @@ -17258,7 +17262,7 @@ class GithubUtils {
}
internalQASection = internalQASection[1];
const internalQAPRs = [...internalQASection.matchAll(new RegExp(`- \\[([ x])]\\s(${CONST_1.default.PULL_REQUEST_REGEX.source})`, 'g'))].map((match) => ({
url: match[2].split('-')[0].trim(),
url: match[2].split('-').at(0)?.trim() ?? '',
number: Number.parseInt(match[3], 10),
isResolved: match[1] === 'x',
}));
Expand Down Expand Up @@ -17342,7 +17346,7 @@ class GithubUtils {
* Fetch all pull requests given a list of PR numbers.
*/
static fetchAllPullRequests(pullRequestNumbers) {
const oldestPR = pullRequestNumbers.sort((a, b) => a - b)[0];
const oldestPR = pullRequestNumbers.sort((a, b) => a - b).at(0);
return this.paginate(this.octokit.pulls.list, {
owner: CONST_1.default.GITHUB_OWNER,
repo: CONST_1.default.APP_REPO,
Expand Down Expand Up @@ -17416,7 +17420,7 @@ class GithubUtils {
repo: CONST_1.default.APP_REPO,
workflow_id: workflow,
})
.then((response) => response.data.workflow_runs[0]?.id);
.then((response) => response.data.workflow_runs.at(0)?.id ?? -1);
}
/**
* Generate the URL of an New Expensify pull request given the PR number.
Expand Down Expand Up @@ -17484,7 +17488,7 @@ class GithubUtils {
per_page: 1,
name: artifactName,
})
.then((response) => response.data.artifacts[0]);
.then((response) => response.data.artifacts.at(0));
}
/**
* Given an artifact ID, returns the download URL to a zip file containing the artifact.
Expand Down
14 changes: 9 additions & 5 deletions .github/actions/javascript/awaitStagingDeploys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12421,7 +12421,11 @@ class GithubUtils {
if (data.length > 1) {
throw new Error(`Found more than one ${CONST_1.default.LABELS.STAGING_DEPLOY} issue.`);
}
return this.getStagingDeployCashData(data[0]);
const issue = data.at(0);
if (!issue) {
throw new Error(`Found an undefined ${CONST_1.default.LABELS.STAGING_DEPLOY} issue.`);
}
return this.getStagingDeployCashData(issue);
});
}
/**
Expand Down Expand Up @@ -12499,7 +12503,7 @@ class GithubUtils {
}
internalQASection = internalQASection[1];
const internalQAPRs = [...internalQASection.matchAll(new RegExp(`- \\[([ x])]\\s(${CONST_1.default.PULL_REQUEST_REGEX.source})`, 'g'))].map((match) => ({
url: match[2].split('-')[0].trim(),
url: match[2].split('-').at(0)?.trim() ?? '',
number: Number.parseInt(match[3], 10),
isResolved: match[1] === 'x',
}));
Expand Down Expand Up @@ -12583,7 +12587,7 @@ class GithubUtils {
* Fetch all pull requests given a list of PR numbers.
*/
static fetchAllPullRequests(pullRequestNumbers) {
const oldestPR = pullRequestNumbers.sort((a, b) => a - b)[0];
const oldestPR = pullRequestNumbers.sort((a, b) => a - b).at(0);
return this.paginate(this.octokit.pulls.list, {
owner: CONST_1.default.GITHUB_OWNER,
repo: CONST_1.default.APP_REPO,
Expand Down Expand Up @@ -12657,7 +12661,7 @@ class GithubUtils {
repo: CONST_1.default.APP_REPO,
workflow_id: workflow,
})
.then((response) => response.data.workflow_runs[0]?.id);
.then((response) => response.data.workflow_runs.at(0)?.id ?? -1);
}
/**
* Generate the URL of an New Expensify pull request given the PR number.
Expand Down Expand Up @@ -12725,7 +12729,7 @@ class GithubUtils {
per_page: 1,
name: artifactName,
})
.then((response) => response.data.artifacts[0]);
.then((response) => response.data.artifacts.at(0));
}
/**
* Given an artifact ID, returns the download URL to a zip file containing the artifact.
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/javascript/bumpVersion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3536,7 +3536,7 @@ exports.updateAndroidVersion = updateAndroidVersion;
* Updates the CFBundleShortVersionString and the CFBundleVersion.
*/
function updateiOSVersion(version) {
const shortVersion = version.split('-')[0];
const shortVersion = version.split('-').at(0);
const cfVersion = version.includes('-') ? version.replace('-', '.') : `${version}.0`;
console.log('Updating iOS', `CFBundleShortVersionString: ${shortVersion}`, `CFBundleVersion: ${cfVersion}`);
// Update Plists
Expand Down
14 changes: 9 additions & 5 deletions .github/actions/javascript/checkDeployBlockers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11704,7 +11704,11 @@ class GithubUtils {
if (data.length > 1) {
throw new Error(`Found more than one ${CONST_1.default.LABELS.STAGING_DEPLOY} issue.`);
}
return this.getStagingDeployCashData(data[0]);
const issue = data.at(0);
if (!issue) {
throw new Error(`Found an undefined ${CONST_1.default.LABELS.STAGING_DEPLOY} issue.`);
}
return this.getStagingDeployCashData(issue);
});
}
/**
Expand Down Expand Up @@ -11782,7 +11786,7 @@ class GithubUtils {
}
internalQASection = internalQASection[1];
const internalQAPRs = [...internalQASection.matchAll(new RegExp(`- \\[([ x])]\\s(${CONST_1.default.PULL_REQUEST_REGEX.source})`, 'g'))].map((match) => ({
url: match[2].split('-')[0].trim(),
url: match[2].split('-').at(0)?.trim() ?? '',
number: Number.parseInt(match[3], 10),
isResolved: match[1] === 'x',
}));
Expand Down Expand Up @@ -11866,7 +11870,7 @@ class GithubUtils {
* Fetch all pull requests given a list of PR numbers.
*/
static fetchAllPullRequests(pullRequestNumbers) {
const oldestPR = pullRequestNumbers.sort((a, b) => a - b)[0];
const oldestPR = pullRequestNumbers.sort((a, b) => a - b).at(0);
return this.paginate(this.octokit.pulls.list, {
owner: CONST_1.default.GITHUB_OWNER,
repo: CONST_1.default.APP_REPO,
Expand Down Expand Up @@ -11940,7 +11944,7 @@ class GithubUtils {
repo: CONST_1.default.APP_REPO,
workflow_id: workflow,
})
.then((response) => response.data.workflow_runs[0]?.id);
.then((response) => response.data.workflow_runs.at(0)?.id ?? -1);
}
/**
* Generate the URL of an New Expensify pull request given the PR number.
Expand Down Expand Up @@ -12008,7 +12012,7 @@ class GithubUtils {
per_page: 1,
name: artifactName,
})
.then((response) => response.data.artifacts[0]);
.then((response) => response.data.artifacts.at(0));
}
/**
* Given an artifact ID, returns the download URL to a zip file containing the artifact.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,24 @@ async function run(): Promise<IssuesCreateResponse | void> {

// Look at the state of the most recent StagingDeployCash,
// if it is open then we'll update the existing one, otherwise, we'll create a new one.
const mostRecentChecklist = recentDeployChecklists[0];
const mostRecentChecklist = recentDeployChecklists.at(0);

if (!mostRecentChecklist) {
throw new Error('Could not find the most recent checklist');
}

const shouldCreateNewDeployChecklist = mostRecentChecklist.state !== 'open';
const previousChecklist = shouldCreateNewDeployChecklist ? mostRecentChecklist : recentDeployChecklists[1];
const previousChecklist = shouldCreateNewDeployChecklist ? mostRecentChecklist : recentDeployChecklists.at(1);
if (shouldCreateNewDeployChecklist) {
console.log('Latest StagingDeployCash is closed, creating a new one.', mostRecentChecklist);
} else {
console.log('Latest StagingDeployCash is open, updating it instead of creating a new one.', 'Current:', mostRecentChecklist, 'Previous:', previousChecklist);
}

if (!previousChecklist) {
throw new Error('Could not find the previous checklist');
}

// Parse the data from the previous and current checklists into the format used to generate the checklist
const previousChecklistData = GithubUtils.getStagingDeployCashData(previousChecklist);
const currentChecklistData: StagingDeployCashData | undefined = shouldCreateNewDeployChecklist ? undefined : GithubUtils.getStagingDeployCashData(mostRecentChecklist);
Expand Down
24 changes: 17 additions & 7 deletions .github/actions/javascript/createOrUpdateStagingDeploy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14229,15 +14229,21 @@ async function run() {
});
// Look at the state of the most recent StagingDeployCash,
// if it is open then we'll update the existing one, otherwise, we'll create a new one.
const mostRecentChecklist = recentDeployChecklists[0];
const mostRecentChecklist = recentDeployChecklists.at(0);
if (!mostRecentChecklist) {
throw new Error('Could not find the most recent checklist');
}
const shouldCreateNewDeployChecklist = mostRecentChecklist.state !== 'open';
const previousChecklist = shouldCreateNewDeployChecklist ? mostRecentChecklist : recentDeployChecklists[1];
const previousChecklist = shouldCreateNewDeployChecklist ? mostRecentChecklist : recentDeployChecklists.at(1);
if (shouldCreateNewDeployChecklist) {
console.log('Latest StagingDeployCash is closed, creating a new one.', mostRecentChecklist);
}
else {
console.log('Latest StagingDeployCash is open, updating it instead of creating a new one.', 'Current:', mostRecentChecklist, 'Previous:', previousChecklist);
}
if (!previousChecklist) {
throw new Error('Could not find the previous checklist');
}
// Parse the data from the previous and current checklists into the format used to generate the checklist
const previousChecklistData = GithubUtils_1.default.getStagingDeployCashData(previousChecklist);
const currentChecklistData = shouldCreateNewDeployChecklist ? undefined : GithubUtils_1.default.getStagingDeployCashData(mostRecentChecklist);
Expand Down Expand Up @@ -14735,7 +14741,11 @@ class GithubUtils {
if (data.length > 1) {
throw new Error(`Found more than one ${CONST_1.default.LABELS.STAGING_DEPLOY} issue.`);
}
return this.getStagingDeployCashData(data[0]);
const issue = data.at(0);
if (!issue) {
throw new Error(`Found an undefined ${CONST_1.default.LABELS.STAGING_DEPLOY} issue.`);
}
return this.getStagingDeployCashData(issue);
});
}
/**
Expand Down Expand Up @@ -14813,7 +14823,7 @@ class GithubUtils {
}
internalQASection = internalQASection[1];
const internalQAPRs = [...internalQASection.matchAll(new RegExp(`- \\[([ x])]\\s(${CONST_1.default.PULL_REQUEST_REGEX.source})`, 'g'))].map((match) => ({
url: match[2].split('-')[0].trim(),
url: match[2].split('-').at(0)?.trim() ?? '',
number: Number.parseInt(match[3], 10),
isResolved: match[1] === 'x',
}));
Expand Down Expand Up @@ -14897,7 +14907,7 @@ class GithubUtils {
* Fetch all pull requests given a list of PR numbers.
*/
static fetchAllPullRequests(pullRequestNumbers) {
const oldestPR = pullRequestNumbers.sort((a, b) => a - b)[0];
const oldestPR = pullRequestNumbers.sort((a, b) => a - b).at(0);
return this.paginate(this.octokit.pulls.list, {
owner: CONST_1.default.GITHUB_OWNER,
repo: CONST_1.default.APP_REPO,
Expand Down Expand Up @@ -14971,7 +14981,7 @@ class GithubUtils {
repo: CONST_1.default.APP_REPO,
workflow_id: workflow,
})
.then((response) => response.data.workflow_runs[0]?.id);
.then((response) => response.data.workflow_runs.at(0)?.id ?? -1);
}
/**
* Generate the URL of an New Expensify pull request given the PR number.
Expand Down Expand Up @@ -15039,7 +15049,7 @@ class GithubUtils {
per_page: 1,
name: artifactName,
})
.then((response) => response.data.artifacts[0]);
.then((response) => response.data.artifacts.at(0));
}
/**
* Given an artifact ID, returns the download URL to a zip file containing the artifact.
Expand Down
14 changes: 9 additions & 5 deletions .github/actions/javascript/getArtifactInfo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11665,7 +11665,11 @@ class GithubUtils {
if (data.length > 1) {
throw new Error(`Found more than one ${CONST_1.default.LABELS.STAGING_DEPLOY} issue.`);
}
return this.getStagingDeployCashData(data[0]);
const issue = data.at(0);
if (!issue) {
throw new Error(`Found an undefined ${CONST_1.default.LABELS.STAGING_DEPLOY} issue.`);
}
return this.getStagingDeployCashData(issue);
});
}
/**
Expand Down Expand Up @@ -11743,7 +11747,7 @@ class GithubUtils {
}
internalQASection = internalQASection[1];
const internalQAPRs = [...internalQASection.matchAll(new RegExp(`- \\[([ x])]\\s(${CONST_1.default.PULL_REQUEST_REGEX.source})`, 'g'))].map((match) => ({
url: match[2].split('-')[0].trim(),
url: match[2].split('-').at(0)?.trim() ?? '',
number: Number.parseInt(match[3], 10),
isResolved: match[1] === 'x',
}));
Expand Down Expand Up @@ -11827,7 +11831,7 @@ class GithubUtils {
* Fetch all pull requests given a list of PR numbers.
*/
static fetchAllPullRequests(pullRequestNumbers) {
const oldestPR = pullRequestNumbers.sort((a, b) => a - b)[0];
const oldestPR = pullRequestNumbers.sort((a, b) => a - b).at(0);
return this.paginate(this.octokit.pulls.list, {
owner: CONST_1.default.GITHUB_OWNER,
repo: CONST_1.default.APP_REPO,
Expand Down Expand Up @@ -11901,7 +11905,7 @@ class GithubUtils {
repo: CONST_1.default.APP_REPO,
workflow_id: workflow,
})
.then((response) => response.data.workflow_runs[0]?.id);
.then((response) => response.data.workflow_runs.at(0)?.id ?? -1);
}
/**
* Generate the URL of an New Expensify pull request given the PR number.
Expand Down Expand Up @@ -11969,7 +11973,7 @@ class GithubUtils {
per_page: 1,
name: artifactName,
})
.then((response) => response.data.artifacts[0]);
.then((response) => response.data.artifacts.at(0));
}
/**
* Given an artifact ID, returns the download URL to a zip file containing the artifact.
Expand Down
14 changes: 9 additions & 5 deletions .github/actions/javascript/getDeployPullRequestList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12027,7 +12027,11 @@ class GithubUtils {
if (data.length > 1) {
throw new Error(`Found more than one ${CONST_1.default.LABELS.STAGING_DEPLOY} issue.`);
}
return this.getStagingDeployCashData(data[0]);
const issue = data.at(0);
if (!issue) {
throw new Error(`Found an undefined ${CONST_1.default.LABELS.STAGING_DEPLOY} issue.`);
}
return this.getStagingDeployCashData(issue);
});
}
/**
Expand Down Expand Up @@ -12105,7 +12109,7 @@ class GithubUtils {
}
internalQASection = internalQASection[1];
const internalQAPRs = [...internalQASection.matchAll(new RegExp(`- \\[([ x])]\\s(${CONST_1.default.PULL_REQUEST_REGEX.source})`, 'g'))].map((match) => ({
url: match[2].split('-')[0].trim(),
url: match[2].split('-').at(0)?.trim() ?? '',
number: Number.parseInt(match[3], 10),
isResolved: match[1] === 'x',
}));
Expand Down Expand Up @@ -12189,7 +12193,7 @@ class GithubUtils {
* Fetch all pull requests given a list of PR numbers.
*/
static fetchAllPullRequests(pullRequestNumbers) {
const oldestPR = pullRequestNumbers.sort((a, b) => a - b)[0];
const oldestPR = pullRequestNumbers.sort((a, b) => a - b).at(0);
return this.paginate(this.octokit.pulls.list, {
owner: CONST_1.default.GITHUB_OWNER,
repo: CONST_1.default.APP_REPO,
Expand Down Expand Up @@ -12263,7 +12267,7 @@ class GithubUtils {
repo: CONST_1.default.APP_REPO,
workflow_id: workflow,
})
.then((response) => response.data.workflow_runs[0]?.id);
.then((response) => response.data.workflow_runs.at(0)?.id ?? -1);
}
/**
* Generate the URL of an New Expensify pull request given the PR number.
Expand Down Expand Up @@ -12331,7 +12335,7 @@ class GithubUtils {
per_page: 1,
name: artifactName,
})
.then((response) => response.data.artifacts[0]);
.then((response) => response.data.artifacts.at(0));
}
/**
* Given an artifact ID, returns the download URL to a zip file containing the artifact.
Expand Down
Loading