Skip to content

Commit 1afb803

Browse files
committed
chore: make eslint happy
1 parent b3ff457 commit 1afb803

32 files changed

Lines changed: 57 additions & 44 deletions

File tree

packages/docs/src/app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export const metadata: Metadata = {
8888
}
8989
};
9090

91-
export default async function RootLayout({ children }: { children: React.ReactNode }) {
91+
export default async function RootLayout({ children }: React.PropsWithChildren) {
9292
const pageMap = await getPageMap();
9393

9494
const navbar = (

packages/foxact/src/breadcrumbs/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface BreadcrumbItemProps<T = unknown> {
2121
export interface BreadcrumbPageProps<T = unknown> {
2222
title: string,
2323
meta?: T,
24-
// eslint-disable-next-line @typescript-eslint/no-restricted-types -- intentional, API shape
24+
// eslint-disable-next-line @typescript-eslint/no-restricted-types, vibe-proof/react-no-render-function-prop -- intentional public API shape
2525
children: ((items: Array<BreadcrumbItemData<T>>) => React.ReactNode) | React.ReactElement
2626
}
2727

packages/foxact/src/create-fixed-array/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable sukka/no-array-from-length-spread -- this module implements foxact/create-fixed-array */
12
const arrayMap = new Map<number, readonly number[]>();
23

34
function makeArray(length: number) {

packages/foxact/src/create-storage-hook/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ export function createStorage(type: StorageType) {
192192

193193
useLayoutEffect(() => {
194194
if (
195-
getStorageItem(key) === null
196-
&& serverValue !== undefined
195+
serverValue !== undefined
196+
&& getStorageItem(key) === null
197197
) {
198198
setStorageItem(key, serializer(serverValue));
199199
}

packages/foxact/src/current-year/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const CurrentYear = memo(function CurrentYear({ defaultYear, ...restProps
1818
useIsomorphicLayoutEffect(() => {
1919
// This is only allowed because it won't trigger infinite re-render and double render is intentional
2020

21-
// eslint-disable-next-line @eslint-react/set-state-in-effect -- layout effect and only once
21+
// eslint-disable-next-line @eslint-react/set-state-in-effect, vibe-proof/react-no-use-effect-watching -- hydration intentionally updates the SSR fallback once
2222
setYear(new Date().getFullYear());
2323
}, []);
2424

packages/foxact/src/fetch-jsonp/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { invariant } from '../invariant';
2+
13
declare global {
24
interface Window {
35
__foxact_jsonp_callbacks__SECRET_INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: Record<string, ((data: any) => void) | undefined>
@@ -8,9 +10,7 @@ const INTERNAL = '__foxact_jsonp_callbacks__SECRET_INTERNAL_DO_NOT_USE_OR_YOU_WI
810

911
/** @see https://foxact.skk.moe/fetch-jsonp */
1012
export function fetchJsonp<T>(getUrl: (callbackName: string) => string, scriptElOptions?: Partial<HTMLScriptElement>): Promise<T> {
11-
if (typeof window === 'undefined') {
12-
throw new TypeError('fetchJsonp is only available in the browser');
13-
}
13+
invariant(typeof window !== 'undefined', 'fetchJsonp is only available in the browser');
1414

1515
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- initialization
1616
if (!window[INTERNAL]) {

packages/foxact/src/invariant/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/** @see https://foxact.skk.moe/invariant-nullthrow */
22
export function invariant<T>(value: T, message = '[foxact/invariant] "value" is null or undefined'): asserts value is NonNullable<T> {
3+
// eslint-disable-next-line sukka/prefer-nullthrow -- this function defines foxact/invariant
34
if (value === null || value === undefined) {
45
throw new TypeError(message);
56
}

packages/foxact/src/is-safari/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
const RE_SAFARI = /version\/[\d._].*?safari/i;
2+
const RE_MOBILE_SAFARI = /mobile safari [\d._]+/i;
3+
14
export function isSafari() {
25
/* istanbul ignore if -- SSR-only guard, unreachable when Happy DOM registers window globally in tests */
36
if (typeof window === 'undefined') {
@@ -11,11 +14,11 @@ export function isSafari() {
1114
if (typeof navigator.userAgent !== 'string') {
1215
return false;
1316
}
14-
if (/version\/[\d._].*?safari/i.test(navigator.userAgent)) {
17+
if (RE_SAFARI.test(navigator.userAgent)) {
1518
return true;
1619
}
17-
// eslint-disable-next-line sukka/unicorn/prefer-boolean-return -- cleaner code
18-
if (/mobile safari [\d._]+/i.test(navigator.userAgent)) {
20+
21+
if (RE_MOBILE_SAFARI.test(navigator.userAgent)) {
1922
return true;
2023
}
2124
return false;

packages/foxact/src/merge-props/index.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ describe('mergeProps', () => {
115115
});
116116

117117
it('handles non-standard event handlers without error', () => {
118-
for (const eventArgument of [true, 13, 'newValue', { key: 'value' }, ['value'], () => 'value']) {
118+
const eventArguments = [true, 13, 'newValue', { key: 'value' }, ['value'], () => 'value'];
119+
for (let i = 0, len = eventArguments.length; i < len; i++) {
120+
const eventArgument = eventArguments[i];
119121
const log: string[] = [];
120122

121123
const mergedProps = mergeProps<any>(

packages/foxact/src/merge-props/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function mutablyMergeInto<T extends React.ElementType>(
5959
}
6060

6161
const keys = Object.keys(externalProps);
62-
for (let i = 0; i < keys.length; i++) {
62+
for (let i = 0, len = keys.length; i < len; i++) {
6363
const propName = keys[i];
6464
const externalPropValue = (externalProps as Record<string, unknown>)[propName];
6565

0 commit comments

Comments
 (0)