Skip to main content
hoist-prop-types
=========

A codemod that will hoist prop types and default props to the top of the file.
Currently only works with files with one component.

### Motivation
The main purpose is to bring the more important parts of your components, `propTypes`,
to the top of the file. PropTypes help explains what your component does, almost as
much as the render method. Keeping them close to the top of your file helps minimize
scrolling and keeps your code that much more consistent.


### Input:
```javascript
import * as React from 'react';
import PropTypes from 'prop-types';

class MyComponent extends React.Component {
render() { return null; }
}

MyComponent.propTypes = {
name: PropTypes.string,
};
MyComponent.defaultProps = {
name: 'Jim'
};
```

### Output:
```javascript
import * as React from 'react';
import PropTypes from 'prop-types';

const PROPS = {
name: PropTypes.string,
};

const DEFAULT_PROPS = {
name: 'Jim'
};

class MyComponent extends React.Component {
render() { return null; }
}

MyComponent.propTypes = PROPS;
MyComponent.defaultProps = DEFAULT_PROPS;

```

`hoist-prop-types` will work with `static propTypes ={...}` that are delared in the class as well.

Install
-----------
```
pip install hoist-prop-types
```

Usage
----------
```
hoist-prop-types ./my/dir/
```

This will read all `.js` and `.jsx` files and try to hoist the prop types to the top.

Metadata

Release files for hoist-prop-types 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hoist-prop-types 0.1.1
File Size Uploaded Provenance
hoist-prop-types-0.1.1.tar.gz 3.2 kB Without provenance Details

Release files / hoist-prop-types-0.1.1.tar.gz

Download URL hoist-prop-types-0.1.1.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
38324c7b88711f5b6011cec03e2b7ea411c743c28514a71cb5cc85ab05beeecf
BLAKE2b-256 checksum
How to use checksums
8bf6700a9de99ba134de8aef2f1f8aaaf627b5746304c19816d165579e05c91e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for hoist-prop-types 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page