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

chore(v2): Fix linter warnings #4442

Merged
merged 3 commits into from
Mar 17, 2021
Merged

chore(v2): Fix linter warnings #4442

merged 3 commits into from
Mar 17, 2021

Conversation

SamChou19815
Copy link
Contributor

@SamChou19815 SamChou19815 commented Mar 16, 2021

Motivation

Help reduce number of linter warnings. .

223 warnings to 148 warnings.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

I avoided changes that can potentially cause runtime behavior changes. All the changes here are almost all type-only. Since it passes the type checker and linter, it shouldn't affect any runtime behavior.

Related PRs

N/A

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Mar 16, 2021
@netlify
Copy link

netlify bot commented Mar 16, 2021

@netlify
Copy link

netlify bot commented Mar 16, 2021

Deploy preview for docusaurus-2 ready!

Built without sensitive environment variables with commit 97513ba

https://deploy-preview-4442--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented Mar 16, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 63
🟢 Accessibility 96
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-4442--docusaurus-2.netlify.app/classic/

223 warnings to 145 warnings
Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

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

thanks, almost good

just wondering if it's not better to use TS inference for some return types?

Particularly on hooks that are not public API, I find declaring full fn signature type creates a lot of boilerplate

): {
readonly preferredVersion: any;
readonly savePreferredVersionName: (versionName: string) => void;
} {
Copy link
Collaborator

Choose a reason for hiding this comment

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

do we really want to have explicit returns everywhere?

I find this a bit annoying personally and like to leverage inference in some cases

@@ -32,11 +34,39 @@ export type Navbar = {
logo?: NavbarLogo;
};

export type ColorModeConfig = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

FYI @armano2 this is likely to conflict with your work here: #4433

Copy link
Contributor

Choose a reason for hiding this comment

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

no worries, i have to redo this pr anyway, and i'm going to split it to smaller pieces

@@ -113,22 +116,22 @@ function Link({
if (IOSupported && ref && isInternal) {
// If IO supported and element reference found, setup Observer functionality.
handleIntersection(ref, () => {
window.docusaurus.prefetch(targetLink);
window.docusaurus.prefetch(targetLink || '');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we prefetch anything if there is no targetLink ?

});
}
};

const onMouseEnter = () => {
if (!preloaded.current) {
window.docusaurus.preload(targetLink);
window.docusaurus.preload(targetLink || '');
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

preloaded.current = true;
}
};

useEffect(() => {
// If IO is not supported. We prefetch by default (only once).
if (!IOSupported && isInternal) {
window.docusaurus.prefetch(targetLink);
window.docusaurus.prefetch(targetLink || '');
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

export function usePluralForm() {
export function usePluralForm(): {
selectMessage: (count: number, pluralMessages: string) => string;
} {
Copy link
Collaborator

Choose a reason for hiding this comment

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

also prefer inference here

locale: string;
fullyQualified: boolean;
}) => string;
} {
Copy link
Collaborator

Choose a reason for hiding this comment

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

😅 I'd prefer just using inference here

@slorber slorber added the pr: polish This PR adds a very minor behavior improvement that users will enjoy. label Mar 17, 2021
@slorber
Copy link
Collaborator

slorber commented Mar 17, 2021

thanks :)

@slorber slorber merged commit 5e73c72 into facebook:master Mar 17, 2021
@SamChou19815 SamChou19815 deleted the fix-linter-warnings branch March 17, 2021 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: polish This PR adds a very minor behavior improvement that users will enjoy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants