This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import javascript from "@eslint/js"; | |
| import { defineConfig } from "eslint/config"; | |
| import { FILE_EXTENSION_GLOB_PATTERNS } from "../constants/glob-patterns"; | |
| import { flattenFilesArrays } from "../utilities/flatten-files-arrays"; | |
| export const javascriptConfig = defineConfig({ | |
| extends: [javascript.configs.recommended], | |
| files: flattenFilesArrays( | |
| FILE_EXTENSION_GLOB_PATTERNS.javascript, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { expect, test } from "vitest"; | |
| import { wordWrapString } from "."; | |
| // characterLimitPerLine = -1 / 5.5 | |
| test.each([ | |
| { | |
| stringToWordWrap: "Hello World", | |
| characterLimitPerLine: 20, | |
| expectedWordWrappedString: "Hello World", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { type ChangeEvent, useState } from "react"; | |
| type SelectInputOption<TOptionValue> = { | |
| label: string; | |
| value: TOptionValue; | |
| }; | |
| interface SelectInputProps<TOptionValue> { | |
| options: Array<SelectInputOption<TOptionValue>>; | |
| selectedValue: TOptionValue; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = (results) => { | |
| const byRuleId = results.reduce((map, current) => { | |
| for (const { column, line, ruleId } of current.messages) { | |
| if (!map[ruleId]) { | |
| map[ruleId] = []; | |
| } | |
| const occurrence = `${current.filePath}:${line}:${column}`; | |
| map[ruleId].push(occurrence); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const singleOrDefault = <TElement, TDefaultValue>( | |
| array: ReadonlyArray<TElement>, | |
| predicate: (element: TElement) => boolean, | |
| defaultValue: TDefaultValue | |
| ): TElement | TDefaultValue => { | |
| if (array.length === 0) { | |
| throw new Error("The source sequence is empty."); | |
| } | |
| const element = array.find(predicate); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * https://markheath.net/post/lunchtime-linq-challenge | |
| */ | |
| interface GetSecondsFromMinutesAndSecondsParameters { | |
| minutes: number; | |
| seconds: number; | |
| } | |
| const getSecondsFromMinutesAndSeconds = ({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import type { ReactNode } from "react"; | |
| interface AsynchronousComponentProps<TData> { | |
| children: (data: NonNullable<TData>) => ReactNode; | |
| data: TData; | |
| isLoading: boolean; | |
| loadingFallback: ReactNode; | |
| hasError: boolean; | |
| errorFallback: ReactNode; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useEffect, useState } from "react"; | |
| export const useDebouncedValue = <TValue>(value: TValue, delay: number) => { | |
| const [debouncedValue, setDebouncedValue] = useState(value); | |
| useEffect(() => { | |
| const timeout = setTimeout(() => { | |
| setDebouncedValue(value); | |
| }, delay); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useRef } from "react"; | |
| import { useIntersectionObserver } from "../../hooks/useIntersectionObserver"; | |
| import type { InfiniteScrollProps } from "./types"; | |
| export const InfiniteScroll = ({ | |
| loadMoreFunction, | |
| isLoadingMore, | |
| loadingMoreMessage, | |
| hasLoadedEverything, | |
| loadedEverythingMessage, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { useEffect } from "react"; | |
| import type { UseIntersectionObserverParameters } from "./types"; | |
| export const useIntersectionObserver = ({ | |
| observableRef, | |
| callback, | |
| options, | |
| }: UseIntersectionObserverParameters) => { | |
| useEffect(() => { | |
| const intersectionObserver = new IntersectionObserver( |
NewerOlder