chore: enable noUncheckedIndexedAccess, better type check (#2608)

This commit is contained in:
Stephen Zhou
2025-01-18 22:35:23 +08:00
committed by GitHub
parent f947bd1d1e
commit 2cd1b5daf9
182 changed files with 489 additions and 589 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ export const [routeAtom, , , , getReadonlyRoute, setRoute] = createAtomHooks(
}),
)
const noop = []
const noop: [] = []
export const useReadonlyRouteSelector = <T>(
selector: (route: RouteAtom) => T,
deps: any[] = noop,
@@ -1,5 +1,4 @@
import { cn } from "@follow/utils/utils"
import pkg from "@pkg"
import { Logo } from "../icons/logo"
@@ -8,7 +7,7 @@ export const PoweredByFooter: Component = ({ className }) => (
<span className="text-xs opacity-80">{new Date().getFullYear()}</span>{" "}
<Logo className="size-5" />{" "}
<a
href={pkg.homepage}
href="https://github.com/RSSNext"
className="cursor-pointer font-default font-bold text-accent no-underline"
target="_blank"
rel="noreferrer"
@@ -30,8 +30,8 @@ export const AutoResizeHeight: React.FC<AnimateChangeInHeightProps> = ({
if (!containerRef.current) return
const resizeObserver = new ResizeObserver((entries) => {
// We only have one entry, so we can use entries[0].
const target = entries[0].target as HTMLElement
const observedHeight = entries[0].contentRect.height
const target = entries[0]!.target as HTMLElement
const observedHeight = entries[0]!.contentRect.height
const style = getComputedStyle(target)
const marginHeight =
@@ -19,7 +19,7 @@ export interface ActionButtonProps {
shortcut?: string
disableTriggerShortcut?: boolean
enableHoverableContent?: boolean
size?: "sm" | "md" | "base"
size?: "sm" | "base"
/**
* @description only trigger shortcut when focus with in `<Focusable />`
@@ -1,5 +1,3 @@
import { PlatformIcon } from "@follow/components/ui/platform-icon/index.jsx"
import { getFeedIconSrc } from "@follow/components/utils/icon"
import type { CombinedEntryModel, FeedModel, FeedOrListRespModel } from "@follow/models/types"
import { getColorScheme, stringToHue } from "@follow/utils/color"
import { getImageProxyUrl } from "@follow/utils/img-proxy"
@@ -9,6 +7,9 @@ import { m } from "framer-motion"
import type { ReactNode } from "react"
import { forwardRef, useMemo } from "react"
import { getFeedIconSrc } from "../../utils/icon"
import { PlatformIcon } from "../platform-icon"
const FallbackableImage = forwardRef<
HTMLImageElement,
{
@@ -108,7 +109,7 @@ export function FeedIcon({
const [src] = getFeedIconSrc({
siteUrl,
})
finalSrc = src
finalSrc = src!
ImageElement = (
<PlatformIcon url={siteUrl} style={sizeStyle} className={cn("center mr-2", className)}>
@@ -145,7 +146,7 @@ export function FeedIcon({
height: size * 2,
},
})
finalSrc = src
finalSrc = src!
ImageElement = (
<PlatformIcon
@@ -156,7 +157,7 @@ export function FeedIcon({
<FallbackableImage
className={cn("mr-2", className)}
style={sizeStyle}
fallbackUrl={fallbackSrc}
fallbackUrl={fallbackSrc!}
/>
</PlatformIcon>
)
+1 -1
View File
@@ -31,7 +31,7 @@ const InputOTPSlot = React.forwardRef<
React.ComponentPropsWithoutRef<"div"> & { index: number }
>(({ index, className, ...props }, ref) => {
const inputOTPContext = React.useContext(OTPInputContext)
const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index]
const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index]!
return (
<div
+1 -1
View File
@@ -117,7 +117,7 @@ function simulateKeyPress(key: string) {
z: 90,
}
const code = keyCodes[key] || key.codePointAt(0)
const code = keyCodes[key as keyof typeof keyCodes] || key.codePointAt(0)
const event = new KeyboardEvent("keydown", {
key,
@@ -25,7 +25,7 @@ function rehypeTrimEndBrElement() {
}
for (let i = tree.children.length - 1; i >= 0; i--) {
const item = tree.children[i]
const item = tree.children[i]!
if (item.type === "element") {
if (item.tagName === "br") {
tree.children.pop()
@@ -56,8 +56,8 @@ export const parseHtml = (content: string, options?: ParseHtmlOptions) => {
rehypeSchema.attributes = {
...rehypeSchema.attributes,
"*": renderInlineStyle
? [...rehypeSchema.attributes!["*"], "style", "class"]
: rehypeSchema.attributes!["*"],
? [...rehypeSchema.attributes!["*"]!, "style", "class"]
: rehypeSchema.attributes!["*"]!,
video: ["src", "poster"],
}
}
@@ -3,6 +3,7 @@ import "remark-gh-alerts/styles/github-colors-light.css"
import "remark-gh-alerts/styles/github-colors-dark-media.css"
import "remark-gh-alerts/styles/github-base.css"
// @ts-ignore
import remarkCalloutDirectives from "@microflash/remark-callout-directives"
import type { Components } from "hast-util-to-jsx-runtime"
import { toJsxRuntime } from "hast-util-to-jsx-runtime"