diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a2c8ed216..e261114f85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange * [Docs] [`jsx-no-target-blank`]: Improve readme ([#3169][] @apepper) * [Docs] [`display-name`]: improve examples ([#3189][] @golopot) * [Refactor] [`no-invalid-html-attribute`]: sort HTML_ELEMENTS and messages ([#3182][] @Primajin) +* [Docs] [`forbid-foreign-prop-types`]: document `allowInPropTypes` option ([#1815][] @ljharb) [#3195]: https://github.com/yannickcr/eslint-plugin-react/pull/3195 [#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 [#3133]: https://github.com/yannickcr/eslint-plugin-react/pull/3133 [#2921]: https://github.com/yannickcr/eslint-plugin-react/pull/2921 [#2753]: https://github.com/yannickcr/eslint-plugin-react/pull/2753 +[#1815]: https://github.com/yannickcr/eslint-plugin-react/issues/1815 [#1754]: https://github.com/yannickcr/eslint-plugin-react/issues/1754 [#1046]: https://github.com/yannickcr/eslint-plugin-react/issues/1046 [#620]: https://github.com/yannickcr/eslint-plugin-react/pull/620 diff --git a/docs/rules/forbid-foreign-prop-types.md b/docs/rules/forbid-foreign-prop-types.md index ae8cb5ab0a..64b99f8fc5 100644 --- a/docs/rules/forbid-foreign-prop-types.md +++ b/docs/rules/forbid-foreign-prop-types.md @@ -2,7 +2,7 @@ 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. -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. +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. ## Rule Details @@ -25,6 +25,18 @@ Examples of **correct** code for this rule: import SomeComponent, {propTypes as someComponentPropTypes} from './SomeComponent'; ``` +## Rule Options + +```js +... +"react/forbid-foreign-prop-types": [, { "allowInPropTypes": [] }] +... +``` + +### `allowInPropTypes` + +If `true`, the rule will not warn on foreign propTypes usage inside a propTypes declaration. + ## When Not To Use It 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.