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

deriv-codemod

Package Overview
Dependencies
Maintainers
5
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deriv-codemod

A tool for helping migrate code

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
5
Weekly downloads
 
Created
Source

deriv-codemod is a tool for helping migrate code. It uses jscodeshift internally to transform the source code.

Installation

deriv-codemod requires Node.js v14+ to run.

To install globally:

npm i -g deriv-codemod

Just run the below command to get started.

deriv-codemod

List of codemods available

  • Change extension

    • It simply modifies the extension of the file.
  • Convert proptypes to TS

    • It converts React propTypes to Typescript type.
    • The things it does are:
      • Remove prop-types import from the import section.
      • Collects the component name and the list of properties and their type in propTypes.
      • Generates a TS type based on component name and collected list of properties and their type.
      • Inserts the generated type as a type annotation to the props param of the component. It also supports destructured props, props in React.memo and React.forwardRef.
      • Removes the propTypes.
      • It also supports multiple components in the same file.
    • React propTypes to TS type:
      • Converts all the primitive types such as boolean, string, number to respective TS type.
      • For PropTypes.func, it will insert an empty anonymous arrow fn type () => void.
      • For PropTypes.object or PropTypes.array, it maps unknown as respective TS type.
      • It also supports PropTypes.oneOfTypes which will map it to TS union types.

Local development

Want to contribute? Great!

Open your Terminal and run the below command.

To install dependencies:

npm install

To build:

npm run build

Please check jscodeshift docs before writing a codemod.

FAQs

Package last updated on 04 Feb 2022

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

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