Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jscodeshift

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jscodeshift - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

6

package.json
{
"name": "jscodeshift",
"version": "0.1.0",
"description": "A toolkit for AST-to-AST JavaScript codemods",
"version": "0.1.1",
"description": "A toolkit for JavaScript codemods",
"repository": {

@@ -32,3 +32,3 @@ "type": "git",

"nomnom": "^1.8.1",
"recast": "^0.10.5"
"recast": "^0.10.10"
},

@@ -35,0 +35,0 @@ "devDependencies": {

# jscodeshift
jscodeshift is a toolkit for running AST-to-AST codemods over multiple JS files.
jscodeshift is a toolkit for running codemods over multiple JS files.
It provides:

@@ -49,4 +49,13 @@

transform(fileInfo, api, options);
```js
module.exports = function(fileInfo, api, options) {
// transform `fileInfo.source` here
// ...
// return changed source
return source;
};
```
### Arguments
#### `fileInfo`

@@ -79,11 +88,14 @@

*/
module.exports = function(path, source) {
return jscodeshift(source)
module.exports = function(fileInfo, api) {
return api.jscodeshift(fileInfo.source)
.findVariableDeclarators('foo')
.renameTo('bar')
.print();
.toSource();
}
```
`stat` is a function that only works when the `--dry` options is set. It accepts
**Note:** This api is exposed for convenience, but you don't have to use it.
You can use any tool to modify the source.
`stats` is a function that only works when the `--dry` options is set. It accepts
a string, and will simply count how often it was called with that value.

@@ -107,13 +119,4 @@

### Example
#### Return value
```js
module.exports = function(fileInfo, api, options) {
// transform `fileInfo.source` here
// ...
// return changed source
return source;
};
```
The return value of the function determines the status of the transformation:

@@ -129,5 +132,5 @@

The CLI provides a summary of the transformation at the end. You can get more
detailed information by setting the `-v` option to `1`, `2` or `3`.
detailed information by setting the `-v` option to `1` or `2`.
You can collect even more stats as explained below.
You can collect even more stats via the `stats` function as explained above.

@@ -240,3 +243,3 @@ ### Example

To learn about the provided method, have a look at the
To learn about the provided methods, have a look at the
[Collection.js](src/Collection.js) and its [extensions](src/collections/).

@@ -243,0 +246,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc