Assess, plan, evolve.
Reusable compiler-aware skills that help coding agents understand, plan, and safely evolve your codebase.
17 packages
# Index Of Codemod ## Introduction This codemod replaces instances of the `index-of` array method with the built-in `indexOf` method. By utilizing native JavaScript features, this transformation reduces dependency on external libraries, improving performance and bundle size. ### Before ```javascript import indexOf from 'index-of'; const items = [1, 2, 3]; const index = indexOf(items, 2); ``` ### After ```javascript const items = [1, 2, 3]; const index = items.indexOf(2); ```
# Last Index Of Codemod ## Introduction This codemod replaces the use of a custom `last-index-of` module with the built-in `Array.prototype.lastIndexOf` method. This transformation simplifies the codebase by removing the dependency on an external module and utilizes a native JavaScript feature for improved performance. ### Before ```javascript import lastIndexOf from 'last-index-of'; const index = lastIndexOf(array, value); ``` ### After ```javascript const index = array.lastIndexOf(value); ```
This codemod updates the API response structure for search calls, replacing the previous body-only return with an object containing additional fields like `statusCode`, `headers`, and `warnings` ## What Changed Previously, the return value of search calls differed based on whether a callback or promise was used: - For promises, only the body was returned. - For callbacks, body, statusCode, and headers were returned separately. Now, both callbacks and promises return an object containing body, statusCode, headers, warnings, and meta. ## Before ```jsx // Promise const body = await client.search({ index: 'my-index', body: { foo: 'bar' } }); // Callback client.search({ index: 'my-index', body: { foo: 'bar' } }, (err, body, statusCode, headers) => { if (err) console.log(err); }); ``` ## After ```jsx // Promise const { body, statusCode, headers, warnings } = await client.search({ index: 'my-index', body: { foo: 'bar' } }); // Callback client.search({ index: 'my-index', body: { foo: 'bar' } }, (err, { body, statusCode, headers, warnings }) => { if (err) console.log(err); }); ```
This codemod moves the client-related configuration parameters (ignore, headers, requestTimeout, and maxRetries) from the API object to the second options object. ## What Changed Previously, ignore, headers, requestTimeout, and maxRetries could be passed directly inside the API object. Now, these parameters need to be specified in a second options object. Now, both callbacks and promises return an object containing body, statusCode, headers, warnings, and meta. ## Before ```jsx const body = await client.search({ index: 'my-index', body: { foo: 'bar' }, ignore: [404] }); client.search({ index: 'my-index', body: { foo: 'bar' }, ignore: [404] }, (err, body, statusCode, headers) => { if (err) console.log(err); }); ``` ## After ```jsx const { body, statusCode, headers, warnings } = await client.search({ index: 'my-index', body: { foo: 'bar' } }, { ignore: [404] }); client.search({ index: 'my-index', body: { foo: 'bar' } }, { ignore: [404] }, (err, { body, statusCode, headers, warnings }) => { if (err) console.log(err); }); ```
Detect possible missing-index risks in Prisma queries and embedded SQL
Example of using codemod that changes SQL. It detects all SELECT statements and adds an index creation statement before them. Inside SELECT statement for any fields that ends with `_id` it creates an index on that field. ## Example ### Before ```sql select * FROM orders WHERE customer_id = 123; ``` ### After ```ts CREATE INDEX idx_customer_id ON orders(customer_id); SELECT * FROM orders WHERE customer_id = 123; ```
Migrate transform index HTML hooks
# Array.prototype.indexOf Codemod ## Introduction This codemod transforms calls to `array.prototype.indexof` (with a lowercase "o") to the built-in `indexOf` method of arrays. This replacement reduces reliance on error-prone custom implementations and leverages the native functionality, improving code performance and readability. ### Before ```javascript const index = array.prototype.indexof(array, value); ``` ### After ```javascript const index = array.indexOf(value); ```
# array.prototype.findindex Codemod ## Introduction This codemod replaces instances of `array.prototype.findindex` with the built-in `Array.prototype.findIndex` method. By making this change, we eliminate the need for an external dependency, which helps reduce bundle size and improves performance. ### Before ```javascript const index = array.prototype.findindex(array, element); ``` ### After ```javascript const index = array.findIndex(element); ```
# Array Prototype Find Last Index Codemod ## Introduction This codemod transforms the usage of the `Array.prototype.findLastIndex` method to its more efficient counterpart, ensuring consistent coding practices and potentially reducing bundle size by leveraging built-in ES features instead of polyfills or outdated methods. ### Before ```javascript const array = [1, 2, 3, 4, 5]; const lastIndex = array.findLastIndex(element => element === 3); ``` ### After ```javascript const array = [1, 2, 3, 4, 5]; const lastIndex = array.findLastIndex(element => element === 3); ```
Read-only C# analysis codemod that detects IndexOf-style comparisons such as > 0 or >= 1, which exclude valid index-0 matches, and emits provider-neutral findings plus metrics for remediation planning.
# Split Lines Codemod ## Introduction This codemod replaces the usage of the `split-lines` npm module with native JavaScript string methods. The goal is to eliminate an unnecessary dependency, optimize the codebase, and enhance performance by utilizing built-in ES features. ### Before ```javascript import splitLines from 'split-lines'; const lines = splitLines(someString, { preserveNewlines: true }); ``` ### After ```javascript const lines = someString.split(/(\r?\n)/).reduce((acc, part, index, array) => { if (index % 2 === 0) { acc.push(part + (array[index + 1] || '')); } return acc; }, []); ```
Ready to evolve your codebase?
Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.