diff --git a/CHANGELOG.md b/CHANGELOG.md index e398952980..01df9f267e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange ### Added * [`jsx-newline`]: add `allowMultiline` option when prevent option is true ([#3311][] @TildaDares) +* [`forbid-dom-props`]: add `disallowedFor` option ([#3338][] @TildaDares) ### Fixed * [`jsx-no-literals`]: properly error on children with noAttributeStrings: true ([#3317][] @TildaDares) @@ -32,6 +33,7 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange [#3347]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3347 [#3344]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3344 [#3339]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3339 +[#3338]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3338 [#3335]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3335 [#3331]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3331 [#3328]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3328 diff --git a/docs/rules/forbid-dom-props.md b/docs/rules/forbid-dom-props.md index 5e89b84ae7..15a1229324 100644 --- a/docs/rules/forbid-dom-props.md +++ b/docs/rules/forbid-dom-props.md @@ -43,12 +43,13 @@ Examples of **correct** code for this rule: ### `forbid` An array of strings, with the names of props that are forbidden. The default value of this option `[]`. -Each array element can either be a string with the property name or object specifying the property name and an optional -custom message: +Each array element can either be a string with the property name or object specifying the property name, an optional +custom message, and a DOM nodes disallowed list (e.g. `
`): ```js { "propName": "someProp", + "disallowedFor": ["DOMNode", "AnotherDOMNode"], "message": "Avoid using someProp" } ``` diff --git a/lib/rules/forbid-dom-props.js b/lib/rules/forbid-dom-props.js index 45beef4083..3b48098e3f 100644 --- a/lib/rules/forbid-dom-props.js +++ b/lib/rules/forbid-dom-props.js @@ -18,6 +18,21 @@ const DEFAULTS = []; // Rule Definition // ------------------------------------------------------------------------------ +/** + * @param {Map