This file contains 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 * as fs from 'fs'; | |
import * as glob from 'glob'; | |
import { parse } from '@babel/parser'; | |
import traverse from '@babel/traverse'; | |
export const isExpectErrorComment = (comment: string): boolean => | |
comment.trim().startsWith('@ts-expect-error TS('); | |
let totalAnyKeywords = 0; | |
let totalExpectErrorDirectives = 0; |
This file contains 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
<Card variant="callout"> | |
<Stack spacing="large"> | |
<Heading variant="small" as="h2"> | |
This is a Card | |
</Heading> | |
<Text>Cards are ways...</Text> | |
<Button variant="primary" as="button"> | |
Got it | |
</Button> | |
</Stack> |
This file contains 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 HIGHLIGHT_WIDTH = 2; | |
const HIGHLIGHT_SELECTOR = '[data-component]'; | |
function createHighlighterForElement(component: HTMLElement) { | |
const highlighter = document.createElement('div'); | |
const { x, y, width, height } = component.getBoundingClientRect(); | |
highlighter.style.cssText = ` | |
top: ${y + window.scrollY - HIGHLIGHT_WIDTH}px; | |
left: ${x - HIGHLIGHT_WIDTH}px; |
This file contains 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
def current_branch | |
`git rev-parse --abbrev-ref HEAD`.strip | |
end |
This file contains 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 { Action, calculateActions, arrayContentsEqual } from './actions'; | |
export const useActions = (): Action[] => { | |
const [actions, setActions] = React.useState(calculateActions()); | |
React.useEffect(() => { | |
function callback() { | |
const newActions = calculateActions(); | |
if (!arrayContentsEqual(newActions, actions)) { | |
setActions(newActions); |
This file contains 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
// actions/index.ts | |
import * as name from './actions/name'; | |
// other action imports ... | |
export interface Action { | |
name: string; | |
canPerform(): boolean; | |
perform(): void; | |
} |
This file contains 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
// actions/name.ts | |
import { screen } from '@testing-library/react'; | |
import userEvent from '@testing-library/user-event'; | |
export function canPerform() { | |
try { | |
return !!screen.getByLabelText(/first name/i) && !!screen.getByLabelText(/last name/i); | |
} catch (error) { | |
return false; | |
} |
This file contains 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 React from 'react'; | |
import ReactDOM from "react-dom"; | |
function DevTools() { | |
return <div>You now have your own DevTools!</div>; | |
} | |
export function install() { | |
const devToolsRoot = document.createElement("div"); | |
document.body.appendChild(devToolsRoot); |
This file contains 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
function loadDevtools() { | |
if (process.env.NODE_ENV === 'development') { | |
return import('dev_tools').then((devTools) => devTools.install()); | |
} | |
} |