question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

forbid-component-props should have a component whitelist

See original GitHub issue

For custom components it makes sense to have the rule, but when using third-party components violating the rule (ReactModal using className is probably one of the more prominent examples) there isn’t much you can do about it…

Having to add eslint-disable react/forbid-component-props comments isn’t a very pretty solution.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
jsphstlscommented, Jun 4, 2019

This seems to be working:

const icons = require('react-icons/fa')
const iconWhitelist = Object.keys(icons)

'react/forbid-component-props': [2, {
  forbid: [{
    'propName': 'className',
    'allowedFor': iconWhitelist
  }]
}]
1reaction
ThiefMastercommented, Mar 22, 2018
{
  propName: string,
  allowedFor: [SomeComponent]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

JS.REACT.FORBID.COMPONENT.PROPS
Forbid certain props on Components (react/forbid-component-props) ... specifying the property name, an optional custom message, and a component whitelist:
Read more >
How to fix "Prop spreading is forbidden" in specialized ...
An alternative might be to pick or omit certain props to create a black- or whitelist, and then spread those. As far as...
Read more >
Why Whitelist Props on Shared React Components - Jake Trent
When we whitelist the props that our components will accept, we know exactly how teams are using our components. Or at least we...
Read more >
Tagify - Tags input Component - GitHub Pages
The last tag, "CSS", has the same value as the first tag, and will be removed, because the duplicates setting is set to...
Read more >
A bit of history early versions of React kept a whitelist of all the built ...
ContentsEach of these named items will become a component, withTweetbeing the ... Contents6PropsWhere HTML elements have “attributes,” React components have ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found