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

gen-rf

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gen-rf

Generate common tsx/jsx plus spec file

  • 1.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

gen-rf

Generates jsx or tsx file together with test or styles files, all with predefined snippets.

Component name is validated before usage (example for file: primary-button, component will be called PrimaryButton).

Usage

npx gen-rf

CLI Options

If --file or --out not specified, user will be prompted every time for input

Usage: index [options]

Options:
  -V, --version           output the version number
  -g, --gen-cfg           generate config file if one doesn't exist (default: true)
  type                    file type: tsx/jsx (default: "tsx")
  -f, --file <type>       specify file name
  -cnf, --config <type>   specify path to config file (default: ".genrfrc.json")
  -o, --out <type>        specify output dir
  -tsf, --test <type>     specify suffix for the test files: none/spec/test (default: "spec")
  -style, --style <type>  specify whenever to genereate css/scss/sass/less file or not (default: "none")
  -h, --help              display help for command

Config file

Configuration file overrides cli commands/options

.genrfrc.json:

{
  "rootDir": "./",
  "type": "tsx",
  "test": "spec",
  "style": "none"
}

Just run npx gen-rf and configuration file will be auto generated depending on user's input

package.json

npm

npm install gen-rf --save-dev

yarn

yarn add gen-rf -D
{
  "scripts": {
    "gen-rf": "gen-rf"
  }
}

Examples with options

npx gen-rf --tsx -o test -f secondary-button

test/secondary-button.tsx

import React from 'react'

interface SecondaryButtonProps {

}

export const SecondaryButton: React.FC<SecondaryButtonProps> = ({}) => {
    return ();
}

test/secondary-button.spec.ts

import { render } from "@testing-library/react";

import { SecondaryButton } from "./index";

describe("SecondaryButton component testing with testing-library", () => {
    const component = render(<SecondaryButton />);

    it("renders without crashing", () => {
        expect(component).toBeTruthy();
    });
});

Config File Options

OptionDescription
rootDirThe root directory used for file creation
typeType for newly craeted files: .jsx|.tsx
testThe suffix that should be appended to the test file: .(test|spec).(js|ts) or none
testThe suffix that should be appended to the style file: .(module|none).(css|scss|less|sass|none)

Keywords

FAQs

Package last updated on 18 May 2021

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