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

Add React exhaustive-deps and compiler ESLint rules #6972

Merged
merged 7 commits into from
Oct 22, 2024

Conversation

raksooo
Copy link
Member

@raksooo raksooo commented Oct 11, 2024

This PR adds the React hooks exhaustive-deps rule and the React compiler rule to ESLint. I've also prohibited @ts-ignore comments and replaced the existing ones with @ts-expect-error, and done some general clean up.

There is no good way to implement WillExit and useWillExit that conforms with these rules (and Reacts design principles) so I removed those as they won't be needed in the upcoming PR where we move to the JavaScript ViewTransition API.

I really suggest going through this PR commit-by-commit.

Fixes DES-1314.


This change is Reviewable

Copy link

socket-security bot commented Oct 11, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/[email protected] Transitive: environment, filesystem, unsafe +56 15.4 MB react-bot

🚮 Removed packages: npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]

View full report↗︎

Copy link

linear bot commented Oct 11, 2024

@raksooo raksooo force-pushed the add-react-linter-rules branch 2 times, most recently from d3d7870 to f787bb2 Compare October 14, 2024 14:02
@raksooo raksooo force-pushed the add-react-linter-rules branch 2 times, most recently from df884fb to 6de8276 Compare October 16, 2024 10:16
Copy link
Contributor

@MarkusPettersson98 MarkusPettersson98 left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r1, 47 of 64 files at r2.
Reviewable status: 21 of 83 files reviewed, all discussions resolved


gui/src/renderer/components/NotificationBanner.tsx line 168 at r2 (raw file):

  }, [props.children]);

  // eslint-disable-next-line react-hooks/exhaustive-deps

A motivation why the lint rule is disabled would be nice:)

Code quote:

  // eslint-disable-next-line react-hooks/exhaustive-deps

Copy link
Contributor

@MarkusPettersson98 MarkusPettersson98 left a comment

Choose a reason for hiding this comment

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

Reviewed 17 of 64 files at r2, 3 of 3 files at r3, 12 of 12 files at r4, 5 of 5 files at r5, 52 of 52 files at r6, 1 of 1 files at r7, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved


gui/test/unit/notification-evaluation.spec.ts line 31 at r5 (raw file):

  before(() => {
    sandbox = sinon.createSandbox();
    // @ts-expect-error Way to many methods to mock.

too*

Code quote:

to

Copy link
Member Author

@raksooo raksooo left a comment

Choose a reason for hiding this comment

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

I've now made all the updates we talked about yesterday.

Reviewable status: 0 of 84 files reviewed, all discussions resolved (waiting on @MarkusPettersson98)


gui/src/renderer/components/NotificationBanner.tsx line 168 at r2 (raw file):

Previously, MarkusPettersson98 (Markus Pettersson) wrote…

A motivation why the lint rule is disabled would be nice:)

This was removed in a later commit.


gui/test/unit/notification-evaluation.spec.ts line 31 at r5 (raw file):

Previously, MarkusPettersson98 (Markus Pettersson) wrote…

too*

Done!

Copy link
Contributor

@MarkusPettersson98 MarkusPettersson98 left a comment

Choose a reason for hiding this comment

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

:lgtm: 🎉

Reviewed 7 of 7 files at r8, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

Copy link
Contributor

@MarkusPettersson98 MarkusPettersson98 left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r9, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @raksooo)


gui/src/renderer/components/EditApiAccessMethod.tsx line 73 at r9 (raw file):

      const enabled = id === undefined ? true : (method?.enabled ?? true);
      const updatedMethod = { ...newMethod, enabled };
      console.log(JSON.stringify(updatedMethod));

Should this console.log be left in? 😊

Code quote:

console.log(JSON.stringify(updatedMethod));

Copy link
Member Author

@raksooo raksooo left a comment

Choose a reason for hiding this comment

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

Reviewable status: 81 of 83 files reviewed, 1 unresolved discussion (waiting on @MarkusPettersson98)


gui/src/renderer/components/EditApiAccessMethod.tsx line 73 at r9 (raw file):

Previously, MarkusPettersson98 (Markus Pettersson) wrote…

Should this console.log be left in? 😊

Thanks for spotting that! Removed!

Copy link
Contributor

@MarkusPettersson98 MarkusPettersson98 left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 2 files at r10, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@raksooo raksooo merged commit 1ec8c9d into main Oct 22, 2024
13 checks passed
@raksooo raksooo deleted the add-react-linter-rules branch October 22, 2024 13:32
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.

2 participants