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 = { | |
create: function (context) { | |
const checkSpreadStatement = (node) => { | |
if (!['ObjectExpression', 'ArrayExpression'].includes(node.type)) { | |
return; | |
} | |
const properties = node.properties || node.elements; | |
properties.forEach((property) => { |
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
// Unility types begin | |
type Split< | |
S extends string, | |
Delimiter extends string | |
> = S extends `${infer Head}${Delimiter}${infer Tail}` | |
? [Head, ...Split<Tail, Delimiter>] | |
: S extends Delimiter | |
? [] | |
: [S]; |
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
#!/bin/bash | |
ssh-keygen -t ed25519 -f ~/.ssh/id_faustienf | |
touch ~/.ssh/config | |
echo " | |
Host faustienf.github.com | |
HostName github.com | |
User faustienf | |
IdentityFile ~/.ssh/id_faustienf |
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 createQueue = () => { | |
let queue = Promise.resolve(); | |
return <T extends () => any>(task: T) => { | |
queue = queue.then(() => task()); | |
}; | |
}; | |
const queue = createQueue(); | |
// example |
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
declare const opaque: unique symbol; | |
type Opaque<T, OpaqueType> = T & { readonly [opaque]: OpaqueType }; | |
// examples | |
type Timestamp = Opaque<number, 'Timestamp'>; | |
const timestamp: Timestamp = Math.random() // Type 'number' is not assignable to type 'Timestamp' |
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
let scrollWidth: null | number = null; | |
export const getScrollWidth = (): number => { | |
if (scrollWidth !== null) { | |
return scrollWidth; | |
} | |
const el = document.createElement('div'); | |
el.style.position = 'fixed'; | |
el.style.zIndex = '-1'; |
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 { | |
createRef, | |
useCallback, | |
useRef, | |
RefObject, | |
} from 'react'; | |
type RefsMap<T> = Partial<Record<string, RefObject<T>>>; | |
type LinkRef<T> = (key: string) => RefObject<T>; |
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
// copy from https://github.com/microsoft/TypeScript/issues/13298#issuecomment-513813788 | |
type Overwrite<T, S extends any> = {[P in keyof T]: S[P]}; | |
type TupleUnshift<T extends any[], X> = T extends any ? ((x: X, ...t: T) => void) extends (...t: infer R) => void ? R : never : never; | |
type TuplePush<T extends any[], X> = T extends any | |
? Overwrite<TupleUnshift<T, any>, T & {[x: string]: X}> | |
: never; |
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 obj = { | |
a: { | |
b: { | |
c: [1, 2, 3] | |
}, | |
d: '', | |
f: true, | |
}, | |
g: { | |
h: 2, |
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
interface CalendarDay { | |
label: number; | |
timestamp: number; | |
isCurrentMonth: boolean; | |
} | |
type CalendarWeek = CalendarDay[]; | |
type Calendar = CalendarWeek[]; | |
/** | |
* @example |
NewerOlder