Skip to content

Commit

Permalink
Bump ESLint version to add prefer-at condition
Browse files Browse the repository at this point in the history
  • Loading branch information
ShridharGoel committed Aug 15, 2024
1 parent a07cce4 commit 9104a0f
Show file tree
Hide file tree
Showing 211 changed files with 872 additions and 850 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ 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);
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async function run() {
labels: CONST.LABELS.STAGING_DEPLOY,
state: 'closed',
});
const previousChecklistID = deployChecklists[0].number;
const previousChecklistID = deployChecklists.at(0).number;

// who closed the last deploy checklist?
const deployer = await GithubUtils.getActorWhoClosedIssue(previousChecklistID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async function run() {
if (assistantResponse.includes(`[${CONST.NO_ACTION}]`)) {
// extract the text after [NO_ACTION] from assistantResponse since this is a
// bot related action keyword
const noActionContext = assistantResponse.split(`[${CONST.NO_ACTION}] `)?.[1]?.replace('"', '');
const noActionContext = assistantResponse.split(`[${CONST.NO_ACTION}] `).at(1)?.replace('"', '');
console.log('[NO_ACTION] w/ context: ', noActionContext);
return;
}
Expand All @@ -86,10 +86,10 @@ async function run() {
} else if (assistantResponse.includes('[EDIT_COMMENT]') && !payload.comment?.body.includes('Edited by **proposal-police**')) {
// extract the text after [EDIT_COMMENT] from assistantResponse since this is a
// bot related action keyword
let extractedNotice = assistantResponse.split('[EDIT_COMMENT] ')?.[1]?.replace('"', '');
let extractedNotice = assistantResponse.split('[EDIT_COMMENT] ').at(1)?.replace('"', '');
// format the github's updated_at like: 2024-01-24 13:15:24 UTC not 2024-01-28 18:18:28.000 UTC
const date = new Date(payload.comment?.updated_at ?? '');
const formattedDate = `${date.toISOString()?.split('.')?.[0]?.replace('T', ' ')} UTC`;
const formattedDate = `${date.toISOString()?.split('.').at(0)?.replace('T', ' ')} UTC`;
extractedNotice = extractedNotice.replace('{updated_timestamp}', formattedDate);
console.log('ProposalPolice™ editing issue comment...', payload.comment.id);
await GithubUtils.octokit.issues.updateComment({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function checkIssueForCompletedChecklist(numberOfChecklistItems: number) {
}

const whitespace = /([\n\r])/gm;
const comment = combinedComments[i].replace(whitespace, '');
const comment = combinedComments.at(i).replace(whitespace, '');

console.log(`Comment ${i} starts with: ${comment.slice(0, 20)}...`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const run = (): boolean => {
console.log(`Processing ${regressionOutput.countChanged.length} measurements...`);

for (let i = 0; i < regressionOutput.countChanged.length; i++) {
const measurement = regressionOutput.countChanged[i];
const measurement = regressionOutput.countChanged.at(i);
const baseline: PerformanceEntry = measurement.baseline;
const current: PerformanceEntry = measurement.current;

Expand Down
10 changes: 5 additions & 5 deletions .github/libs/GithubUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class GithubUtils {
throw new Error(`Found more than one ${CONST.LABELS.STAGING_DEPLOY} issue.`);
}

return this.getStagingDeployCashData(data[0]);
return this.getStagingDeployCashData(data.at(0));
});
}

Expand Down Expand Up @@ -254,7 +254,7 @@ class GithubUtils {
}
internalQASection = internalQASection[1];
const internalQAPRs = [...internalQASection.matchAll(new RegExp(`- \\[([ x])]\\s(${CONST.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 @@ -367,7 +367,7 @@ class GithubUtils {
* Fetch all pull requests given a list of PR numbers.
*/
static fetchAllPullRequests(pullRequestNumbers: number[]): Promise<OctokitPR[] | void> {
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,
{
Expand Down Expand Up @@ -459,7 +459,7 @@ class GithubUtils {
repo: CONST.APP_REPO,
workflow_id: workflow,
})
.then((response) => response.data.workflow_runs[0]?.id);
.then((response) => response.data.workflow_runs.at(0)?.id);
}

/**
Expand Down Expand Up @@ -533,7 +533,7 @@ class GithubUtils {
per_page: 1,
name: artifactName,
})
.then((response) => response.data.artifacts[0]);
.then((response) => response.data.artifacts.at(0));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion .github/libs/nativeVersionUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function updateAndroidVersion(versionName: string, versionCode: string): Promise
* Updates the CFBundleShortVersionString and the CFBundleVersion.
*/
function updateiOSVersion(version: string): string {
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}`);

Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/createDocsRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function pushOrCreateEntry<TKey extends HubEntriesKey>(hubs: Hub[], hub: string,
}

function getOrderFromArticleFrontMatter(path: string): number | undefined {
const frontmatter = fs.readFileSync(path, 'utf8').split('---')[1];
const frontmatter = fs.readFileSync(path, 'utf8').split('---').at(1);
const frontmatterObject = yaml.load(frontmatter) as Record<string, unknown>;
return frontmatterObject.order as number | undefined;
}
Expand Down
6 changes: 3 additions & 3 deletions .storybook/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ const webpackConfig = ({config}: {config: Configuration}) => {

// Necessary to overwrite the values in the existing DefinePlugin hardcoded to the Config staging values
const definePluginIndex = config.plugins.findIndex((plugin) => plugin instanceof DefinePlugin);
if (definePluginIndex !== -1 && config.plugins[definePluginIndex] instanceof DefinePlugin) {
const definePlugin = config.plugins[definePluginIndex] as DefinePlugin;
if (definePluginIndex !== -1 && config.plugins.at(definePluginIndex) instanceof DefinePlugin) {
const definePlugin = config.plugins.at(definePluginIndex) as DefinePlugin;
if (definePlugin.definitions) {
definePlugin.definitions.__REACT_WEB_CONFIG__ = JSON.stringify(env);
}
}
config.resolve.extensions = custom.resolve.extensions;

const babelRulesIndex = custom.module.rules.findIndex((rule) => rule.loader === 'babel-loader');
const babelRule = custom.module.rules[babelRulesIndex];
const babelRule = custom.module.rules.at(babelRulesIndex);
if (babelRule) {
config.module.rules?.push(babelRule);
}
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1009002100
versionName "9.0.21-0"
versionCode 1009002006
versionName "9.0.20-6"
// Supported language variants must be declared here to avoid from being removed during the compilation.
// This also helps us to not include unnecessary language variants in the APK.
resConfigs "en", "es"
Expand Down
2 changes: 1 addition & 1 deletion assets/emojis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const localeEmojis: LocaleEmojis = {
};

const importEmojiLocale = (locale: Locale) => {
const normalizedLocale = locale.toLowerCase().split('-')[0] as Locale;
const normalizedLocale = locale.toLowerCase().split('-').at(0) as Locale;
if (!localeEmojis[normalizedLocale]) {
const emojiImportPromise = normalizedLocale === 'en' ? import('./en') : import('./es');
return emojiImportPromise.then((esEmojiModule) => {
Expand Down
2 changes: 1 addition & 1 deletion config/webpack/webpack.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const environmentToLogoSuffixMap: Record<string, string> = {
};

function mapEnvironmentToLogoSuffix(environmentFile: string): string {
let environment = environmentFile.split('.')[2];
let environment = environmentFile.split('.').at(2);
if (typeof environment === 'undefined') {
environment = 'dev';
}
Expand Down
4 changes: 2 additions & 2 deletions ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>9.0.21</string>
<string>9.0.20</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
Expand All @@ -40,7 +40,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>9.0.21.0</string>
<string>9.0.20.6</string>
<key>FullStory</key>
<dict>
<key>OrgId</key>
Expand Down
4 changes: 2 additions & 2 deletions ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>9.0.21</string>
<string>9.0.20</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>9.0.21.0</string>
<string>9.0.20.6</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions ios/NotificationServiceExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundleShortVersionString</key>
<string>9.0.21</string>
<string>9.0.20</string>
<key>CFBundleVersion</key>
<string>9.0.21.0</string>
<string>9.0.20.6</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
Expand Down
2 changes: 1 addition & 1 deletion jest/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jest.mock('react-native/Libraries/LogBox/LogBox', () => ({

// Turn off the console logs for timing events. They are not relevant for unit tests and create a lot of noise
jest.spyOn(console, 'debug').mockImplementation((...params: string[]) => {
if (params[0].startsWith('Timing:')) {
if (params.at(0).startsWith('Timing:')) {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "9.0.21-0",
"version": "9.0.20-6",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down Expand Up @@ -273,7 +273,7 @@
"electron-builder": "25.0.0",
"eslint": "^8.57.0",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-config-expensify": "^2.0.58",
"eslint-config-expensify": "^2.0.56",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-jsdoc": "^46.2.6",
Expand Down
2 changes: 1 addition & 1 deletion scripts/release-profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if (cpuProfiles.length === 0) {
process.exit(1);
} else {
// Construct the command
const cpuprofileName = cpuProfiles[0];
const cpuprofileName = cpuProfiles.at(0);
const command = `npx react-native-release-profiler --local "${cpuprofileName}" --sourcemap-path "${sourcemapPath}"`;

console.log(`Executing: ${command}`);
Expand Down
2 changes: 1 addition & 1 deletion src/components/AddPlaidBankAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function AddPlaidBankAccount({
const {icon, iconSize, iconStyles} = getBankIcon({styles});
const plaidErrors = plaidData?.errors;
// eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style
const plaidDataErrorMessage = !isEmptyObject(plaidErrors) ? (Object.values(plaidErrors)[0] as string) : '';
const plaidDataErrorMessage = !isEmptyObject(plaidErrors) ? (Object.values(plaidErrors).at(0) as string) : '';
const bankName = plaidData?.bankName;

/**
Expand Down
7 changes: 5 additions & 2 deletions src/components/AttachmentPicker/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ function AttachmentPicker({type = CONST.ATTACHMENT_PICKER_TYPE.FILE, children, s
const uri = manipResult.uri;
const convertedAsset = {
uri,
name: uri.substring(uri.lastIndexOf('/') + 1).split('?')[0],
name: uri
.substring(uri.lastIndexOf('/') + 1)
.split('?')
.at(0),
type: 'image/jpeg',
width: manipResult.width,
height: manipResult.height,
Expand Down Expand Up @@ -363,7 +366,7 @@ function AttachmentPicker({type = CONST.ATTACHMENT_PICKER_TYPE.FILE, children, s
if (focusedIndex === -1) {
return;
}
selectItem(menuItemData[focusedIndex]);
selectItem(menuItemData.at(focusedIndex));
setFocusedIndex(-1); // Reset the focusedIndex on selecting any menu
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ function AttachmentCarousel({report, reportActions, parentReportActions, source,
}

// Update the parent modal's state with the source and name from the mapped attachments
if (targetAttachments[initialPage] !== undefined && onNavigate) {
onNavigate(targetAttachments[initialPage]);
if (targetAttachments.at(initialPage) !== undefined && onNavigate) {
onNavigate(targetAttachments.at(initialPage));
}
}
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
Expand All @@ -66,7 +66,7 @@ function AttachmentCarousel({report, reportActions, parentReportActions, source,
Keyboard.dismiss();
setShouldShowArrows(true);

const item = attachments[newPageIndex];
const item = attachments.at(newPageIndex);

setPage(newPageIndex);
setActiveSource(item.source);
Expand Down
8 changes: 4 additions & 4 deletions src/components/Attachments/AttachmentCarousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ function AttachmentCarousel({report, reportActions, parentReportActions, source,
}

// Update the parent modal's state with the source and name from the mapped attachments
if (targetAttachments[initialPage] !== undefined && onNavigate) {
onNavigate(targetAttachments[initialPage]);
if (targetAttachments.at(initialPage) !== undefined && onNavigate) {
onNavigate(targetAttachments.at(initialPage));
}
}
}, [report.privateNotes, reportActions, parentReportActions, compareImage, report.parentReportActionID, attachments, setDownloadButtonVisibility, onNavigate, accountID, type]);
Expand All @@ -129,7 +129,7 @@ function AttachmentCarousel({report, reportActions, parentReportActions, source,

// Since we can have only one item in view at a time, we can use the first item in the array
// to get the index of the current page
const entry = viewableItems[0];
const entry = viewableItems.at(0);
if (!entry) {
setActiveSource(null);
return;
Expand All @@ -156,7 +156,7 @@ function AttachmentCarousel({report, reportActions, parentReportActions, source,
}

const nextIndex = page + deltaSlide;
const nextItem = attachments[nextIndex];
const nextItem = attachments.at(nextIndex);

if (!nextItem || !scrollRef.current) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ function AttachmentViewPdf(props: AttachmentViewPdfProps) {
.manualActivation(true)
.onTouchesMove((evt) => {
if (offsetX.value !== 0 && offsetY.value !== 0 && isScrollEnabled) {
const translateX = Math.abs(evt.allTouches[0].absoluteX - offsetX.value);
const translateY = Math.abs(evt.allTouches[0].absoluteY - offsetY.value);
const translateX = Math.abs(evt.allTouches.at(0).absoluteX - offsetX.value);
const translateY = Math.abs(evt.allTouches.at(0).absoluteY - offsetY.value);
const allowEnablingScroll = !isPanGestureActive.value || isScrollEnabled.value;

// if the value of X is greater than Y and the pdf is not zoomed in,
Expand All @@ -49,8 +49,8 @@ function AttachmentViewPdf(props: AttachmentViewPdfProps) {
}

isPanGestureActive.value = true;
offsetX.value = evt.allTouches[0].absoluteX;
offsetY.value = evt.allTouches[0].absoluteY;
offsetX.value = evt.allTouches.at(0).absoluteX;
offsetY.value = evt.allTouches.at(0).absoluteY;
})
.onTouchesUp(() => {
isPanGestureActive.value = false;
Expand Down
Loading

0 comments on commit 9104a0f

Please sign in to comment.