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

fela-codemods

v12.2.1

Published

Automatic codemods to upgrade Fela code to newer versions

Downloads

14

Readme

fela-codemods

Automatic Codemods to migrate your Fela code to newer versions using jscodeshift.

Installation

yarn add fela-codemods

You may alternatively use npm i --save fela-codemods.

Usage

First of all, we need to have jscodeshift installed globally.

yarn global add jscodeshift

You may alternatively use npm i -g jscodeshift.

Now transforming our codebase is as simple as using the jscodeshift CLI.

jscodeshift -t node_modules/fela-codemods/lib/{codemod} [path]

where codemod is the actual codemod file that should be used and path is either a single file or a directory. Note: If using Typescript of Flow, you may need to specify the parser argument, e.g.,

jscodeshift --parser=flow -t node_modules/fela-codemods/lib/{codemod} [path]

Available Codemods

The following list shows all available codemods for different version migrations. In order to use all codemods for a specific version at once, we use index as our codemod value.

Table of Contents

v10

FelaComponent

| Packages | Codemod | | --- | --- | | react-felainferno-felapreact-fela | v10/FelaComponent.js |

Renames the rule prop to style and transforms all style as a function of theme to a function of props. Also transforms the render prop to either as or children respectively.

Warning: This codemod transforms inline functions passed to the style prop (theme => ... -> ({ theme }) => ...), but cannot handle non inlined functions. The following case would need to be handled manually:

<FelaComponent style={myStyle}>...</FelaComponent>

// The signature of this function is not transformed by the codemode,
// and should be manually edited to:
//   function myStyle({ theme, }) { ... }
function myStyle(theme) { return { color: theme.color, } }
const Usage = (
  <FelaComponent rule={({ color }) => ({ fontSize: 15, color })} />
)
const Usage = (
  <FelaComponent style={theme => ({ color: theme.primary })} />
)
const Usage = (
  <FelaComponent render="div">Hello</FelaComponent>
)
const Usage = (
  <FelaComponent render={({ className }) => <div className={className}>Hello</div>} />
)
const Usage = (
  <FelaComponent style={({ color }) => ({ fontSize: 15, color })} />
)
const Usage = (
  <FelaComponent style={({ theme }) => ({ color: theme.primary })} />
)
const Usage = (
  <FelaComponent as="div">Hello</FelaComponent>
)
const Usage = (
  <FelaComponent>{({ className }) => <div className={className}>Hello</div>}</FelaComponent>
)

FelaTheme

| Packages | Codemod | | --- | --- | | react-felainferno-felapreact-fela | v10/FelaTheme.js

Refactors using the render prop to use the children special prop instead.

const Usage = (
  <FelaTheme render={theme => <div>{theme.color.primary}</div>} />
)
const Usage = (
  <FelaTheme>{theme => <div>{theme.color.primary}</div>}</FelaTheme>
)

RendererProvider

| Packages | Codemod | | --- | --- | | react-felainferno-felapreact-fela | v10/RendererProvider.js

Renames all usages of Provider to RendererProvider. Also works for named imports.

import { Provider } from 'react-fela'

const Usage = (
  <Provider renderer={renderer}>
    <App />
  </Provider>
)
import { Provider as FelaProvider } from 'react-fela'

const Usage = (
  <FelaProvider renderer={renderer}>
    <App />
  </FelaProvider>
)
import { RendererProvider } from 'react-fela'

const Usage = (
  <RendererProvider renderer={renderer}>
    <App />
  </RendererProvider>
)
import { RendererProvider as FelaProvider } from 'react-fela'

const Usage = (
  <FelaProvider renderer={renderer}>
    <App />
  </FelaProvider>
)

Example

# applies all version 10 codemods to all .js files in src
jscodeshift -t node_modules/fela-codemods/lib/v10/index.js src

# applies the version 10 FelaComponent codemod to all .js files in src
jscodeshift -t node_modules/fela-codemods/lib/v10/FelaComponent.js src

License

Fela is licensed under the MIT License. Documentation is licensed under Creative Commons License. Created with ♥ by @robinweser and all the great contributors.