npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jscodeshaft

v0.6.0

Published

Collection of more or less primitive helpers and abstractions for JSCodeShift, build for design system migrations and upgrades.

Downloads

77

Readme

JSCodeShaft

A collection of simple, often deliberately primitive JSCodeShift helpers and abstractions to ease the pain of upgrading/migrating and deprecating certain aspects of your codebases. The primary focus here are React-based design systems, but fair amount of code here may work in other envs too.

shaft noun [C]
a rod forming part of a machine such as an engine, that turns in order to pass power on to the machine.

Prerequisites

A parent project including [email protected] or newer.

Gotchas

  1. ast-types is currently out of date and trips up on Class-based react components. As a temporary workaround @gkz/ast-types package is used instead and swapped upon post-install.

Contributing

Whatever you do, familiarise yourself with how AST works. Preferably bookmark https://astexplorer.net/ and while you're at it, set the Transform to jscodeshift and the parser to whatever understands JSX, e.g. babel-eslint or flow.

In order to achieve anything, you will have to traverse a lot of nodes, so don't be afraid to abstract even small pieces of logic in helpers for future reuse.

Also, mutation is fine. In fact, it seems it's expected. Don't over-complicate your life trying to avoid it.

Please, please, please be verbose in your comments (obviously within reason) – there are many not entirely obvious cases you'll have to handle, and nobody wants to guess what you had in mind 3 months from now.

TODOs

  • [ ] ensure the package is consumable as expected
  • [ ] cleanup all helpers and their categories
  • [ ] sort out a roadmap
  • [ ] add a proper documentation on AST, JSCodeShift and this.

Various resources

  1. https://github.com/sejoker/awesome-jscodeshift
  2. https://github.com/rajasegar/awesome-codemods
  3. https://github.com/cowchimp/awesome-ast
  4. https://github.com/facebook/jscodeshift/tree/master/src/collections
  5. https://github.com/cpojer/js-codemod
  6. https://gist.github.com/ptbrowne/4fab98301c8bcffeaf3af215025d5b2c
  7. https://vramana.github.io/blog/2015/12/21/codemod-tutorial/
  8. https://skovy.dev/jscodeshift-custom-transform/
  9. https://github.com/cpojer/js-codemod/blob/master/transforms/template-literals.js
  10. https://www.npmjs.com/package/jscodeshift-helper
  11. https://katilius.dev/writing-js-codemods/