-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
Conversation
[V1] Deploy preview failure Built without sensitive environment variables with commit 97513ba https://app.netlify.com/sites/docusaurus-1/deploys/6052286fec1fc50008eff9e5 |
Deploy preview for docusaurus-2 ready! Built without sensitive environment variables with commit 97513ba |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-4442--docusaurus-2.netlify.app/classic/ |
223 warnings to 145 warnings
There was a problem hiding this 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; | ||
} { |
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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 || ''); |
There was a problem hiding this comment.
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 || ''); |
There was a problem hiding this comment.
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 || ''); |
There was a problem hiding this comment.
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; | ||
} { |
There was a problem hiding this comment.
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; | ||
} { |
There was a problem hiding this comment.
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
thanks :) |
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