New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pinnacle0/codemod

Package Overview
Dependencies
Maintainers
5
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pinnacle0/codemod

Provide codemod by using babel and recast

  • 1.2.4
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-50%
Maintainers
5
Weekly downloads
 
Created
Source

@pinnacle0/codemod

This package provide various codemod to refactor code related to other pinnacle published packages.

Codemod does not guarantee 100% accuracy, please double check your source file after transform.

Installation

npm install -g @pinnacle0/codemod

or to install locally in order to use JavaScript API provided by use

pnpm add -D @pinnacle0/codemod

Usages

There to two way to execute the code: using command line and through JavaScript API

CLI usage

# list all avaliable codemod
pinnacle-codemod list
# Transform file, add --dry flat to dry-run
pinnacle-codemod transform <codemod> <path> 
# Help for advanced usage
pinnacle-codemod --help

It is recommanded to run transform with --dry flag first to make sure there are going to be no error during transform.

API usage

import { run } from '@pinnacle0/codemod'

// eg:
run('select-your-code-mod', './src/**/*.ts' , { dry: true });

Development

use new-codemod script to generate new template for creating the new codemod.

use codgen script to auto update the codemod list and type.

Core

@babel/parser is used to parse the source code to AST, and use recast to travel and transform the tree node.

The main reason of using recast instead of @babel/travse and @babel/generator is the former tries to preserve the style of original code as much as possible where later do not.

Known issues

  • Unable to preserve code style of JSX

  • Parse HTML entities incorrectly

License

MIT

FAQs

Package last updated on 21 Mar 2023

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