An open API service indexing awesome lists of open source software.

https://github.com/skovy/font-awesome-codemod

⚙️ Font Awesome codemod script
https://github.com/skovy/font-awesome-codemod

List: font-awesome-codemod

codemod font-awesome jscodeshift typescript

Last synced: 25 days ago
JSON representation

⚙️ Font Awesome codemod script

Awesome Lists containing this project

README

          

# font-awesome-codemod [![Build Status](https://travis-ci.org/skovy/font-awesome-codemod.svg?branch=master)](https://travis-ci.org/skovy/font-awesome-codemod)

This repository contains a codemod script to use with [jscodeshift](https://github.com/facebook/jscodeshift).

## :hammer_and_wrench: Setup & Run

```sh
# Globally install (or consider using npx)
yarn global add jscodeshift

# Clone the transform (or try https://github.com/skovy/font-awesome-codemod)
git clone git@github.com:skovy/font-awesome-codemod.git

# Install the transform's dependencies
cd font-awesome-codemod
yarn install
cd ..

# Run the transform against your project
jscodeshift -t font-awesome-codemod/transforms/implicit-icons-to-explicit-imports.ts
```

Use the `-d` option for a dry-run and use `-p` to print the output for comparison. Also be sure to set the proper `--parser` and `--extensions` [jscodeshift options](https://github.com/facebook/jscodeshift#usage-cli) if not using vanilla JavaScript.

## :gear: Options:

All options have a default but can be set with the following options:

### `--componentName`:

**Type**: `string`

**Default**: `FontAwesomeIcon`

**Example**: `--componentName=Icon`

The name of the component to update the icon usage

### `--propName`

**Type**: `string`

**Default**: `icon`

**Example**: `--propName=iconProp`

The name of the prop on the component to update the icon usage.

### `--type`

**Type**: `"free" | "pro"`

**Default**: `free`

**Example**: `--type=pro`

The type of packages (imports) to replace the icons usages.

## :mag: Example

### :arrow_right: Input

```tsx
import * as React from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";

const Component = () => {
return ;
};
```

### ️ :arrow_left: Output

```tsx
import * as React from "react";
import { faMinusCircle } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";

const Component = () => {
return ;
};
```