Code transformation
jsFam
jsFam(callback)
Returns JavaScript/TypeScript specific subcommands and helpers.
combining engines
Parameters
callback
CallbackFunction
requiredAllows to use JavaScript/TypeScript specific subcommands and helpers. Inside callback you can use addImport
and removeImport
to add or remove imports, astGrep
to search for code patterns and jscodeshift
to transform code.
jsFam
is always should be used together with files command. It automatically adds glob to find all js/ts files, so calling files().jsFam()
is equivalent to files('**/*.{js,jsx,ts,tsx,cjs,mjs}').jsFam()
.
Callback helpers:
addImport(imports)
- Accepts code with imports and automatically merges file imports with provided imports.removeImport(imports)
- Accepts code with imports and automatically removes provided imports from file imports.