Skip to content
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

Bump ESLint version to add prefer-at condition #47439

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,5 +289,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,7 +54,7 @@ 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 checklist = partitionWithChecklist(fileContents).at(1) ?? '';
const numberOfChecklistItems = (checklist.match(/\[ \]/g) ?? []).length;
return numberOfChecklistItems;
}
Expand Down
16 changes: 10 additions & 6 deletions .github/actions/javascript/authorChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16771,7 +16771,7 @@ function partitionWithChecklist(body) {
async function getNumberOfItemsFromAuthorChecklist() {
const response = await fetch(pathToAuthorChecklist);
const fileContents = await response.text();
const checklist = partitionWithChecklist(fileContents)[1];
const checklist = partitionWithChecklist(fileContents).at(1) ?? '';
const numberOfChecklistItems = (checklist.match(/\[ \]/g) ?? []).length;
return numberOfChecklistItems;
}
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
Loading