Assess, plan, evolve.
Reusable compiler-aware skills that help coding agents understand, plan, and safely evolve your codebase.
43 packages
This is a [codemod](https://codemod.com) created with [```codemod init```](https://docs.codemod.com/deploying-codemods/cli#codemod-init). ## Using this codemod You can run this codemod with the following command: ```bash npx codemod json-breather ``` ### Before ```ts const toReplace = "hello"; ``` ### After ```ts const replacement = "hello"; ```
This custom codemod replaces `JSONResponse` with `ORJSONResponse`to bring consistency to the way we handle JSON responses in our codebase. Besides updating the response class, it also updates the imports to use `from src.json_encoding import ORJSONResponse`.
- python
This codemod helps developers migrate their deno.json configuration files to the new flattened schema format, making them easier to read and write. It automates the transformation of nested properties to their new top-level structure as outlined in recent Deno updates. ### Before ```json { "lint": { "files": { "exclude": ["gen.ts"] } }, "fmt": { "options": { "lineWidth": 80, "useTabs": false } } } ``` ### After ```json { "lint": { "exclude": ["gen.ts"] }, "fmt": { "lineWidth": 80, "useTabs": false } } ``` The codemod handles the following transformations on the config file | Before | After | | ------------------------- | ----------------- | | `bench.files.include` | `bench.include` | | `bench.files.exclude` | `bench.exclude` | | `fmt.files.include` | `fmt.include` | | `fmt.files.exclude` | `fmt.exclude` | | `fmt.options.useTabs` | `fmt.useTabs` | | `fmt.options.lineWidth` | `fmt.lineWidth` | | `fmt.options.indentWidth` | `fmt.indentWidth` | | `fmt.options.singleQuote` | `fmt.singleQuote` | | `fmt.options.proseWrap` | `fmt.proseWrap` | | `fmt.options.semiColons` | `fmt.semiColons` | | `lint.files.include` | `lint.include` | | `lint.files.exclude` | `lint.exclude` | | `test.files.include` | `test.include` | | `test.files.exclude` | `test.exclude` |
- deprecation
- configuration
- +2
This codemod addresses changes mentioned in [Prisma's official upgrade guide](https://www.prisma.io/docs/orm/more/upgrade-guides/upgrading-versions/upgrading-to-prisma-5/jsonprotocol-changes) related to Json Protocol changes. ## Note: There are known FNs for this codemod when in any occassion you pass an identifier (variable) that is not an array into prisma client invocations where it expects an array. This is due to the fact that the codemod is not able to infer the type of the identifier. In such cases, you will have to manually update the code. The codemod will still work for most of the cases when such calls are made with literals.
- migration
- prisma
In JSON files, for tokens of the type 'color' (not other tokens), transform $value into an object with a 'hex' key, where the value remains the same as the previous $value ### Before ```json { "interactive": { "100": { "$value": "<some string>", "$type": "color" } }, "someOtherColorToken": { "$value": "#DBF0FF", "$type": "color" } } ``` ### After ```json { "interactive": { "100": { "$value": { "hex": "<some string>" }, "$type": "color" } }, "someOtherColorToken": { "$value": { "hex": "#DBF0FF" }, "$type": "color" } } ```
- design tokens
This codemod replaces configuration files for ESLint with corresponding biome.json for all the found rules. It also replaces Prettier configuration. ## Note: This codemod accepts manual user input, which is required to migrate away from eslint. In order to run it properly, run the following command: ```bash npx eslint --print-config <path-to-a-file-that-eslint-checks> | codemod eslint/biome/migrate-rules ``` It's important that you pass these rules to the codemod, because our codemods are limited in access for security purposes and have no access to most node features that could maliciously affect your system. This codemod requires internet connection. ## Example ### `package.json` ### Before ```json { "name": "package-name", "dependencies": { "prettier": "^3.1.0", "prettier-plugin-tailwindcss": "^0.5.4", "@tanstack/eslint-plugin-query": "^4.29.25", "@someorg/prettier-config": "^1.1.1" }, "devDependencies": { "eslint-plugin-airbnb": "^10.2.0", "eslint": "^10.2.0", "eslint-plugin-prettier": "^10.2.0", "eslint-config-prettier": "^10.2.0" }, "main": "./dist/index.cjs", "scripts": { "start": "pnpm run build:cjs && node ./dist/index.cjs", "lint:eslint": "eslint . --fix", "lint:prettier": "prettier --write ." }, "eslintIgnore": ["ignore-key"], "files": [ "prettier-test-no-replace", "README.md", ".codemodrc.json", "./dist/index.cjs" ], "lint-staged": { "*.js": "eslint --fix", "*.ts": "eslint --fix" }, "type": "module" } ``` ### After ```json { "name": "package-name", "dependencies": {}, "devDependencies": { "@biomejs/biome": "1.5.3" }, "main": "./dist/index.cjs", "scripts": { "start": "pnpm run build:cjs && node ./dist/index.cjs", "lint:eslint": "pnpm dlx @biomejs/biome lint . --apply", "lint:prettier": "pnpm dlx @biomejs/biome format --write .", "NOTE": "You can apply both linter, formatter and import ordering by using https://biomejs.dev/reference/cli/#biome-check", "NOTE2": "There is an ongoing work to release prettier-tailwind-plugin alternative: https://biomejs.dev/linter/rules/use-sorted-classes/, https://github.com/biomejs/biome/issues/1274" }, "files": [ "prettier-test-no-replace", "README.md", ".codemodrc.json", "./dist/index.cjs" ], "lint-staged": { "*.js": "pnpm dlx @biomejs/biome lint --apply", "*.ts": "pnpm dlx @biomejs/biome lint --apply" }, "type": "module" } ``` ### `.eslintrc.json` ### Before ```json { "rules": [...] } ``` ### After `Removed and replaced with corresponding rules in biome.json` ### `.prettierrc` ### Before ```json { "printWidth": 80 } ``` ### After `Removed and replaced with corresponding values in biome.json` ### `biome.json` ```json { "linter": { "ignore": [ "ignore-key", "dist", "build", "pnpm-lock.yaml", "node_modules" ], "rules": { "suspicious": { "noDoubleEquals": "warn", "noAssignInExpressions": "warn" }, "correctness": { "noUnusedVariables": "off" } } }, "formatter": { "ignore": [], "indentStyle": "tab" } } ```
- migration
- eslint
Run this codemod to upgrade configuration files that need to be changed after migrating from `mocha` to `vitest`. ## Example ### `package.json` ### Before ```json { "name": "package-name", "dependencies": { "mocha": "^10.2.0", "some-mocha-plugin": "^10.0.4" }, "devDependencies": { "mocha": "^10.2.0", "@types/mocha": "^10.0.4" }, "main": "./dist/index.cjs", "scripts": { "test": "mocha" }, "mocha": { "config-key": "config-value" }, "files": ["README.md", ".codemodrc.json", "./dist/index.cjs"], "type": "module" } ``` ### After ```json { "name": "package-name", "dependencies": {}, "devDependencies": { "vitest": "^1.0.1", "@vitest/coverage-v8": "^1.0.1" }, "main": "./dist/index.cjs", "scripts": { "test": "vitest run", "coverage": "vitest run --coverage" }, "files": ["README.md", ".codemodrc.json", "./dist/index.cjs"], "type": "module" } ``` ### `tsconfig.json` ### Before ```json { "compilerOptions": { "types": ["mocha"] }, "include": [ "./src/**/*.ts", "./src/**/*.js", "./test/**/*.ts", "./test/**/*.js" ] } ``` ### After ```json { "compilerOptions": {}, "include": [ "./src/**/*.ts", "./src/**/*.js", "./test/**/*.ts", "./test/**/*.js" ] } ``` ### `.mocharc` ### Before ```json { "loader": ["ts-node/esm"], "full-trace": true, "failZero": false, "bail": true, "spec": "./**/test.ts", "timeout": 5000 } ``` ### After `Removed`
- migration
This codemod does tranformation based on changes in the utils in ethers.js ## Example Byte32 string helpers ### Before ```ts bytes32 = ethers.utils.formatBytes32String(text); text = ethers.utils.parseBytes32String(bytes32); ``` ### After ```ts bytes32 = ethers.encodeBytes32String(text); text = ethers.decodeBytes32String(bytes32); ``` Constants ### Before ```ts ethers.constants.AddressZero; ethers.constants.HashZero; ``` ### After ```ts ethers.ZeroAddress; ethers.ZeroHash; ``` Data Manipulation ### Before ```ts slice = ethers.utils.hexDataSlice(value, start, end); padded = ethers.utils.hexZeroPad(value, length); hex = hexlify(35); ``` ### After ```ts slice = ethers.dataSlice(value, start, end); padded = ethers.zeroPadValue(value, length); // v6; converting numbers to hexstrings hex = toBeHex(35); ``` Deafult AbiCoder ### Before ```ts // In v5, it is a property of AbiCoder coder = AbiCoder.defaultAbiCoder; ``` ### After ```ts // In v6, it is a static function on AbiCoder coder = AbiCoder.defaultAbiCoder(); ``` Hex Conversion ### Before ```ts hex = ethers.utils.hexValue(value); array = ethers.utils.arrayify(value); ``` ### After ```ts hex = ethers.toQuantity(value); array = ethers.getBytes(value); ``` Solidity non-standard packed ### Before ```ts ethers.utils.solidityPack(types, values); ethers.utils.solidityKeccak256(types, values); ethers.utils.soliditySha256(types, values); ``` ### After ```ts ethers.solidityPacked(types, values); ethers.solidityPackedKeccak256(types, values); ethers.solidityPackedSha256(types, values); ``` Property Manipulation ### Before ```ts ethers.utils.defineReadOnly(obj, "name", value); ``` ### After ```ts ethers.defineProperties(obj, { name: value }); ``` Above were some transformation, that were done in utilities section of ethers, now below are some cleanups and breaking changes. PS: These changes are not done using codemod. **Fetching content** Basic Fetch with Json ### Before ```ts data = await ethers.utils.fetchJson(url, json, processFunc); ``` ### After ```ts const req = new ethers.FetchRequest(url); req.body = json; req.processFunc = processFunc; const resp = await req.send(); data = resp.bodyJson; // or resp.bodyText / resp.body depending on the desired format ``` Fetch with Connection Overrides: ### Before ```ts req = { url: url, user: "username", password: "password", // etc. properties have FetchRequest equivalents }; data = await ethers.utils.fetchJson(req, json, processFunc); ``` ### After ```ts const req = new ethers.FetchRequest(url); req.setCredentials("username", "password"); req.body = json; req.processFunc = processFunc; const resp = await req.send(); data = resp.bodyJson; // or resp.bodyText / resp.body depending on the desired format ```
- ethers.js
- migration
This codemod is designed to help you migrate your existing codebase from using the native `fetch` API to the more concise and convenient `ky` HTTP client library. By running this codemod, you can automatically update your code to leverage `ky`'s features, such as simpler syntax for common use cases like JSON requests and responses. ## Detailed Description The codemod performs the following transformations: - Replaces `fetch` calls with `ky` methods (`ky.get`, `ky.post`, `ky.put`, `ky.delete`). - Simplifies request setup by using `ky`'s built-in methods for JSON handling (`.json()`). - Removes manual error checking (`!resp.ok`), as `ky` automatically throws errors for non-2xx responses. - Streamlines the code by reducing boilerplate and improving readability. ## Example ### Before ```ts export async function getTodos() { const resp = await fetch(`/todos`); if (!resp.ok) throw resp; return resp.json(); } export async function addTodo(todo) { const resp = await fetch(`/todo`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ todo }), }); if (!resp.ok) throw resp; return resp.json(); } export async function updateTodo(todo) { const resp = await fetch(`/todo/${todo.id}`, { method: 'PUT', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ todo }), }); if (!resp.ok) throw resp; } export async function deleteTodo(todoId) { const resp = await fetch(`/todo/${todoId}`, { method: 'DELETE', }); if (!resp.ok) throw resp; } ``` ### After ```ts import ky from 'ky'; export async function getTodos() { const resp = await ky.get(`/todos`); return resp.json(); } export async function addTodo(todo) { const resp = await ky.post(`/todo`, { json: { todo }, }); return resp.json(); } export async function updateTodo(todo) { const resp = await ky.put(`/todo/${todo.id}`, { json: { todo }, }); } export async function deleteTodo(todoId) { const resp = await ky.delete(`/todo/${todoId}`); } ``` This codemod streamlines your existing fetch functions by converting them to use `ky`, eliminating unnecessary code, and making your HTTP requests more readable and maintainable.
- fetch-to-ky
This codemod migrates imports from JSON modules that use named exports to use default exports instead. This codemod transforms named imports from JSON files into default imports, adhering to the new ECMAScript specification and Webpack v5 compatibility. Named imports from JSON modules are no longer supported. ## Example ### Before ```ts import { version } from "./package.json"; console.log(version); ``` ### After ```ts import pkg from "./package.json"; console.log(pkg.version); ``` , ### Before ```ts import { version, name, description } from "./package.json"; console.log(version, name, description); ``` ### After ```ts import pkg from "./package.json"; console.log(pkg.version, pkg.name, pkg.description); ``` , ### Before ```ts import { data } from './config.json'; console.log(data.nested.key, data.anotherKey); ``` ### After ```ts import config from './config.json'; console.log(config.data.nested.key, config.data.anotherKey); ``` , ### Before ```ts import { key1, key2 } from './config.json'; console.log(key1, key2); ``` ### After ```ts import config from './config.json'; console.log(config.key1, config.key2); ```
- webpack
- migration
- +1
This is a [codemod](https://codemod.com) created with [`codemod init`](https://docs.codemod.com/deploying-codemods/cli#codemod-init). ## Using this codemod You can run this codemod with the following command: ```bash npx codemod vercel-postgres-to-neon ``` ### Before ```ts import { sql } from '@vercel/postgres'; import { NextApiRequest, NextApiResponse } from 'next'; export default async function handler( request: NextApiRequest, response: NextApiResponse, ) { try { await sql`CREATE TABLE Pets ( Name varchar(255), Owner varchar(255) );`; const names = ['Fiona', 'Lucy']; await sql`INSERT INTO Pets (Name, Owner) VALUES (${names[0]}, ${names[1]});`; } catch (error) { return response.status(500).json({ error }); } const pets = await sql`SELECT * FROM Pets;`; return response.status(200).json({ pets }); } ``` ### After ```ts import { neon } from '@neondatabase/serverless'; import { NextApiRequest, NextApiResponse } from 'next'; const sql = neon(process.env.POSTGRES_URL); export default async function handler( request: NextApiRequest, response: NextApiResponse, ) { try { await sql`CREATE TABLE Pets ( Name varchar(255), Owner varchar(255) );`; const names = ['Fiona', 'Lucy']; await sql`INSERT INTO Pets (Name, Owner) VALUES (${names[0]}, ${names[1]});`; } catch (error) { return response.status(500).json({ error }); } const pets = await sql`SELECT * FROM Pets;`; return response.status(200).json({ pets }); } ```
- vercel
- vercel-postgres
This codemod copies specific keys from one translation namespace to another, for each of the supported languages. The codemod expects the following arguments: - `oldNamespace` is the name of the namespace from which the keys are taken, - `newNamespace` is the name of the namespace to which the keys are copied, - `keys` is a comma-separated list of keys. You need to pass these arguments using the [Codemod Arguments' settings](https://docs.codemod.com/docs/vs-code-extension/advanced-usage#set-codemod-arguments) in Codemod VSCode extension or [Codemod CLI](https://docs.codemod.com/docs/cli/quickstart). ## Before ### .../en/common.json ```json { "copyKey": "copyKeyEnglish", "noopKey": "noopKeyEnglish" } ``` ### .../en/new.json ```json { "existingKey": "existingKeyEnglish" } ``` ## After ### .../en/common.json ```json { "copyKey": "copyKeyEnglish", "noopKey": "noopKeyEnglish" } ``` ### .../en/new.json ```json { "existingKey": "existingKeyEnglish", "copyKey": "copyKeyEnglish" } ```
- migration
Ready to evolve your codebase?
Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.