Skip to content

chore(v2): Fix linter warnings#4442

Merged
slorber merged 3 commits intofacebook:masterfrom
SamChou19815:fix-linter-warnings
Mar 17, 2021
Merged

chore(v2): Fix linter warnings#4442
slorber merged 3 commits intofacebook:masterfrom
SamChou19815:fix-linter-warnings

Conversation

@SamChou19815
Copy link
Copy Markdown
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
Copy Markdown

netlify bot commented Mar 16, 2021

@netlify
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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

logo?: NavbarLogo;
};

export type ColorModeConfig = {
Copy link
Copy Markdown
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
Copy Markdown
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

// If IO supported and element reference found, setup Observer functionality.
handleIntersection(ref, () => {
window.docusaurus.prefetch(targetLink);
window.docusaurus.prefetch(targetLink || '');
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same

// If IO is not supported. We prefetch by default (only once).
if (!IOSupported && isInternal) {
window.docusaurus.prefetch(targetLink);
window.docusaurus.prefetch(targetLink || '');
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@SamChou19815 SamChou19815 requested a review from slorber March 17, 2021 16:02
@slorber
Copy link
Copy Markdown
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