repo stringlengths 7 64 | file_url stringlengths 81 338 | file_path stringlengths 5 257 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:25:31 2026-01-05 01:50:38 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/jsxChildrenWhitespace2.ts | test/findReplace/jsxChildrenWhitespace2.ts | export const input = `
const a = (
<div>
foo bar
{bar}
baz
{qux}
</div>
)
const b = <div> foo bar {bar} </div>
const c = <div>foo bar{bar}</div>
`
export const find = `
<div>foo bar{$$c}</div>
`
export const expectedFind = [
{
arrayCaptures: {
$$c: ['{bar}', '\n baz\n ', '{qu... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/backreference.ts | test/findReplace/backreference.ts | export const input = `
foo(1, 1, {foo: 1}, {foo: 1})
foo(1, 2, {foo: 1}, {foo: 1})
foo(1, 1, {foo: 1}, {bar: 1})
`
export const find = `foo($a, $a, $b, $b)`
export const expectedFind = [
{
node: 'foo(1, 1, {foo: 1}, {foo: 1})',
captures: { $a: '1', $b: '{foo: 1}' },
},
]
import { findReplaceTestcase } fro... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/arrayAndObjectPattern.ts | test/findReplace/arrayAndObjectPattern.ts | export const input = `
const [a, b, {c, d: [e], h}, f] = foo
`
export const find = `const [a, $$b, {c, $$d}, $$e] = $f`
export const expectedFind = [
{
node: `const [a, b, {c, d: [e], h}, f] = foo`,
arrayCaptures: {
$$b: ['b'],
$$d: ['d: [e]', 'h'],
$$e: ['f'],
},
captures: {
... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/missingCaptureReplacement.ts | test/findReplace/missingCaptureReplacement.ts | export const input = `
const a = 1 + foo(2, 3, 4)
`
export const find = `
$a + foo(2, $$b)
`
export const replace = `
foo($$b, $$c) + $a + $c
`
export const expectedReplace = `
const a = foo(3, 4, $$c) + 1 + $c
`
import { findReplaceTestcase } from '../findReplaceTestcase'
findReplaceTestcase({
file: __filename,
... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/arrayMatchingDefaultOrderedMatch.ts | test/findReplace/arrayMatchingDefaultOrderedMatch.ts | export const input = `
[1, 2, 3, 4, 5]
`
export const find = `[1, 2, 3, 4, 5]`
export const expectedFind = [
{
node: '[1, 2, 3, 4, 5]',
},
]
import { findReplaceTestcase } from '../findReplaceTestcase'
findReplaceTestcase({
file: __filename,
input,
find,
expectedFind,
})
| typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/typeAnnotationCapture.ts | test/findReplace/typeAnnotationCapture.ts | export const input = `
export type F = (strings: string[]) => Node | Node[]
`
export const find = `
type X = /**/ $T
`
export const expectedFind = [
{
captures: {
$T: '(strings: string[]) => Node | Node[]',
},
node: '(strings: string[]) => Node | Node[]',
},
{
captures: {
$T: 'string... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/intersectionType.ts | test/findReplace/intersectionType.ts | export const input = `
type A = B & C & D[] & E[] & F
type B = B & C & D[] & E & F
`
export const find = `type $a = $$b & $c[] & F`
export const expectedFind = [
{
node: `type A = B & C & D[] & E[] & F`,
captures: { $a: 'A', $c: 'E' },
arrayCaptures: { $$b: ['B', 'C', 'D[]'] },
},
]
export const repl... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/findPromiseMethodCalls.ts | test/findReplace/findPromiseMethodCalls.ts | export const input = `
function foo(thing) {
thing.then(() => blah).finally(() => done)
return thing.then(
value => value * 2,
error => logged(error)
).catch(error => blah)
}
`
export const find = `
$Or($a.then($handleValue), $a.then($handleValue, $handleError), $a.catch($handleError), $a.finally($handle... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/arrayMatchingForceUnorderedExtraneous.ts | test/findReplace/arrayMatchingForceUnorderedExtraneous.ts | export const input = `
[1, 2, 3, 4, 5]
`
export const find = `[$Unordered, 1, 2, 3, 5, 4, 6]`
export const expectedFind = []
import { findReplaceTestcase } from '../findReplaceTestcase'
findReplaceTestcase({
file: __filename,
input,
find,
expectedFind,
})
| typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/mixedRestAndArrayCapturesError.ts | test/findReplace/mixedRestAndArrayCapturesError.ts | export const input = `
[1, 2, 3]
`
export const find = `
[$$a, $$$b]
`
export const expectedError = `can't mix array and rest matchers`
import { findReplaceTestcase } from '../findReplaceTestcase'
findReplaceTestcase({
file: __filename,
input,
find,
expectedError,
})
| typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/bugs_replaceTSTypeParameterWithExtends.ts | test/findReplace/bugs_replaceTSTypeParameterWithExtends.ts | import { findReplaceTestcase } from '../findReplaceTestcase'
import dedent from 'dedent-js'
findReplaceTestcase({
file: __filename,
parsers: ['babel/tsx', 'recast/babel/tsx'],
input: dedent`
function useDebounce<F extends any>() { }
`,
find: dedent`
type X</**/ $T extends any> = any
`,
replace: d... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/arrayValueToTypeSpread.ts | test/findReplace/arrayValueToTypeSpread.ts | export const parsers = ['babel/tsx', 'recast/babel/tsx']
export const input = `
const X = [...Y, Z]
`
export const find = `
const $A = [...$B, $$C]
`
export const replace = `
type $A = [...$B, $$C]
`
export const expectedReplace = `
type X = [...Y, Z]
`
import { findReplaceTestcase } from '../findReplaceTestcase'
... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/objectType.ts | test/findReplace/objectType.ts | export const input = `
type Foo = { a: number, b: string, c: [number, string], d: any, $e: any, 'hello-world': any }
`
export const find = `
type $1 = { $$a: $, c: [number, $$b], $d: $, $_e: any, 'hello-world': any }
`
export const expectedFind = [
{
node: `type Foo = { a: number, b: string, c: [number, string],... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/tsFunctionParamTypes.ts | test/findReplace/tsFunctionParamTypes.ts | export const parsers = ['babel/tsx', 'recast/babel/tsx']
export const input = `
type Foo = (a: number, b: string, c: [number, string], d: any, $e) => any
`
export const find = `
type $1 = ($$a, c: [number, $$b], $d, $_e) => any
`
export const expectedFind = [
{
node: `type Foo = (a: number, b: string, c: [numb... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/jsxChildCapture.ts | test/findReplace/jsxChildCapture.ts | export const input = `
<A b>c {d}</A>
(<>e {f}</>)
h
i.j
k()
`
export const find = `
(<A>{/**/}{$a}</A>)
`
export const expectedFind = ['c ', '{d}', 'e ', '{f}'].map((node) => ({
node,
captures: { $a: node },
}))
import { findReplaceTestcase } from '../findReplaceTestcase'
findReplaceTestcase({
file: __filenam... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/importSpecifiersDefaultUnorderedExtraneous.ts | test/findReplace/importSpecifiersDefaultUnorderedExtraneous.ts | export const input = `
import A, {B, C, D, E, F} from 'foo'
`
export const find = `import A, {E, C, D, B} from 'foo'`
export const expectedFind = []
import { findReplaceTestcase } from '../findReplaceTestcase'
findReplaceTestcase({
file: __filename,
input,
find,
expectedFind,
})
| typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/requiredVariableDeclaratorInit.ts | test/findReplace/requiredVariableDeclaratorInit.ts | export const input = `
let foo
let bar = 1
`
export const find = `
let $a = $b
`
export const expectedFind = [
{
captures: {
$a: 'bar',
$b: '1',
},
node: 'let bar = 1',
},
]
import { findReplaceTestcase } from '../findReplaceTestcase'
findReplaceTestcase({
file: __filename,
input,
f... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/statementsQuery.ts | test/findReplace/statementsQuery.ts | export const input = `
const a = 1
const b = a + 3
const c = 5
function foo() {
const c = 5
const d = 6
const e = c + 4
}
const f = 1
const g = f + 3
`
export const find = `
const $a = $b
$$c
const $d = $a + $e
`
export const expectedFind = [
{
nodes: ['const c = 5', 'const d = 6', 'const e = c + 4'],
... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/convertDestructuredRequiresToImports.ts | test/findReplace/convertDestructuredRequiresToImports.ts | export const input = `
const foo = require('foo')
const bar = require('bar')
const baz = require('baz' + 'qux')
const {glom, qlx} = require('foo')
const {bar: barr, default: qux} = require('bar')
`
export const find = `const $1 = require('$a')`
export const expectedFind = [
{
node: "const foo = require('foo')",
... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/stringLiteralMatchesBacktickString.ts | test/findReplace/stringLiteralMatchesBacktickString.ts | import { findReplaceTestcase } from '../findReplaceTestcase'
import dedent from 'dedent-js'
findReplaceTestcase({
file: __filename,
input: dedent`
'foo'
\`foo\`
\`foo\${a}\`
\`bar\`
`,
find: dedent`
'foo'
`,
expectedFind: [{ node: "'foo'" }, { node: '`foo`' }],
})
| typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/optionalObjectPropertyAssignmentPattern.ts | test/findReplace/optionalObjectPropertyAssignmentPattern.ts | export const input = `
let foo
let {bar = 2} = foo
let {baz} = foo
`
export const find = `
let /**/ {$a = $Maybe($b)} = $c
`
export const expectedFind: ExpectedMatch[] = [
{
captures: { $a: 'bar', $b: '2', $c: 'foo' },
node: '{bar = 2} = foo',
},
{
captures: { $a: 'baz', $c: 'foo' },
node: '{baz... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/multipleRestCapturesError.ts | test/findReplace/multipleRestCapturesError.ts | export const input = `
[1, 2, 3]
`
export const find = `
[$$$a, $$$b]
`
export const expectedError = `can't have two or more rest matchers as siblings`
import { findReplaceTestcase } from '../findReplaceTestcase'
findReplaceTestcase({
file: __filename,
input,
find,
expectedError,
})
| typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/stringLiteral.ts | test/findReplace/stringLiteral.ts | export const input = `
const foo = 'bar'
`
export const find = `'bar'`
export const expectedFind = [{ node: `'bar'` }]
import { findReplaceTestcase } from '../findReplaceTestcase'
findReplaceTestcase({
file: __filename,
input,
find,
expectedFind,
})
| typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/functionArgs.ts | test/findReplace/functionArgs.ts | export const input = `
function foo(w, x, y, z) {}
function bar(a, b, c) {}
`
export const find = `function foo($a, $$b, z) {}`
export const expectedFind = [
{
node: 'function foo(w, x, y, z) {}',
captures: {
$a: 'w',
},
arrayCaptures: {
$$b: ['x', 'y'],
},
},
]
import { findReplac... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/bugs_schema-ts.ts | test/findReplace/bugs_schema-ts.ts | export const input = `
import * as Generic from '~/lib/sdk-spec/generic-sdk-wrappers';
import { SetNonNullable } from '~/lib/_util';
import { JavaBundle } from './bundle';
import { SDKMethod } from './method';
import { SDKModel } from './model';
import { SDKResource } from './resource';
export type SDKSchema =
| SDK... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/importDefaultReplacement.ts | test/findReplace/importDefaultReplacement.ts | export const input = `
import foo from 'foo'
`
export const find = `
import $x from '$y'
`
export const replace = `
import $x from 'y'
`
export const expectedReplace = `
import foo from 'y'
`
import { findReplaceTestcase } from '../findReplaceTestcase'
findReplaceTestcase({
file: __filename,
input,
find,
re... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/statementsOrder.ts | test/findReplace/statementsOrder.ts | export const input = `
const a = 1
const b = a + 3
const f = 1
function foo() {
const c = 5
const d = 6
const e = c + 4
}
const g = f + 3
`
export const find = `
const $a = $b
$$c
const $d = $a + $e
`
export const expectedFind = [
{
arrayCaptures: {
$$c: ['const d = 6'],
},
captures: {
... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/classPropertyCapture.ts | test/findReplace/classPropertyCapture.ts | export const input = `
class A {
a: number
constructor() {}
get foo() {}
}
interface B {
b: number
}
type C = {
b: number,
}
`
export const find = `
class X {
/**/ $a
}
`
export const expectedFind = [
'a: number',
'constructor() {}',
'get foo() {}',
].map((node) => ({
node,
captures: { $a: nod... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/bugs_arraySpread.ts | test/findReplace/bugs_arraySpread.ts | export const input = `
Dots(
OrgPackage({
subPackage: [
'services',
async ? 'async' : 'blocking',
...namespace,
Names.ServiceType({ resource, async }),
],
}),
)
`
export const find = `
OrgPackage({subPackage: [$$p]})
`
export const replace = `
[...OrgPackage(), $$p]
`
export const... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/optionalVariableDeclaratorInit.ts | test/findReplace/optionalVariableDeclaratorInit.ts | export const input = `
let foo
let bar = 2
`
export const find = `
let $a = $Maybe($b)
`
export const expectedFind: ExpectedMatch[] = [
{
captures: { $a: 'foo' },
node: 'let foo',
},
{
captures: { $a: 'bar', $b: '2' },
node: 'let bar = 2',
},
]
import { ExpectedMatch, findReplaceTestcase } fro... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/classBody.ts | test/findReplace/classBody.ts | export const input = `
class Foo {
a: number;
b: string;
c(): string {}
d(x: number): string {}
}
`
export const find = `
class Foo {
$$a
$b
d(x: number): string {}
}
`
export const expectedFind = [
{
node: `class Foo {
a: number;
b: string;
c(): string {}
d(x: number): string {}
}`,
ca... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/noCaptures.ts | test/findReplace/noCaptures.ts | export const input = `
1 + 2
const foo = bar
3 + 5
`
export const find = `1 + 2`
export const replace = `bar`
export const expectedReplace = `
bar
const foo = bar
3 + 5
`
import { findReplaceTestcase } from '../findReplaceTestcase'
findReplaceTestcase({
file: __filename,
input,
find,
replace,
expectedRepl... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/variableDeclaration.ts | test/findReplace/variableDeclaration.ts | export const input = `
var a = 1, b, c = 3, d = [1, 2, 3], e
`
export const find = `
var $a, $$b, $c = [1, $$d], e
`
export const expectedFind = [
{
node: `var a = 1, b, c = 3, d = [1, 2, 3], e`,
captures: {
$a: 'a = 1',
$c: 'd',
},
arrayCaptures: {
$$b: ['b', 'c = 3'],
$$d: ... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/blockStatement3.ts | test/findReplace/blockStatement3.ts | export const input = `
if (foo) {
const bar = foo
const baz = 3
const x = 1
console.log(x)
console.log(baz)
}
`
export const find = `if ($a) {
$$b
$c
const $d = 1
$$d
}`
export const expectedFind = [
{
node: `if (foo) {
const bar = foo
const baz = 3
const x = 1
console.log(x)
console... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/stringCaptureBackreference.ts | test/findReplace/stringCaptureBackreference.ts | export const input = `
const a = ['foo', \`foo\`]
const b = ['bar', \`bar\`]
const c = ['baz', \`qux\`]
`
export const find = `['$a', \`$a\`]`
export const expectedFind = [
{
node: "['foo', `foo`]",
captures: {
$a: "'foo'",
},
stringCaptures: {
$a: 'foo',
},
},
{
node: "['bar... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/nonCaptureExpressionStatement.ts | test/findReplace/nonCaptureExpressionStatement.ts | export const input = `
function foo() {
$a
}
`
export const find = `
function foo() {
$_a
}
`
export const expectedFind = [{ node: input.trim() }]
import { findReplaceTestcase } from '../findReplaceTestcase'
findReplaceTestcase({
file: __filename,
input,
find,
expectedFind,
})
| typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/exportSpecifiers.ts | test/findReplace/exportSpecifiers.ts | export const input = `
export A, {B, C, D, E} from 'foo'
`
export const find = `export {$$a, B, $C, $$b} from 'foo'`
export const expectedFind = [
{
node: `export A, {B, C, D, E} from 'foo'`,
arrayCaptures: {
$$a: ['A'],
$$b: ['D', 'E'],
},
captures: {
$C: 'C',
},
},
]
expor... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/jsxElementChildToExpession.ts | test/findReplace/jsxElementChildToExpession.ts | export const input = `
const body = () => (
<Mui.Button>
<Placeholder type="expression" stop={0} />
</Mui.Button>
)
`
export const find = `
<Placeholder type="expression" stop={$stop} />
`
export const replace = `
expression($stop)
`
export const expectedReplace = `
const body = () => (
<Mui.Button>
{e... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/bugs_nestedForOfVarToConst.ts | test/findReplace/bugs_nestedForOfVarToConst.ts | export const input = `
for (var x of [1, 2, 3]) {
for (var y of [4, 5, 6]) {
print(x, y)
}
}
`
export const find = `
for (var $a of $b) $body
`
export const replace = `
for (const $a of $b) $body
`
export const expectedReplace = `
for (const x of [1, 2, 3]) {
for (const y of [4, 5, 6]) {
print(x, y)
... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/identifierWithTypeAnnotationBackreferenceMismatch.ts | test/findReplace/identifierWithTypeAnnotationBackreferenceMismatch.ts | export const input = `
x()
let y: number
z()
let z: number
`
export const find = `
$a()
let $a: number
`
export const expectedFind = [
{ nodes: ['z()', 'let z: number'], captures: { $a: 'z' } },
]
import { findReplaceTestcase } from '../findReplaceTestcase'
findReplaceTestcase({
file: __filename,
input,
fin... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/objectRestSpread.ts | test/findReplace/objectRestSpread.ts | export const input = `
const a = {
foo: 'bar',
baz: 'qux',
glorm: {
a: 1,
b: 2,
c: 3,
d: 4,
...qlom,
}
}
const b = {
foo: 'bar',
baz: 'qux',
glorm: {
a: 1,
c: 3,
}
}
`
export const find = `{foo: 'bar', glorm: {a: 1, b: 2, ...$$inner}, ...$$outer}`
export const expectedFind... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/importSpecifiersDefaultUnordered.ts | test/findReplace/importSpecifiersDefaultUnordered.ts | export const input = `
import A, {B, C, D, E} from 'foo'
`
export const find = `import A, {E, C, D, B} from 'foo'`
export const expectedFind = [
{
node: `import A, {B, C, D, E} from 'foo'`,
},
]
import { findReplaceTestcase } from '../findReplaceTestcase'
findReplaceTestcase({
file: __filename,
input,
... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/templateLiteralSubMatching.ts | test/findReplace/templateLiteralSubMatching.ts | export const input = `
const x = \`foo \${1 + 2} bar\`
`
export const find = `
\`foo \${$a + $b} bar\`
`
export const expectedFind = [
{
node: '`foo ${1 + 2} bar`',
captures: {
$a: '1',
$b: '2',
},
},
]
export const replace = `
\`foo \${$a} bar \${$b}\`
`
export const expectedReplace = `... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/newExpression.ts | test/findReplace/newExpression.ts | export const input = `
new foo(a, {b: 3, c: 4}, c, d, [1, 2, 3])
`
export const find = `new $1($$a, d, $c)`
export const expectedFind = [
{
node: `new foo(a, {b: 3, c: 4}, c, d, [1, 2, 3])`,
captures: {
$1: 'foo',
$c: '[1, 2, 3]',
},
arrayCaptures: {
$$a: ['a', '{b: 3, c: 4}', 'c']... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/superClassCapture.ts | test/findReplace/superClassCapture.ts | export const input = `
class a extends b implements x, y {}
let c = class d extends e {}
a.b
c.d
f
g()
`
export const find = `
class a extends /**/$a {}
`
export const expectedFind = ['b', 'e'].map((node) => ({
node,
captures: { $a: node },
}))
import { findReplaceTestcase } from '../findReplaceTestcase'
findRep... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/quoting$.ts | test/findReplace/quoting$.ts | export const input = `
const x = $foo(2, 3)
`
export const find = `$_foo($a, $b)`
export const replace = `$_foo($b, $a)`
export const expectedReplace = `
const x = $foo(3, 2)
`
import { findReplaceTestcase } from '../findReplaceTestcase'
findReplaceTestcase({
file: __filename,
input,
find,
replace,
expect... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/maybeSuperTypeParameters.ts | test/findReplace/maybeSuperTypeParameters.ts | export const input = `
class Cls<A> extends Base {
}
`
export const find = `
class $A<$$B> extends $C<$Maybe<$D>> {
}
`
export const expectedFind = [
{
arrayCaptures: {
$$B: ['A'],
},
captures: {
$A: 'Cls',
$C: 'Base',
},
node: 'class Cls<A> extends Base {\n}',
},
]
export ... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/bugs_unexpectedObjectArray.ts | test/findReplace/bugs_unexpectedObjectArray.ts | export const input = `
setFakeServerHandler(() =>
Promise.resolve({
headers: javaScriptHeaders,
body: [
"function generateBid() {",
" return { bid: 0.03, render: 'about:blank#1' };",
"}",
].join("\\n"),
})
);
`
export const find = `
setFakeServerHandler(() => Promise.resolve($respons... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/tsImportSpecifiers.ts | test/findReplace/tsImportSpecifiers.ts | export const parsers = ['babel/tsx', 'recast/babel/tsx']
export const input = `
import A, {B, C, D, E} from 'foo'
`
export const find = `import {$$a, B, $C, $$b} from 'foo'`
export const expectedFind = [
{
node: `import A, {B, C, D, E} from 'foo'`,
arrayCaptures: {
$$a: ['A'],
$$b: ['D', 'E'],
... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/classImplements.ts | test/findReplace/classImplements.ts | export const input = `
class Foo implements A, B, C, D { }
`
export const find = `
class Foo implements $$a, C, $d { }
`
export const expectedFind = [
{
node: `class Foo implements A, B, C, D { }`,
captures: {
$d: 'D',
},
arrayCaptures: {
$$a: ['A', 'B'],
},
},
]
export const repl... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/stringPlaceholderMatchesBacktickString.ts | test/findReplace/stringPlaceholderMatchesBacktickString.ts | import { findReplaceTestcase } from '../findReplaceTestcase'
import dedent from 'dedent-js'
findReplaceTestcase({
file: __filename,
input: dedent`
'foo'
\`bar\`
\`bar\${baz}\`
`,
find: dedent`
'$s'
`,
expectedFind: ["'foo'", '`bar`'].map((node) => ({
node,
captures: { $s: node },
... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/nonCapturePlaceholder.ts | test/findReplace/nonCapturePlaceholder.ts | export const input = `
const foo = bar
`
export const find = `
const /**/ $a = $
`
export const expectedFind = [
{
node: 'foo = bar',
captures: { $a: 'foo' },
},
]
import { findReplaceTestcase } from '../findReplaceTestcase'
findReplaceTestcase({
file: __filename,
input,
find,
expectedFind,
})
| typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/renderPropsStylesRefactor.ts | test/findReplace/renderPropsStylesRefactor.ts | export const input = `
/**
* @flow
* @prettier
*/
import * as React from 'react'
import CodeInput from './CodeInput'
import { type FieldProps } from 'redux-form'
import FormHelperText from '@material-ui/core/FormHelperText'
import FormControl from '@material-ui/core/FormControl'
import FormLabel from '@material-ui/... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/classIdCapture.ts | test/findReplace/classIdCapture.ts | export const input = `
class a extends b implements x, y {}
let c = class d extends e {}
a.b
c.d
f
g()
`
export const find = `
class /**/$a {}
`
export const expectedFind = ['a', 'd'].map((node) => ({
node,
captures: { $a: node },
}))
import { findReplaceTestcase } from '../findReplaceTestcase'
findReplaceTestca... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/explodeShorthandProperty.ts | test/findReplace/explodeShorthandProperty.ts | export const input = `
const x = {
a, b
}
`
export const find = `
const x = { /**/ a: $a }
`
export const expectedFind = [
{
node: 'a',
captures: { $a: 'a' },
},
]
export const replace = `
const x = { /**/ c: $a }
`
export const expectedReplace = `
const x = {
c: a, b
}
`
import { findReplaceTestcas... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/findReplace/importSpecifierRestMatching.ts | test/findReplace/importSpecifierRestMatching.ts | export const input = `
import x, {a, b, c, d, e} from 'f'
`
export const find = `import {$$$b, b, d} from 'f'`
export const expectedFind = [
{
node: `import x, {a, b, c, d, e} from 'f'`,
arrayCaptures: {
$$$b: ['x', 'a', 'c', 'e'],
},
},
]
export const replace = `import {b, $$$b, d} from 'f'`
... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findPredicate.ts | test/astx/findPredicate.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
parsers: ['babel', 'babel/tsx'],
input: dedent`
class Foo {
x() { }
}
function foo() {
class Bar {
y() { }
}
}
`,... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/addImports-not-existing-namespace.ts | test/astx/addImports-not-existing-namespace.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
input: dedent`
import a from 'a'
function foo() {
}
`,
astx: ({ astx }: TransformOptions): void => {
astx.addImports`
import * as b... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/componentRefactor.ts | test/astx/componentRefactor.ts | import { Statement, TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
export const parsers = ['recast/babel']
export const input = `
/**
* @flow
* @prettier
*/
import * as React from 'react'
import gql from 'graphql-tag'
import {
Subscription,
type SubscriptionResult,
type O... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/replaceImport-default-to-named.ts | test/astx/replaceImport-default-to-named.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
input: dedent`
import foo, {foob} from 'foo'
import bar from 'bar'
`,
astx: ({ astx }: TransformOptions): void => {
astx.replaceImport`import f... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findImports-named-type-2.ts | test/astx/findImports-named-type-2.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
// parsers: ['babel/tsx'],
input: dedent`
import {type foo as bar, baz} from 'foo'
`,
astx: ({ astx, report }: TransformOptions): void => {
repo... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findImports-no-specifier-1.ts | test/astx/findImports-no-specifier-1.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
// parsers: ['babel/tsx', 'recast/babel/tsx'],
input: dedent`
import * as Blah from 'foo'
import 'foo'
`,
astx: ({ astx, report }: TransformOptio... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findImports-namespace-type-2.ts | test/astx/findImports-namespace-type-2.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
parsers: ['babel/tsx', 'recast/babel/tsx'],
input: dedent`
import * as Blah from 'foo'
import type * as Foo from 'foob'
`,
astx: ({ astx, report... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findImports-source-placeholder.ts | test/astx/findImports-source-placeholder.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
input: dedent`
import { foo as bar, qux } from 'foo'
import { foo as baz } from 'baz'
`,
astx: ({ astx, report }: TransformOptions): void => {
... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/replaceImport-named-value-to-default-type-capture.ts | test/astx/replaceImport-named-value-to-default-type-capture.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
input: dedent`
import { foo as blah, foo2 } from 'foo'
import bar from 'bar'
`,
astx: ({ astx }: TransformOptions): void => {
astx.replaceImpor... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/bugs_scope.ts | test/astx/bugs_scope.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import { NodePath as AstTypesNodePath } from 'ast-types/lib/node-path'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
input: dedent`
const foo = 1;
`,
parsers: ['babel', 'babel/tsx'],
astx: ({ ast... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findImports-namespace-value-2.ts | test/astx/findImports-namespace-value-2.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
// parsers: ['babel/tsx', 'recast/babel/tsx'],
input: dedent`
import * as Foo from 'foob'
import * as Blah from 'foo'
`,
astx: ({ astx, report }... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/scope-testcase.ts | test/astx/scope-testcase.ts | import { NodePath as AstTypesNodePath } from 'ast-types/lib/node-path'
import { Astx } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
input: dedent`
const x = 1, y = 2;
function foo() {
const y = 3;
const target = ... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/replaceImport-rename-capture-fn.ts | test/astx/replaceImport-rename-capture-fn.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
input: dedent`
import { foo as blah } from 'foo'
import bar from 'bar'
`,
astx: ({ astx }: TransformOptions): void => {
astx.replaceImport`impo... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/remove-ordered-match.ts | test/astx/remove-ordered-match.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
astxTestcase({
file: __filename,
input: `
const x = [1, 2, 3, 4]
`,
astx: ({ astx }: TransformOptions): void => {
astx.find`[1, $$b, 4]`.$$b.remove()
},
expected: `
const x = [1, 4];
`,
preferSimpleR... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findImports-named-type-3.ts | test/astx/findImports-named-type-3.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
// parsers: ['babel/tsx'],
input: dedent`
import {foo as bar, baz} from 'foo'
`,
astx: ({ astx, report }: TransformOptions): void => {
report(as... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/addImports-merge-two-defaults.ts | test/astx/addImports-merge-two-defaults.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
input: dedent`
import a from 'a'
`,
astx: ({ astx }: TransformOptions): void => {
astx.addImports`
import b from 'a'
`
},
expected: d... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findImports-no-specifier-2.ts | test/astx/findImports-no-specifier-2.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
// parsers: ['babel/tsx', 'recast/babel/tsx'],
input: dedent`
import type Foo from 'foo'
import * as Blah from 'foo'
import 'foob'
`,
astx: (... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findImports-default-type-1.ts | test/astx/findImports-default-type-1.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
// parsers: ['babel/tsx'],
input: dedent`
import Blah from 'foo'
import type Foo from 'foo'
`,
astx: ({ astx, report }: TransformOptions): void ... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/splitImports.ts | test/astx/splitImports.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
export const input = `
import { mapValues, map } from 'lodash'
import { fromPairs } from 'lodash'
`
export function astx({ astx }: TransformOptions): void {
astx.find`import { $$imports } from 'lodash'`.replace(
({ $$imp... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findImports-default-value-1.ts | test/astx/findImports-default-value-1.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
// parsers: ['babel/tsx'],
input: dedent`
import type Blah from 'foo'
import Foo, {baz, type glarb} from 'foo'
`,
astx: ({ astx, report }: Trans... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/addImports-merge-basic.ts | test/astx/addImports-merge-basic.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
input: dedent`
import {a} from 'a'
import {b} from 'b'
import {c, c as h} from 'c'
function foo() {
}
const bar = 2
`,
astx: ({ ... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findImports-named-type-1.ts | test/astx/findImports-named-type-1.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
// parsers: ['babel/tsx'],
input: dedent`
import type {foo as bar, baz} from 'foo'
`,
astx: ({ astx, report }: TransformOptions): void => {
repo... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findImports-default-type-2.ts | test/astx/findImports-default-type-2.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
// parsers: ['babel/tsx'],
input: dedent`
import Blah from 'foo'
import type Foo from 'foob'
`,
astx: ({ astx, report }: TransformOptions): void... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/replaceImport-rename-capture-relative.ts | test/astx/replaceImport-rename-capture-relative.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import Path from 'path'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
transformFile: Path.resolve(__filename, '..', 'bar/transform.ts'),
input: dedent`
import { foo as blah } from '../foo'
import... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/addImports-after-last-import.ts | test/astx/addImports-after-last-import.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
input: dedent`
import a from 'a'
import b from 'b'
function foo() {
}
`,
astx: ({ astx }: TransformOptions): void => {
astx.addImport... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/addImports-existing-namespace.ts | test/astx/addImports-existing-namespace.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
input: dedent`
import * as a from 'a'
function foo() {
}
`,
astx: ({ astx }: TransformOptions): void => {
astx.addImports`
import *... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findImports-multiple-1.ts | test/astx/findImports-multiple-1.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
// parsers: ['babel/tsx'],
input: dedent`
import Blah, {bar as qux} from 'foo'
import type Foo from 'foo'
`,
astx: ({ astx, report }: TransformO... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/replaceImport-named-value-to-default-type.ts | test/astx/replaceImport-named-value-to-default-type.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
input: dedent`
import { foo, foo2 } from 'foo'
import bar from 'bar'
`,
astx: ({ astx }: TransformOptions): void => {
astx.replaceImport`import... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/basic.ts | test/astx/basic.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
export const input = `
process.env.FOO
process.env.BAR
const { BAZ, QUX, BOO: boo } = process.env
let { GLORM } = process.env
;({ A } = process.env)
`
export function astx({ astx, report }: TransformOptions): void {
for (c... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/remove-unordered-match.ts | test/astx/remove-unordered-match.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
astxTestcase({
file: __filename,
input: `
const x = [1, 2, 3, 4]
`,
astx: ({ astx }: TransformOptions): void => {
astx.find`[1, 3, $$$rest]`.$$$rest.remove()
},
expected: `
const x = [1, 3];
`,
prefe... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findImports-default-value-2.ts | test/astx/findImports-default-value-2.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
// parsers: ['babel/tsx'],
input: dedent`
import type Blah from 'foo'
import { type default as Foob } from 'foo'
import {default as Foo, baz, typ... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/addImports-add-namespace-specifier-to-empty-import.ts | test/astx/addImports-add-namespace-specifier-to-empty-import.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
parsers: ['babel/tsx'],
input: dedent`
import 'a'
function foo() {
}
`,
astx: ({ astx }: TransformOptions): void => {
astx.addImports`
... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findImports-named-value-2.ts | test/astx/findImports-named-value-2.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
// parsers: ['babel/tsx'],
input: dedent`
import type {foo as qux} from 'foo'
import {foo as bar, baz} from 'foo'
`,
astx: ({ astx, report }: Tr... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/bugs_react-router-refactor.ts | test/astx/bugs_react-router-refactor.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
parsers: ['babel/tsx'],
input: dedent`
import * as React from 'react'
import { withRouter } from 'react-router-dom'
import type { LocationShape, ... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/insertComment.ts | test/astx/insertComment.ts | import dedent from 'dedent-js'
import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
astxTestcase({
file: __filename,
parsers: ['babel', 'babel/tsx'],
input: dedent`
const foo = 1
`,
astx: ({ astx }: TransformOptions): void => {
;(astx.node as any).program.body[0... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findImports-named-value-1.ts | test/astx/findImports-named-value-1.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
// parsers: ['babel/tsx'],
input: dedent`
import {type foo as qux} from 'foo'
import {foo as bar, baz} from 'foo'
`,
astx: ({ astx, report }: Tr... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/remove.ts | test/astx/remove.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
astxTestcase({
file: __filename,
input: `
const x = [1, 2, 3, 4]
`,
astx: ({ astx }: TransformOptions): void => {
astx.find`$Or(2, 4)`.remove()
},
expected: `
const x = [1, 3];
`,
preferSimpleReplace... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findImports-named-value-3.ts | test/astx/findImports-named-value-3.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
// parsers: ['babel/tsx'],
input: dedent`
import type {foo as qux} from 'foo'
import Foo, {foo as bar, baz} from 'foo'
`,
astx: ({ astx, report ... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findImports-default-type-3.ts | test/astx/findImports-default-type-3.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
// parsers: ['babel/tsx'],
input: dedent`
import Blah from 'foo'
import { default as Foob } from 'foo'
import { type default as Foo } from 'foo' ... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/replace-simple.ts | test/astx/replace-simple.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
astxTestcase({
file: __filename,
input: `
const x = [1, 2, 3, 4]
`,
astx: ({ astx }: TransformOptions): void => {
astx.find`$Or(2, 4)`.replace`5`
},
expected: `
const x = [1, 5, 3, 5]
`,
preferSimp... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/addImports-capture-existing-named.ts | test/astx/addImports-capture-existing-named.ts | import { expect } from 'chai'
import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
input: dedent`
import { a } from 'a'
import { b } from 'b'
import type { c } from 'c'
import { type d } from 'd'
... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findImports-multiple-2.ts | test/astx/findImports-multiple-2.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
// parsers: ['babel/tsx'],
input: dedent`
import Blah, {barg as qux} from 'foo'
import type Foo from 'foo'
`,
astx: ({ astx, report }: Transform... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/addImports-add-specifier-to-no-specifiers.ts | test/astx/addImports-add-specifier-to-no-specifiers.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
input: dedent`
import 'a'
`,
astx: ({ astx }: TransformOptions): void => {
astx.addImports`
import x, {type d} from 'a'
`
},
expected... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
codemodsquad/astx | https://github.com/codemodsquad/astx/blob/c76c2219fd40bdbd1c75dc8aa0ac13da14a56910/test/astx/findImports-no-specifier-3.ts | test/astx/findImports-no-specifier-3.ts | import { TransformOptions } from '../../src'
import { astxTestcase } from '../astxTestcase'
import dedent from 'dedent-js'
astxTestcase({
file: __filename,
// parsers: ['babel/tsx', 'recast/babel/tsx'],
input: dedent`
import type Foo from 'foo'
import {foo} from 'foo'
import 'foob'
`,
astx: ({ as... | typescript | MIT | c76c2219fd40bdbd1c75dc8aa0ac13da14a56910 | 2026-01-05T05:01:15.024820Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.