Rule enhancement: allow regex in forbid-component-props allowedFor / disallowedFor #3686
Closed
Description
Is there an existing issue for this?
- I have searched the existing issues and my issue is unique
- My issue appears in the command-line and not only in the text editor
Description Overview
My team uses react/forbid-component-props
to disallow className and style props, but we maintain a list of legacy components that took these props before we introduced this rule. We now also have a bunch of icon components in the codebase that all have names like Icon24Something
. We like to pass style or className props to these to override css properties in some cases, so it'd be nice to be able to allow any component that matches /^Icon\d+/
.
Does this sound like a change you'd be happy to accept? I'd be okay sending a PR. Otherwise I'm also happy to fork the rule internally for our use case, but figured I'd check here to contribute back to the community.
Expected Behavior
I'd expect to be able to pass a regex to allowedFor
.
eslint-plugin-react version
v7.32.2
eslint version
v8.36.0
node version
v18.17.1
Activity