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

Conversation

ShridharGoel
Copy link
Contributor

Details

Bump ESLint version to add prefer-at condition.

Fixed Issues

$ #43055
PROPOSAL: #43055 (comment)

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop

@ShridharGoel ShridharGoel requested review from a team as code owners August 14, 2024 16:03
@melvin-bot melvin-bot bot requested a review from eh2077 August 14, 2024 16:03
Copy link

melvin-bot bot commented Aug 14, 2024

Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!

@melvin-bot melvin-bot bot removed the request for review from a team August 14, 2024 16:03
Copy link

melvin-bot bot commented Aug 14, 2024

@eh2077 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@ShridharGoel ShridharGoel marked this pull request as draft August 14, 2024 16:03
@dubielzyk-expensify dubielzyk-expensify removed the request for review from a team August 15, 2024 00:25
@ShridharGoel ShridharGoel force-pushed the eslint-update branch 5 times, most recently from cadeafa to 380f4c7 Compare August 16, 2024 07:27
Copy link
Contributor

@fabioh8010 fabioh8010 left a comment

Choose a reason for hiding this comment

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

Did a partial review since there are actually hundreds of TS errors with the change to .at()

@ShridharGoel Whats the status of this PR? I think you can work on fixing the TS errors that are not related to this PR while we wait for that one. Please let's speed up the work here.

@@ -50,7 +50,7 @@ function ButtonWithDropdownMenu<IValueType>({
const {windowWidth, windowHeight} = useWindowDimensions();
const dropdownAnchor = useRef<View | null>(null);
const dropdownButtonRef = isSplitButton ? buttonRef : mergeRefs(buttonRef, dropdownAnchor);
const selectedItem = options[selectedItemIndex] || options[0];
const selectedItem = options.at(selectedItemIndex) ?? options.at(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's test this operator change to make sure there's no regression

src/components/Composer/index.native.tsx Outdated Show resolved Hide resolved
@@ -51,8 +51,8 @@ export default function generateMonthMatrix(year: number, month: number) {
}

// Add null values for days before the first day of the month
for (let i = matrix[0].length; i < 7; i++) {
matrix[0].unshift(undefined);
for (let i = matrix.at(0).length; i < 7; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We need some condition before because matrix.at(0) can be undefined now

src/components/DisplayNames/DisplayNamesWithTooltip.tsx Outdated Show resolved Hide resolved
src/components/MapView/MapView.tsx Outdated Show resolved Hide resolved
src/components/MapView/MapView.website.tsx Outdated Show resolved Hide resolved
src/libs/CurrencyUtils.ts Outdated Show resolved Hide resolved
@ShridharGoel
Copy link
Contributor Author

Whats the status of this PR?

This just needed an update of the eslint-config-expensify version after Expensify/eslint-config-expensify#114 gets merged. But now we'll need to fix the conflicts as well, and I'll add the suggested changes.

@fabioh8010
Copy link
Contributor

@ShridharGoel The ESLint PR was merged, could you prioritize work on this one? Thanks 🙏

@ShridharGoel ShridharGoel force-pushed the eslint-update branch 3 times, most recently from 3ce0318 to 9eea593 Compare August 24, 2024 10:17
@ShridharGoel
Copy link
Contributor Author

Just need to check the test failure now.

Copy link
Contributor

@fabioh8010 fabioh8010 left a comment

Choose a reason for hiding this comment

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

@ShridharGoel Thanks for the work on this. Some notes though:

  • Please run npm run gh-actions-build every time you change any files under .github/actions/javascript/ as we need to re-generate the compiled JS files.
  • I'm seeing many ESLint suppresions, mainly eslint-disable rulesdir/prefer-at which defeats the purpose of this PR. Let's address and remove all them as much as possible.
  • Let's remove [NoQA] from this PR's title as I think we should have extensive testing here due to changes in logic. @roryabraham WDYT about asking for a full regression test here?
  • Once you solve the lint / workflow errors I think we can open the PR to review.

const mostRecentChecklist = recentDeployChecklists.at(0);

if (!mostRecentChecklist) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return;
throw new Error('Could not find the most recent checklist');

Shouldn't we try an Error here instead?

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) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return;
throw new Error('Could not find the previous checklist');

@@ -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 ?? 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const previousChecklistID = deployChecklists.at(0)?.number ?? 0;
const previousChecklistID = deployChecklists.at(0)?.number;
if (!previousChecklistID) {
throw new Error('Could not find the previous checklist ID');
}

Comment on lines 96 to 97
const frontmatter = fs.readFileSync(path, 'utf8').split('---').at(1);
const frontmatterObject = yaml.load(frontmatter ?? '') as Record<string, unknown>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const frontmatter = fs.readFileSync(path, 'utf8').split('---').at(1);
const frontmatterObject = yaml.load(frontmatter ?? '') as Record<string, unknown>;
const frontmatter = fs.readFileSync(path, 'utf8').split('---').at(1);
if (!frontmatter) {
return;
}
const frontmatterObject = yaml.load(frontmatter) as Record<string, unknown>;

I think it's safer

Comment on lines 74 to 80
if (item) {
setActiveSource(item.source);
}

if (onNavigate) {
if (onNavigate && item) {
onNavigate(item);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (item) {
setActiveSource(item.source);
}
if (onNavigate) {
if (onNavigate && item) {
onNavigate(item);
}
if (item) {
setActiveSource(item.source);
if (onNavigate) {
onNavigate(item);
}
}

@@ -1,4 +1,6 @@
/* eslint-disable @typescript-eslint/naming-convention */

/* eslint-disable rulesdir/prefer-at */
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

@@ -1,3 +1,4 @@
/* eslint-disable rulesdir/prefer-at */
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

@@ -1,3 +1,4 @@
/* eslint-disable rulesdir/prefer-at */
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

@@ -1,3 +1,4 @@
/* eslint-disable rulesdir/prefer-at */
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/naming-convention */
/* eslint-disable rulesdir/prefer-at */
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

@roryabraham
Copy link
Contributor

WDYT about asking for a full regression test here?

We can do that, but let's do it on one platform only to save time and money

@ShridharGoel
Copy link
Contributor Author

ShridharGoel commented Sep 16, 2024 via email

@ShridharGoel ShridharGoel changed the title [NoQA] Bump ESLint version to add prefer-at condition Bump ESLint version to add prefer-at condition Sep 17, 2024
@ShridharGoel
Copy link
Contributor Author

Updated.

@fabioh8010
Copy link
Contributor

@ShridharGoel We got conflicts in the PR. Please address them together with the workflow failures (except Changed files ESLint check, let's ignore this one for now)

Screenshot 2024-09-17 at 15 44 37

@ShridharGoel
Copy link
Contributor Author

ShridharGoel commented Sep 17, 2024 via email

@fabioh8010
Copy link
Contributor

@ShridharGoel By looking at the workflow result, it seems to be only these ones:

  • src/pages/Search/SearchTypeMenuNarrow.tsx
  • src/components/DistanceRequest/DistanceRequestFooter.tsx
  • src/pages/home/report/ReportTypingIndicator.tsx

@ShridharGoel
Copy link
Contributor Author

ShridharGoel commented Sep 17, 2024

In ReportTypingIndicator, my only change is a single [] to at(). Any idea how can it lead to invalid nesting which is mentioned in logs generated locally?

@fabioh8010
Copy link
Contributor

@ShridharGoel There is a section about your error (Invalid nesting in program blocks or scopes) in REACT_COMPILER.md

@ShridharGoel
Copy link
Contributor Author

ShridharGoel commented Sep 18, 2024 via email

@ShridharGoel
Copy link
Contributor Author

All perf tests are passing locally, so is this a CI issue?

@ShridharGoel
Copy link
Contributor Author

Can we go ahead with the review on this?

@eh2077
Copy link
Contributor

eh2077 commented Sep 23, 2024

@ShridharGoel This issue has been reassigned, please check this #43055 (comment). So, I think this PR will be on hold.

@ShridharGoel
Copy link
Contributor Author

ShridharGoel commented Sep 23, 2024 via email

@ShridharGoel
Copy link
Contributor Author

CC: @roryabraham

@ShridharGoel ShridharGoel marked this pull request as ready for review September 24, 2024 10:04
@roryabraham roryabraham closed this Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants