| title | AST Grep and Codemods at Transcend |
|---|---|
| date | 2026-06-30 |
What to do when find and replace isn't enough
| interface Work<Input, Output = any> { | |
| input: Input; | |
| handle: PromiseWithResolvers<Output>; | |
| } | |
| interface Flush<Input> { | |
| (batchedWork: Work<Input>[]): void | Promise<void>; | |
| } | |
| /** |
| #!/usr/bin/env node | |
| import { createHash } from "node:crypto"; | |
| import fs from "node:fs"; | |
| import { glob } from "node:fs/promises"; | |
| import { join } from "node:path"; | |
| import { parseArgs } from "node:util"; | |
| const logger = console; | |
| if (import.meta.main) { |
| // ==UserScript== | |
| // @name GitHub Monospace Font Override | |
| // @namespace http://tampermonkey.net/ | |
| // @version 2025-09-23 | |
| // @description Change the default monospace font used by GitHub | |
| // @author You | |
| // @match https://github.com/* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=github.com | |
| // @grant none | |
| // ==/UserScript== |
| # yaml-language-server: $schema=https://raw.githubusercontent.com/ast-grep/ast-grep/main/schemas/rule.json | |
| id: bad-type-imports | |
| message: Cannot use type keyword within a type import | |
| severity: error | |
| language: TypeScript | |
| rule: | |
| kind: import_specifier | |
| pattern: type $IMPORT | |
| inside: |
| #cloud-config | |
| # Enable automatic package updates and upgrades during cloud-init execution | |
| package_update: true | |
| package_upgrade: true | |
| packages: | |
| # Security and Hardening | |
| - ufw | |
| - fail2ban |
| import { Children, ReactNode, isValidElement, useMemo } from 'react'; | |
| type ShowProps<T> = { | |
| when: T; | |
| fallback?: ReactNode; | |
| children: ReactNode | ((item: NonNullable<T>) => ReactNode); | |
| }; | |
| /** | |
| * Concept borrowed from Solid: https://www.solidjs.com/docs/latest/api#show |
| type HttpStatus = { | |
| // 2xx | |
| 200: 'Ok'; | |
| 201: 'Created'; | |
| 202: 'Accepted'; | |
| 203: 'Non-Authoritative Information'; | |
| 204: 'No Content'; | |
| 205: 'Reset Content'; | |
| // 4xx | |
| 400: 'Bad Request'; |