New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

js-codemod

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-codemod

Codemod scripts to transform code to next generation JS

latest
Source
npmnpm
Version
7.0.0
Version published
Weekly downloads
87
35.94%
Maintainers
1
Weekly downloads
 
Created
Source

js-codemod

This repository contains a collection of codemod scripts to be used with JSCodeshift.

Setup & Run

  • npm install -g jscodeshift
  • npm install js-codemod
  • jscodeshift <codemod-script> <file>
  • Use the -d option for a dry-run and use -p to print the output for comparison

Included Scripts

use-strict adds a top-level 'use strict' statement to JavaScript files

  • jscodeshift -t node_modules/js-codemod/transforms/use-strict.js <file>

arrow-function transforms functions to arrow functions

  • jscodeshift -t node_modules/js-codemod/transforms/arrow-function.js <file>

It will transform function() { }.bind(this) calls to () => {}. If the only statement in the body is a ReturnStatement it will remove the curly braces. If you are feeling lucky and you know that returning the value of single-expression functions will not affect the behavior of your application you can specify the --inline-single-expressions=true option and it will transform function() { relay(); }.bind(this) to () => relay() instead of () => { relay(); }.

Recast Options

Options to recast's printer can be provided through the printOptions command line argument

  • jscodeshift -t transform.js <file> --printOptions='{"quote":"double"}'

Keywords

codemod

FAQs

Package last updated on 30 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts