https://github.com/ammaraskar/eslint-injected-proptypes
ESLint prop types rule for React that avoids problems with injected props
https://github.com/ammaraskar/eslint-injected-proptypes
Last synced: 9 months ago
JSON representation
ESLint prop types rule for React that avoids problems with injected props
- Host: GitHub
- URL: https://github.com/ammaraskar/eslint-injected-proptypes
- Owner: ammaraskar
- License: mit
- Created: 2018-06-12T03:29:40.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-13T18:47:06.000Z (about 8 years ago)
- Last Synced: 2025-03-02T03:41:25.738Z (over 1 year ago)
- Language: JavaScript
- Size: 94.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/ammaraskar/eslint-injected-proptypes)
[](https://codecov.io/gh/ammaraskar/eslint-injected-proptypes)
[](https://www.npmjs.com/package/eslint-plugin-injected-proptypes)
# Install
1. Install the package:
`npm install --dev eslint-plugin-injected-proptypes`
`yarn add --dev eslint-plugin-injected-proptypes`
2. Add `"plugins": ["injected-proptypes"]` to your eslint config file.
# Prevent missing propTypes in React components (non-injected-prop-types)
This rule ensures that all your React components have propTypes set for all of their used properties.
However, it ignores common injected properties such as those introduced by Redux's `mapDispatchToProps` and
`mapStateToProps`. See [eslint-plugin-react/#553](https://github.com/yannickcr/eslint-plugin-react/issues/553)
for more details.
## Rule Details
Examples of **incorrect** code for this rule:
```js
const Foo = ({ propMissingType }) =>
(
{propMissingType}
);
```
Examples of **correct** code for this rule:
```js
const Foo = ({providedProp, injectedProp}) =>
(
{providedProp}
{injectedProp}
);
const mapStateToProps = state => ({
injectedProp: state.fooBar
});
Foo.propTypes = {
providedProp: PropTypes.string.isRequired
};
export default connect(mapStateToProps)(Foo);
```
### Options
Consult the documentation for the original rule here:
https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md