Skip to content

Instantly share code, notes, and snippets.

View fwouts's full-sized avatar

Francois Wouts fwouts

View GitHub Profile
@fwouts
fwouts / react-factories-to-jsx-codemod.ts
Last active June 5, 2025 06:45
A codemod (to use with jscodeshift) to automatically replace React factory calls with JSX.
import jscodeshift from 'jscodeshift';
const codemod: jscodeshift.Transform = (fileInfo, api) => {
const j = api.jscodeshift;
const root = j(fileInfo.source);
root.find(j.VariableDeclaration).forEach((path) => {
const extracted = extractComponentNameFromReactFactoryCall(path.node);
if (extracted) {
let total = 0;
let replaced = 0;
@fwouts
fwouts / CLA.md
Created June 12, 2018 05:49 — forked from pjcozzi/CLA.md
CLA for MIT license

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I have the right to submit it under the MIT license; or

(b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the MIT license; or

@fwouts
fwouts / fasy.d.ts
Created November 8, 2017 22:52
Fasy TypeScript definitions
/*! fasy.js
v5.0.3 (c) 2017 Kyle Simpson
MIT License: http://getify.mit-license.org
*/
export declare type PotentialPromise<T> = T | Promise<T>;
export declare type EachFn<I> = (value: I, idx: number, arr: I[]) => PotentialPromise<any>;
export declare type MapperFn<I, O> = (value: I, idx: number, arr: I[]) => PotentialPromise<O>;
export declare type PredicateFn<I> = (value: I, idx: number, arr: I[]) => PotentialPromise<any>;
export declare type CombinationFn<I, O> = (acc: I, v: I) => PotentialPromise<O>;
@fwouts
fwouts / script.js
Last active August 26, 2017 23:47
JS script that rewrites itself
import * as fs from "fs";
import * as ts from "typescript";
let sourceCode = fs.readFileSync(__filename, "utf8");
let tsSourceFile = ts.createSourceFile(
__filename,
sourceCode,
ts.ScriptTarget.Latest
);
for (let statement of tsSourceFile.statements) {