Skip to content

Commit 2e6a391

Browse files
committed
[Docs] forbid-foreign-prop-types: document allowInPropTypes option
Fixes #1815
1 parent 42a8093 commit 2e6a391

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
2828
* [Docs] [`jsx-no-target-blank`]: Improve readme ([#3169][] @apepper)
2929
* [Docs] [`display-name`]: improve examples ([#3189][] @golopot)
3030
* [Refactor] [`no-invalid-html-attribute`]: sort HTML_ELEMENTS and messages ([#3182][] @Primajin)
31+
* [Docs] [`forbid-foreign-prop-types`]: document `allowInPropTypes` option ([#1815][] @ljharb)
3132

3233
[#3195]: https://github.com/yannickcr/eslint-plugin-react/pull/3195
3334
[#3191]: https://github.com/yannickcr/eslint-plugin-react/pull/3191
@@ -43,6 +44,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
4344
[#3133]: https://github.com/yannickcr/eslint-plugin-react/pull/3133
4445
[#2921]: https://github.com/yannickcr/eslint-plugin-react/pull/2921
4546
[#2753]: https://github.com/yannickcr/eslint-plugin-react/pull/2753
47+
[#1815]: https://github.com/yannickcr/eslint-plugin-react/issues/1815
4648
[#1754]: https://github.com/yannickcr/eslint-plugin-react/issues/1754
4749
[#1046]: https://github.com/yannickcr/eslint-plugin-react/issues/1046
4850
[#620]: https://github.com/yannickcr/eslint-plugin-react/pull/620

docs/rules/forbid-foreign-prop-types.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This rule forbids using another component's prop types unless they are explicitly imported/exported. This allows people who want to use [babel-plugin-transform-react-remove-prop-types](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types) to remove propTypes from their components in production builds, to do so safely.
44

5-
In order to ensure that imports are explicitly exported it is recommended to use the ["named" rule in eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/named.md) in conjunction with this rule.
5+
In order to ensure that imports are explicitly exported it is recommended to use the ["named" rule in eslint-plugin-import](https://github.com/benmosher/eslint-plugin-import/blob/HEAD/docs/rules/named.md) in conjunction with this rule.
66

77
## Rule Details
88

@@ -25,6 +25,18 @@ Examples of **correct** code for this rule:
2525
import SomeComponent, {propTypes as someComponentPropTypes} from './SomeComponent';
2626
```
2727

28+
## Rule Options
29+
30+
```js
31+
...
32+
"react/forbid-foreign-prop-types": [<enabled>, { "allowInPropTypes": [<boolean>] }]
33+
...
34+
```
35+
36+
### `allowInPropTypes`
37+
38+
If `true`, the rule will not warn on foreign propTypes usage inside a propTypes declaration.
39+
2840
## When Not To Use It
2941

3042
This rule aims to make a certain production optimization, removing prop types, less prone to error. This rule may not be relevant to you if you do not wish to make use of this optimization.

0 commit comments

Comments
 (0)