Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: facebook/jscodeshift
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1ed8ccddaa06e7126e56d5ce597e5aecbbffc22a
Choose a base ref
...
head repository: facebook/jscodeshift
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 13bf8067f5a1fc1010247c78e8ac01c543d5dc2e
Choose a head ref

Commits on Dec 5, 2018

  1. Fix #243 (#244)

    nickserv authored and fkling committed Dec 5, 2018
    Copy the full SHA
    6e38213 View commit details
  2. nomnom is not used anymore

    fkling committed Dec 5, 2018
    Copy the full SHA
    3fc6ca1 View commit details

Commits on Dec 6, 2018

  1. Improve/fix @babel/register usage (closes #294)

    The plugin names used have been incorrect. I'm also not 100% sure
    where `@babel/register` tries to load the plugins from, so to be safe, I
    require them directly.
    
    Because we use `preset-env` now, we can actually transpiling language
    features that the running Node version supports. This is done by setting
    `{targets: {node: true}}`.
    
    We also don't have to include the `proposal-object-rest-spread` plugin
    anymore, since it is part of ES2018 and thus handled by `preset-env`.
    fkling committed Dec 6, 2018
    Copy the full SHA
    cb92c48 View commit details
  2. Update changelog

    fkling committed Dec 6, 2018
    Copy the full SHA
    55ef34d View commit details
  3. Copy the full SHA
    891dea3 View commit details

Commits on Dec 14, 2018

  1. Introduce jest snapshot testing utils (fixes #135)

    - Refactored `runInlineTest` and extracted `applyTransform` function
    - Introduced `runSnapshotTest`, same as `runInlineTest` but takes no `expectedOutput`
        - maybe worth merging the two, but that requires breaking change
    - Introduced `defineSnapshotTest`, same as `defineInlineTest` but takes no `expectedOutput`
        - maybe worth merging the two, but that requires breaking change
    - `runInlineTest` and `runSnapshopTest` now both also return the result `applyTransform`
        - This can be used to take the result of one run and use it for another (check for idempotent)
    dogoku authored Dec 14, 2018
    Copy the full SHA
    413c558 View commit details
  2. Copy the full SHA
    60cfda5 View commit details

Commits on Jan 16, 2019

  1. Fix TypeError in case no files were found (#295)

    Fixes "UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined"
    skovhus authored and fkling committed Jan 16, 2019
    Copy the full SHA
    16fcf0a View commit details
  2. Copy the full SHA
    76734f7 View commit details

Commits on Jan 19, 2019

  1. Parse unknown CLI options as JSON

    ... to be compatible with nomnom and preserve behavior existing scripts
    expect.
    fkling committed Jan 19, 2019
    1
    Copy the full SHA
    ea1a4a4 View commit details
  2. Update changelog

    fkling committed Jan 19, 2019
    Copy the full SHA
    d289b23 View commit details
  3. Copy the full SHA
    6dd0eba View commit details

Commits on Mar 6, 2019

  1. Improve handling of .gitignore files. (#306)

    * Omit comments from list of patterns.
    * Support .gitignore files with \r\n linebreaks.
    amanda-mitchell authored and fkling committed Mar 6, 2019
    Copy the full SHA
    ec3ab98 View commit details
  2. Remove transform file .js restriction for testUtils (#308)

    Since we are able to write transformers in TS, the .js extension hard coded in testUtils not allow us to use it to write tests for TS transform modules.
    And `require('some-module')` will automatically infer some-module's extension whether it is ended with '.js' or '.ts', it should be safe to remove ',js'.
    pengx17 authored and fkling committed Mar 6, 2019
    Copy the full SHA
    036d62a View commit details

Commits on Mar 13, 2019

  1. Copy the full SHA
    e23d7fb View commit details

Commits on Apr 30, 2019

  1. Update changelog

    fkling committed Apr 30, 2019
    Copy the full SHA
    c5d60af View commit details
  2. Copy the full SHA
    2890872 View commit details

Commits on Jun 18, 2019

  1. Remove Reactiflux link

    nickserv authored Jun 18, 2019
    Copy the full SHA
    2ce79f5 View commit details
  2. Remove Reactiflux link (#328)

    Remove Reactiflux link
    cpojer authored Jun 18, 2019
    Copy the full SHA
    ef480de View commit details

Commits on Jul 18, 2019

  1. Fix Unhandled Promise rejection when called with a non-existent path

    When jscodeshift is called with a path that doesn't exist, `concatAll()` gets called with `undefined`, which isn't an interable, and throws an error. This PR fixes the promise being resolved by matching it with the ignore case.
    Sunil Pai authored Jul 18, 2019
    Copy the full SHA
    298690d View commit details

Commits on Aug 6, 2019

  1. Copy the full SHA
    8146833 View commit details

Commits on Aug 7, 2019

  1. Update .gitignore

    cpojer authored Aug 7, 2019
    Copy the full SHA
    2c269a7 View commit details
  2. Move to MIT license (#338)

    Move to MIT license
    cpojer authored Aug 7, 2019
    Copy the full SHA
    d63aa84 View commit details

Commits on Sep 6, 2019

  1. Merge pull request #334 from threepointone/patch-1

    Fix Unhandled Promise rejection when called with a non-existent path
    cpojer authored Sep 6, 2019
    Copy the full SHA
    5ed9108 View commit details

Commits on Sep 9, 2019

  1. Bump recast to ^0.18.1

    haoqunjiang authored and mroch committed Sep 9, 2019
    Copy the full SHA
    7748dba View commit details
  2. fix: preserve file extension for remote file

    There is behavior in this program that depends on the extension
    of the transformFile, notably how babel runs (or doesn't).
    
    There was a bug when requesting a remote transformFile authored as
    an ES6 module because of the temp filename being used.
    
    This commit preserves the original file extension used when writing
    the remote file to the temp one.
    samselikoff authored and mroch committed Sep 9, 2019
    Copy the full SHA
    5a6a868 View commit details

Commits on Sep 30, 2019

  1. Upgrade eslint dev dependency

    Summary:
    
    Test Plan:
    
    Reviewers:
    
    Subscribers:
    
    Tasks:
    
    Tags:
    gkz authored and mroch committed Sep 30, 2019
    Copy the full SHA
    a268d0d View commit details

Commits on Oct 21, 2019

  1. Introduce jest snapshot testing utils (fixes #135) (#297)

    Introduce jest snapshot testing utils (fixes #135)
    Daniel15 authored Oct 21, 2019
    Copy the full SHA
    8512b69 View commit details

Commits on Oct 23, 2019

  1. Copy the full SHA
    1764942 View commit details
  2. Copy the full SHA
    1201750 View commit details

Commits on Oct 29, 2019

  1. Merge pull request #332 from skovy/skovy/support-parsers-in-test-utils

    Support different parsers in the test utils
    Daniel15 authored Oct 29, 2019
    Copy the full SHA
    08b8608 View commit details
  2. Bump js-yaml from 3.12.0 to 3.13.1

    Bumps [js-yaml](https://github.com/nodeca/js-yaml) from 3.12.0 to 3.13.1.
    - [Release notes](https://github.com/nodeca/js-yaml/releases)
    - [Changelog](https://github.com/nodeca/js-yaml/blob/master/CHANGELOG.md)
    - [Commits](nodeca/js-yaml@3.12.0...3.13.1)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Oct 29, 2019
    Copy the full SHA
    835c001 View commit details
  3. Bump handlebars from 4.0.12 to 4.5.1

    Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.0.12 to 4.5.1.
    - [Release notes](https://github.com/wycats/handlebars.js/releases)
    - [Changelog](https://github.com/wycats/handlebars.js/blob/v4.5.1/release-notes.md)
    - [Commits](handlebars-lang/handlebars.js@v4.0.12...v4.5.1)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Oct 29, 2019
    Copy the full SHA
    05b59bb View commit details
  4. Bump mixin-deep from 1.3.1 to 1.3.2

    Bumps [mixin-deep](https://github.com/jonschlinkert/mixin-deep) from 1.3.1 to 1.3.2.
    - [Release notes](https://github.com/jonschlinkert/mixin-deep/releases)
    - [Commits](jonschlinkert/mixin-deep@1.3.1...1.3.2)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Oct 29, 2019
    Copy the full SHA
    67395a6 View commit details
  5. Bump lodash from 4.17.11 to 4.17.15

    Bumps [lodash](https://github.com/lodash/lodash) from 4.17.11 to 4.17.15.
    - [Release notes](https://github.com/lodash/lodash/releases)
    - [Commits](lodash/lodash@4.17.11...4.17.15)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Oct 29, 2019
    Copy the full SHA
    3c04772 View commit details

Commits on Oct 30, 2019

  1. Merge pull request #349 from facebook/dependabot/npm_and_yarn/handleb…

    …ars-4.5.1
    
    Bump handlebars from 4.0.12 to 4.5.1
    dsainati1 authored Oct 30, 2019
    Copy the full SHA
    d4b31b4 View commit details
  2. Merge pull request #350 from facebook/dependabot/npm_and_yarn/mixin-d…

    …eep-1.3.2
    
    Bump mixin-deep from 1.3.1 to 1.3.2
    dsainati1 authored Oct 30, 2019
    Copy the full SHA
    006bae8 View commit details
  3. Merge pull request #348 from facebook/dependabot/npm_and_yarn/js-yaml…

    …-3.13.1
    
    Bump js-yaml from 3.12.0 to 3.13.1
    dsainati1 authored Oct 30, 2019
    Copy the full SHA
    6fcdd10 View commit details
  4. Merge pull request #351 from facebook/dependabot/npm_and_yarn/lodash-…

    …4.17.15
    
    Bump lodash from 4.17.11 to 4.17.15
    dsainati1 authored Oct 30, 2019
    Copy the full SHA
    c84b745 View commit details

Commits on Dec 10, 2019

  1. Bump flow parser to 0.113

    jbrown215 committed Dec 10, 2019
    Copy the full SHA
    60d6880 View commit details

Commits on Dec 11, 2019

  1. update changelog

    jbrown215 committed Dec 11, 2019
    Copy the full SHA
    56b44eb View commit details
  2. bump version for releasing

    jbrown215 committed Dec 11, 2019
    Copy the full SHA
    24b032b View commit details
  3. Merge pull request #355 from jbrown215/bump_version

    Bump flow parser, update changelog, bump jscodeshift version
    jbrown215 authored Dec 11, 2019
    Copy the full SHA
    308e246 View commit details

Commits on Dec 12, 2019

  1. Update changelog with #297

    jbrown215 committed Dec 12, 2019
    Copy the full SHA
    e349703 View commit details

Commits on Apr 23, 2020

  1. rename any to isMatch

    mickaelzhang committed Apr 23, 2020
    Copy the full SHA
    62f2888 View commit details

Commits on Apr 25, 2020

  1. Merge pull request #371 from mickaelzhang/update-mm-method

    Rename micromatch any to isMatch
    gkz authored Apr 25, 2020
    Copy the full SHA
    d7631b4 View commit details

Commits on May 2, 2020

  1. Update npmignore

    cpojer committed May 2, 2020
    Copy the full SHA
    5885662 View commit details
  2. 0.7.1

    cpojer committed May 2, 2020
    Copy the full SHA
    4acfd61 View commit details

Commits on May 3, 2020

  1. Copy the full SHA
    9db8928 View commit details
  2. Copy the full SHA
    36c7e2e View commit details
Showing with 1,023 additions and 1,179 deletions.
  1. +0 −1 .gitignore
  2. +1 −0 .node-version
  3. +2 −0 .npmignore
  4. +1 −2 .travis.yml
  5. +40 −0 CHANGELOG.md
  6. +3 −3 CONTRIBUTING.md
  7. +17 −26 LICENSE
  8. +0 −33 PATENTS
  9. +50 −13 README.md
  10. +60 −32 bin/__tests__/jscodeshift-test.js
  11. +5 −7 bin/jscodeshift.js
  12. +5 −7 bin/jscodeshift.sh
  13. +7 −9 docs/Collection.js.html
  14. +7 −9 docs/collections_JSXElement.js.html
  15. +7 −9 docs/collections_Node.js.html
  16. +9 −11 docs/collections_VariableDeclarator.js.html
  17. +7 −9 docs/core.js.html
  18. +5 −7 index.js
  19. +8 −5 package.json
  20. +5 −7 parser/babel5Compat.js
  21. +5 −7 parser/babylon.js
  22. +5 −7 parser/flow.js
  23. +5 −7 parser/ts.js
  24. +5 −7 parser/tsOptions.js
  25. +5 −7 parser/tsx.js
  26. +5 −0 sample/__testfixtures__/typescript/reverse-identifiers.input.ts
  27. +5 −0 sample/__testfixtures__/typescript/reverse-identifiers.output.ts
  28. +5 −5 sample/__tests__/reverse-identifiers-test.js
  29. +3 −5 sample/reverse-identifiers.js
  30. +5 −7 src/Collection.js
  31. +9 −10 src/Runner.js
  32. +35 −14 src/Worker.js
  33. +5 −7 src/__tests__/Collection-test.js
  34. +5 −7 src/__tests__/Worker-test.js
  35. +16 −4 src/__tests__/argsParser-test.js
  36. +5 −7 src/__tests__/core-test.js
  37. +3 −5 src/__tests__/matchNode-test.js
  38. +5 −7 src/__tests__/template-test.js
  39. +13 −8 src/argsParser.js
  40. +5 −7 src/collections/JSXElement.js
  41. +5 −7 src/collections/Node.js
  42. +14 −7 src/collections/VariableDeclarator.js
  43. +5 −7 src/collections/__tests__/JSXElement-test.js
  44. +5 −7 src/collections/__tests__/Node-test.js
  45. +6 −7 src/collections/__tests__/VariableDeclarator-test.js
  46. +5 −7 src/collections/index.js
  47. +5 −7 src/core.js
  48. +5 −7 src/getParser.js
  49. +3 −3 src/ignoreFiles.js
  50. +5 −7 src/matchNode.js
  51. +5 −7 src/template.js
  52. +49 −16 src/testUtils.js
  53. +3 −4 src/utils/__tests__/intersection-test.js
  54. +3 −4 src/utils/__tests__/once-test.js
  55. +3 −4 src/utils/__tests__/union-test.js
  56. +4 −6 src/utils/intersection.js
  57. +4 −6 src/utils/once.js
  58. +4 −6 src/utils/union.js
  59. +5 −7 utils/requirePackage.js
  60. +9 −10 utils/testUtils.js
  61. +488 −725 yarn.lock
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/dist
node_modules/

1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9.11.2
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/docs/
/sample/
/recipes/
.gitignore
.eslintrc
.eslintrc.yaml
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
sudo: false
language: node_js
node_js:
- 6
- 8
- 10
- 12
- stable
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,46 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.7.0] 2019-12-11
## Added
- Added jest snapshot utils (#297, @dogoku)

### Changed
- Moved from BSD to MIT license

### Fixed
- No longer throw an error when calling jscodeshift on a non-existent path (#334, @threepointone)
- Preserve the original file extension in remote files (#317, @samselikoff)

## [0.6.4] 2019-04-30
### Changed
- Allow writing tests in TypeScript ([PR #308](https://github.com/facebook/jscodeshift/pull/308))
- Better handling of `.gitingore` files: Ignore comments and support `\r\n` line breaks ([PR #306](https://github.com/facebook/jscodeshift/pull/306))


## [0.6.3] 2019-01-18
### Fixed
- Don't throw an error when jscodeshift processes an empty set of files (#295,
@skovhus).
- `renameTo` should not rename class properties (#296, @henryqdineen).
- Custom/unknown CLI parameters are parsed as JSON, just like nomnom used to
do.


## [0.6.2] 2018-12-05
### Changed
- `@babel/register`/`@babel/preset-env` is configured to not transpile any
language features that the running Node process supports. That means if you use
features in your transform code supported by the Node version you are running,
they will be left as is. Most of ES2015 is actually supported since Node v6.
- Do not transpile object rest/spread in transform code if supported by running
Node version.

### Fixed
- Presets and plugins passed to `@babel/register` are now properly named and
loaded.


## [0.6.1] 2018-12-04
### Added
- Tranform files can be written in Typescript. If the file extension of the
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -42,6 +42,6 @@ outlined on that page and do not file a public issue.
* 80 character line length
* "Attractive"

## License
By contributing to jscodeshift, you agree that your contributions will be licensed
under its BSD license.
### License

jscodeshift is [MIT licensed](./LICENSE).
43 changes: 17 additions & 26 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
BSD License
MIT License

For jscodeshift software
Copyright (c) Facebook, Inc. and its affiliates.

Copyright (c) 2015-present, Facebook, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name Facebook nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
33 changes: 0 additions & 33 deletions PATENTS

This file was deleted.

63 changes: 50 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# jscodeshift [![Build Status](https://travis-ci.org/facebook/jscodeshift.svg?branch=master)](https://travis-ci.org/facebook/jscodeshift)

jscodeshift is a toolkit for running codemods over multiple JavaScript or
Typescript files.
TypeScript files.
It provides:

- A runner, which executes the provided transform for each file passed to it.
@@ -85,7 +85,7 @@ module.exports = function(fileInfo, api, options) {
};
```

As of v0.6.1, this module can also be written in Typescript.
As of v0.6.1, this module can also be written in TypeScript.

### Arguments

@@ -149,8 +149,7 @@ additional options to the transform. For example, if the CLI is called with
$ jscodeshift -t myTransforms fileA fileB --foo=bar
```

`options` would contain `{foo: 'bar'}`. jscodeshift uses [nomnom][] to parse
command line options.
`options` would contain `{foo: 'bar'}`.

### Return value

@@ -364,33 +363,76 @@ jscodeshift comes with a simple utility to allow easy unit testing with [Jest](h
- Test fixtures are located in a `__testfixtures__` directory

This results in a directory structure like this:

```
/MyTransform.js
/__tests__/MyTransform-test.js
/__testfixtures__/MyTransform.input.js
/__testfixtures__/MyTransform.output.js
```

To define a test, use `defineTest` or `defineInlineTest` from the `testUtils` module. A simple example is bundled in the [sample directory](sample).
A simple example of unit tests is bundled in the [sample directory](sample).

The `testUtils` module exposes a number of useful helpers for unit testing.

#### `defineTest`

Defines a Jest/Jasmine test for a jscodeshift transform which depends on fixtures

```js
jest.autoMockOff();
const defineTest = require('jscodeshift/dist/testUtils').defineTest;
defineTest(__dirname, 'MyTransform');
```

An alternate fixture filename can be provided as the fourth argument to `defineTest`. This also means that multiple test fixtures can be provided:
An alternate fixture filename can be provided as the fourth argument to `defineTest`.
This also means that multiple test fixtures can be provided:

```js
defineTest(__dirname, 'MyTransform', null, 'FirstFixture');
defineTest(__dirname, 'MyTransform', null, 'SecondFixture');
```
This will run two tests: One for `__testfixtures__/FirstFixture.input.js` and one for `__testfixtures__/SecondFixture.input.js`

This will run two tests:
- `__testfixtures__/FirstFixture.input.js`
- `__testfixtures__/SecondFixture.input.js`

#### `defineInlineTest`

Defines a Jest/Jasmine test suite for a jscodeshift transform which accepts inline values

This is a more flexible alternative to `defineTest`, as this allows to also provide options to your transform

```js
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
const transform = require('../myTransform');
const transformOptions = {};
defineInlineTest(transform, transformOptions, 'input', 'expected output', 'test name (optional)');
```

#### `defineSnapshotTest`

Similar to `defineInlineTest` but instead of requiring an output value, it uses Jest's `toMatchSnapshot()`

```js
const defineSnapshotTest = require('jscodeshift/dist/testUtils').defineSnapshotTest;
const transform = require('../myTransform');
const transformOptions = {};
defineSnapshotTest(transform, transformOptions, 'input', 'test name (optional)');
```

For more information on snapshots, check out [Jest's docs](https://jestjs.io/docs/en/snapshot-testing)

#### `applyTransform`

Executes your transform using the options and the input given and returns the result.
This function is used internally by the other helpers, but it can prove useful in other cases.

```js
const applyTransform = require('jscodeshift/dist/testUtils').applyTransform;
const transform = require('../myTransform');
defineInlineTest(transform, {}, 'input', 'expected output', 'test name (optional)');
const transformOptions = {};
const output = applyTransform(transform, transformOptions, 'input');
```

### Example Codemods
@@ -403,13 +445,8 @@ defineInlineTest(transform, {}, 'input', 'expected output', 'test name (optional

- [Retain leading comment(s) in file when replacing/removing first statement](recipes/retain-first-comment.md)

### Support

* Discord - [#codemod](https://discordapp.com/channels/102860784329052160/103748721107292160) on [Reactiflux](http://www.reactiflux.com/)

[npm]: https://www.npmjs.com/
[Mozilla Parser API]: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Parser_API
[recast]: https://github.com/benjamn/recast
[ast-types]: https://github.com/benjamn/ast-types
[ast-explorer]: http://astexplorer.net/
[nomnom]: https://www.npmjs.com/package/nomnom
Loading