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

@stanfaas/proptypes

v1.3.0

Published

A NodeJS script that helps you adding missing and removing unused PropTypes in your ReactJS projects that use ESLint.

Downloads

13

Readme

npm (scoped) npm bundle size (scoped)

proptypes

A NodeJS script that automatically adds or removes PropTypes to your react projects.

Table of Contents

  1. Installation and Preparation
  2. Usage
  3. Filing Issues
  4. Releases
  5. Semantic Versioning Policy
  6. Author

Installation and preparation

Prerequisites:

  • Node.js (^8.10.0, ^10.13.0, or >=11.10.1), npm version 3+.
  • ESLint (Any version, but the latest would be preferred).

You can install proptypes using npm:

npm install @stanfaas/proptypes --save-dev

or using yarn:

yarn add @stanfaas/proptypes

You should then add a eslint-report script to your package.json like this:

# package.json

...
"scripts": {
  "eslint-report": "./node_modules/.bin/eslint [your dir] -f json -o eslintresults.json",
  ...
}

Note: Be sure to replace [your dir] with your actual directory that you'd like to lint.

Lets run down on what we've done here. Like normal, we've added a eslint script that you can run like yarn eslint or npm eslint. However, we also added a -f and -o, these stand for format and ouput file path respectively.
So we have set the format to JSON and we output that JSON file into eslintresults.json which will automatically be put into the root folder of your project.

Another important thing you need to do, if you don't have them already, is to add the following rules to your .eslintrc (or .eslintrc.js):

"react/no-unused-prop-types": 1,
"react/prop-types": 1,

This makes sure your linter will show warnings when props are not set as PropTypes and when PropTypes are not used. If you want, you can also change the 1 to 2. It will then give you an error instead of an warning.

Usage

This CLI is not complicated at all. It only has add and remove functionality. To use it, just run:

Basic usage

./node_modules/.bin/proptypes

You'll then get the choice to either add missing PropTypes, or remove redundant ones.

Add missing proptypes

To add missing proptypes you only have to run:

./node_modules/.bin/proptypes add

Be aware: This scripts add the missing PropTypes with a type of string. Be sure to manually fix this afterwards while running through your project.

Remove unused PropTypes

To remove unused PropTypes you run:

./node_modules/.bin/proptypes remove

Is git clean?

The CLI will automatically check whether your project is clean or not. If not, it will tell you to stash or commit your code. If you don't want that, then pass the force argument to the CLI like the following example:

./node_modules/.bin/proptypes force

This will add missing PropTypes and forces the CLI to continue, disregarding the fact that your git directory is not clean.

Filing Issues

I'm always open to PRs and will check issues regularly. Whenever you have any questions or suggestions file an issue.

Releases

Whenever there is an update, I will release. Whether that will be a patch release, minor release or major release.

Semantic Versioning Policy

I follow semantic versioning. Here is a short overview of what that entails.

Given a version number MAJOR.MINOR.PATCH, increment the:

  • MAJOR version when you make incompatible API changes,
  • MINOR version when you add functionality in a backwards compatible manner, and
  • PATCH version when you make backwards compatible bug fixes. Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.

Author